import Data.Proxy (Proxy(..))
import Prelude hiding ((&&), not, (||))
-import Language.Symantic.Parsing
-import Language.Symantic.Typing
-import Language.Symantic.Compiling
-import Language.Symantic.Interpreting
-import Language.Symantic.Lib.Bool
-import Language.Symantic.Lib.Lambda ((~>))
-import Compiling.Term.Test
+import Language.Symantic
+import Language.Symantic.Lib
+-- import Language.Symantic.Lib.Lambda ((~>))
+import Compiling.Test
-type Ifaces =
+type SS =
[ Proxy Bool
, Proxy (->)
, Proxy Integer
+ , Proxy []
+ , Proxy Char
]
-(==>) = test_compile @Ifaces
+(==>) = test_readTerm @() @SS
tests :: TestTree
tests = testGroup "Bool" $
- [ "True" ==> Right (ty @Bool, True, "True")
- , "xor True True" ==> Right (ty @Bool, False, "((\\x0 -> (\\x1 -> x0 `xor` x1)) True) True")
- , "xor False True" ==> Right (ty @Bool, True, "((\\x0 -> (\\x1 -> x0 `xor` x1)) False) True")
- , "True `xor` True" ==> Right (ty @Bool, False, "((\\x0 -> (\\x1 -> x0 `xor` x1)) True) True")
- , "(\\(xy:Bool) -> xy) True" ==> Right (ty @Bool, True, "(\\x0 -> x0) True")
- , "(\\(False:Bool) -> False) True" ==> Right (ty @Bool, True, "(\\x0 -> x0) True")
- , "(\\(False:Bool) -> False) (False `xor` True)" ==> Right
- (ty @Bool, True, "(\\x0 -> x0) (((\\x0 -> (\\x1 -> x0 `xor` x1)) False) True)")
- , "(\\(lett:Bool) -> lett) True" ==> Right (ty @Bool, True, "(\\x0 -> x0) True")
- , "(\\(x:Bool) -> xor x x) True" ==> Right
- (ty @Bool, False, "(\\x0 -> ((\\x1 -> (\\x2 -> x1 `xor` x2)) x0) x0) True")
- , "let x = True in xor x True" ==> Right
- (ty @Bool, False, "let x0 = True in ((\\x1 -> (\\x2 -> x1 `xor` x2)) x0) True")
+ [ "True" ==> Right (tyBool, True , "True")
+ , "xor True True" ==> Right (tyBool, False, "True `xor` True")
+ , "xor False True" ==> Right (tyBool, True , "False `xor` True")
+ , "True `xor` True" ==> Right (tyBool, False, "True `xor` True")
+ , "(\\(xy:Bool) -> xy) True" ==> Right (tyBool, True , "(\\x0 -> x0) True")
+ , "(\\(False:Bool) -> False) True" ==> Right (tyBool, True , "(\\x0 -> x0) True")
+ , "(\\(lett:Bool) -> lett) True" ==> Right (tyBool, True , "(\\x0 -> x0) True")
+ , "(\\(x:Bool) -> xor x x) True" ==> Right (tyBool, False, "(\\x0 -> x0 `xor` x0) True")
+ , "let x = True in xor x True" ==> Right (tyBool, False, "let x0 = True in x0 `xor` True")
+ , "(\\(False:Bool) -> False) (False `xor` True)" ==> Right (tyBool, True, "(\\x0 -> x0) (False `xor` True)")
, testGroup "Error_Term"
- [ "True True" ==> Left (ty @Bool,
- Right $ Error_Term_Con_Type $
- Right $ Con_TyApp $
- At (maybeRight $ test_tokenizer "True") $
- EType $ ty @Bool)
- , "(\\(x:Bool) -> x `xor` True) Bool" ==> Left (ty @Bool,
- Right $ Error_Term_unbound $ Term_Name "Bool")
- , "(\\(x:Bool) -> x) True True" ==> Left (ty @Bool,
- Right $ Error_Term_Con_Type $
- Right $ Con_TyApp $
- At (maybeRight $ test_tokenizer "(\\(x:Bool) -> x) True") $
- EType $ ty @Bool)
- , "(\\(x:Bool -> Bool) -> x True) True" ==> Left (ty @Bool,
- Right $ Error_Term_Con_Type $ Right $
- Con_TyEq
- (Right $ At (maybeRight $ test_tokenizer "(\\(x:Bool -> Bool) -> x True)") $
- EType $ (ty @Bool ~> ty @Bool))
- (At (maybeRight $ test_tokenizer "True") $
- EType $ ty @Bool)
- )
+ [ "True True" ==> Left (tyBool,
+ Right $ Error_Term_Beta $
+ Error_Beta_Term_not_a_function $
+ TypeVT $ tyBool @_ @'[])
+ , "x" ==> Left (tyBool,
+ Right $ Error_Term_unknown $ NameTe "x")
+ , "x `xor` True" ==> Left (tyBool,
+ Right $ Error_Term_unknown $ NameTe "x")
+ , "(\\(x:Bool) -> x `xor` True) Bool" ==> Left (tyBool,
+ Right $ Error_Term_unknown $ NameTe "Bool")
+ , "(\\(x:Bool) -> x) True True" ==> Left (tyBool,
+ Right $ Error_Term_Beta $
+ Error_Beta_Term_not_a_function $
+ TypeVT $ tyBool @_ @'[])
+ , "(\\(x:Bool -> Bool) -> x True) True" ==> Left (tyBool,
+ Right $ Error_Term_Beta $ Error_Beta_Unify $
+ Error_Unify_Const_mismatch
+ (TypeVT $ tyFun @_ @'[])
+ (TypeVT $ tyBool @_ @'[]))
]
]
x :: repr Bool
y :: repr Bool
z :: repr Bool
-instance Sym_Bool_Vars TextI where
- x = TextI $ \_p _v -> "x"
- y = TextI $ \_p _v -> "y"
- z = TextI $ \_p _v -> "z"
+instance Sym_Bool_Vars View where
+ x = View $ \_p _v -> "x"
+ y = View $ \_p _v -> "y"
+ z = View $ \_p _v -> "z"
{-
instance -- Trans_Boo_Const
( Sym_Bool repr