bergamot/test/Main.purs

24 lines
830 B
Plaintext
Raw Normal View History

2023-02-28 19:44:24 -08:00
module Test.Main where
import Prelude
import Language.Bergamot.Syntax
import Control.Monad.Logic.Trans
import Control.Monad.Logic.Class
import Control.Monad.Unify.Trans
import Control.Monad.Unify.Class
import Data.List
import Data.Maybe
2023-02-28 19:44:24 -08:00
runSomeComputation :: forall m. MonadLogic m => MonadUnify IntVar Expr m => m (Expr IntVar)
runSomeComputation = do
x1 <- fresh
x2 <- fresh
let binPred = Atom "hello" $ fromFoldable [variable x1, variable x2]
let realBinPred = Atom "hello" $ fromFoldable [Atom "first" $ fromFoldable [], Atom "second" $ fromFoldable []]
unify binPred realBinPred
(unify (variable x1) (variable x2) >>= const (reify (variable x1))) `interleave` (unify (variable x1) (variable x1) >>= const (reify (variable x2)))
main :: Maybe (Expr IntVar)
main = runUnifier runSomeComputation