init
authorJulien Moutinho <julm+symantic@autogeree.net>
Tue, 18 Oct 2016 12:16:59 +0000 (14:16 +0200)
committerJulien Moutinho <julm+symantic@autogeree.net>
Tue, 18 Oct 2016 16:15:59 +0000 (18:15 +0200)
29 files changed:
Language/Symantic/AST/Test.hs
Language/Symantic/Expr/Bool/Test.hs
Language/Symantic/Expr/Common.hs
Language/Symantic/Expr/Eq.hs
Language/Symantic/Expr/Eq/Test.hs
Language/Symantic/Expr/If.hs
Language/Symantic/Expr/If/Test.hs
Language/Symantic/Expr/Int/Test.hs
Language/Symantic/Expr/Lambda.hs
Language/Symantic/Expr/List.hs
Language/Symantic/Expr/List/Test.hs
Language/Symantic/Expr/Map.hs
Language/Symantic/Expr/Maybe.hs
Language/Symantic/Expr/Maybe/Test.hs
Language/Symantic/Expr/Ord.hs
Language/Symantic/Expr/Tuple.hs
Language/Symantic/Repr/Text/Test.hs
Language/Symantic/Type/Bool.hs
Language/Symantic/Type/Common.hs
Language/Symantic/Type/Fun.hs
Language/Symantic/Type/Int.hs
Language/Symantic/Type/List.hs
Language/Symantic/Type/Map.hs
Language/Symantic/Type/Maybe.hs
Language/Symantic/Type/Ordering.hs
Language/Symantic/Type/Tuple.hs
Language/Symantic/Type/Unit.hs
Language/Symantic/Type/Var.hs
symantic.cabal

index 43021c0d8cdef38aa9fbc2678b1303a64d10e8b9..16011c608e949eb336da2cccf67b57c807a1792c 100644 (file)
@@ -129,7 +129,7 @@ op1_from_AST
  ( ty ~ Type_Root_of_Expr ex
  , root ~ Root_of_Expr ex
  , ast ~ AST
- , Type_Eq (Type_Root_of_Expr root)
+ , Eq_Type (Type_Root_of_Expr root)
  , Expr_from ast root
  , Error_Expr_Lift (Error_Expr (Error_of_Type ast ty) ty ast)
                    (Error_of_Expr ast root)
@@ -148,7 +148,7 @@ op2_from_AST
  ( ty ~ Type_Root_of_Expr ex
  , root ~ Root_of_Expr ex
  , ast ~ AST
- , Type_Eq (Type_Root_of_Expr root)
+ , Eq_Type (Type_Root_of_Expr root)
  , Expr_from ast root
  , Error_Expr_Lift (Error_Expr (Error_of_Type ast ty) ty ast)
                    (Error_of_Expr ast root)
@@ -209,7 +209,7 @@ instance -- Type_from AST Type_Int
                                Error_Type_Wrong_number_of_arguments ast 0
                 _ -> Left $ error_type_unsupported ty ast
 instance -- Type_from AST Type_Fun
- ( Type_Eq root
+ ( Eq_Type root
  , Type_from AST root
  , Type_Root_Lift (Type_Fun lam) root
  , Error_Type_Lift   (Error_Type AST) (Error_of_Type AST root)
@@ -226,7 +226,7 @@ instance -- Type_from AST Type_Fun
                                Error_Type_Wrong_number_of_arguments ast 2
                 _ -> Left $ error_type_unsupported ty ast
 instance -- Type_from AST Type_Maybe
- ( Type_Eq root
+ ( Eq_Type root
  , Type_from AST root
  , Type_Root_Lift Type_Maybe root
  , Error_Type_Lift   (Error_Type AST) (Error_of_Type AST root)
@@ -361,14 +361,14 @@ instance -- Expr_from AST Expr_Maybe
  ) => Expr_from AST (Expr_Maybe lam root) where
        expr_from ex ast ctx k =
                case ast of
-                AST "maybe"   asts -> from_ast3 asts maybe_from ex ast ctx k
+                AST "maybe"   asts -> from_ast3 asts maybe_from   ex ast ctx k
                 AST "nothing" asts -> from_ast1 asts nothing_from ex ast ctx k
-                AST "just"    asts -> from_ast1 asts just_from ex ast ctx k
+                AST "just"    asts -> from_ast1 asts just_from    ex ast ctx k
                 _ -> Left $ error_expr_unsupported ex ast
 instance -- Expr_from AST Expr_Eq
  ( Type_from AST (Type_Root_of_Expr root)
  , Type_Lift Type_Bool (Type_of_Expr root)
- , Type_Constraint Eq (Type_Root_of_Expr root)
+ , Constraint_Type Eq (Type_Root_of_Expr root)
  , Expr_from AST root
  , Error_Expr_Lift (Error_Expr_of_Root AST root) (Error_of_Expr AST root)
  , Root_of_Expr root ~ root
@@ -381,7 +381,7 @@ instance -- Expr_from AST Expr_Eq
 instance -- Expr_from AST Expr_Ord
  ( Type_from AST (Type_Root_of_Expr root)
  , Type_Lift Type_Ordering (Type_of_Expr root)
- , Type_Constraint Ord (Type_Root_of_Expr root)
+ , Constraint_Type Ord (Type_Root_of_Expr root)
  , Expr_from AST root
  , Error_Expr_Lift (Error_Expr_of_Root AST root) (Error_of_Expr AST root)
  , Root_of_Expr root ~ root
@@ -405,8 +405,8 @@ instance -- Expr_from AST Expr_List
  ) => Expr_from AST (Expr_List lam root) where
        expr_from ex ast ctx k =
                case ast of
-                AST "[]"          asts -> from_ast1 asts list_empty_from ex ast ctx k
-                AST ":"           asts -> from_ast2 asts list_cons_from ex ast ctx k
+                AST "[]"          asts -> from_ast1 asts list_empty_from  ex ast ctx k
+                AST ":"           asts -> from_ast2 asts list_cons_from   ex ast ctx k
                 AST "list_filter" asts -> from_ast2 asts list_filter_from ex ast ctx k
                 _ -> Left $ error_expr_unsupported ex ast
 instance -- Expr_from AST Expr_Map
@@ -414,13 +414,13 @@ instance -- Expr_from AST Expr_Map
  , Expr_from AST root
  , Type_Lift   (Type_Fun lam) (Type_of_Expr root)
  , Type_Unlift (Type_Fun lam) (Type_of_Expr root)
- , Type_Lift   Type_Map      (Type_of_Expr root)
- , Type_Unlift Type_Map      (Type_of_Expr root)
- , Type_Lift   Type_List     (Type_of_Expr root)
- , Type_Unlift Type_List     (Type_of_Expr root)
- , Type_Lift   Type_Tuple2   (Type_of_Expr root)
- , Type_Unlift Type_Tuple2   (Type_of_Expr root)
- , Type_Constraint Ord (Type_Root_of_Expr root)
+ , Type_Lift   Type_Map       (Type_of_Expr root)
+ , Type_Unlift Type_Map       (Type_of_Expr root)
+ , Type_Lift   Type_List      (Type_of_Expr root)
+ , Type_Unlift Type_List      (Type_of_Expr root)
+ , Type_Lift   Type_Tuple2    (Type_of_Expr root)
+ , Type_Unlift Type_Tuple2    (Type_of_Expr root)
+ , Constraint_Type Ord (Type_Root_of_Expr root)
  , Error_Expr_Lift (Error_Expr_of_Root AST root) (Error_of_Expr AST root)
  , Root_of_Expr root ~ root
  , Implicit_HBool (Is_Last_Expr (Expr_Map lam root) root)
index cbe74ba7fd63914d8d6857928c1474081504e024..db94c46d369bacad72f29da9bad4c8a2299db554 100644 (file)
@@ -67,7 +67,7 @@ ex_from = root_expr_from (Proxy::Proxy (Ex lam)) (Proxy::Proxy lam)
                 Left (_, err) -> Right ("…"::String) @?= Left err
                 Right (ty_expected::Type_Root_of_Expr (Ex IO) h, _::h, _::Text) ->
                        (>>= (@?= (\(_::Proxy h, err) -> err) `left` expected)) $
-                       case ty `type_eq` ty_expected of
+                       case ty `eq_type` ty_expected of
                         Nothing -> return $ Left $
                                error_expr (Proxy::Proxy (Ex IO)) $
                                Error_Expr_Type_mismatch ast
index 57707d64a75151dae9cbb0308a0edbd795751e73..104c4de9beb798597240f4608ff3ff9d8d5ae767 100644 (file)
@@ -81,7 +81,7 @@ op1_from
  :: forall root ty lit ex ast hs ret.
  ( ty ~ Type_Root_of_Expr ex
  , root ~ Root_of_Expr ex
- , Type_Eq (Type_Root_of_Expr root)
+ , Eq_Type (Type_Root_of_Expr root)
  , Expr_from ast root
  , Error_Expr_Lift (Error_Expr (Error_of_Type ast ty) ty ast)
                    (Error_of_Expr ast root)
@@ -92,7 +92,7 @@ op1_from
 op1_from op ty_lit ast_x ex ast ctx k =
        expr_from (Proxy::Proxy root) ast_x ctx $
         \ty_x (Forall_Repr_with_Context x) ->
-       check_type_eq ex ast ty_lit ty_x $ \Refl ->
+       check_eq_type ex ast ty_lit ty_x $ \Refl ->
                k ty_x $ Forall_Repr_with_Context (op . x)
 
 -- | Parse a binary operator.
@@ -100,7 +100,7 @@ op2_from
  :: forall root ty lit ex ast hs ret.
  ( ty ~ Type_Root_of_Expr ex
  , root ~ Root_of_Expr ex
- , Type_Eq (Type_Root_of_Expr root)
+ , Eq_Type (Type_Root_of_Expr root)
  , Expr_from ast root
  , Error_Expr_Lift (Error_Expr (Error_of_Type ast ty) ty ast)
                    (Error_of_Expr ast root)
@@ -111,8 +111,8 @@ op2_from
 op2_from op ty_lit ast_x ast_y ex ast ctx k =
        expr_from (Proxy::Proxy root) ast_x ctx $ \ty_x (Forall_Repr_with_Context x) ->
        expr_from (Proxy::Proxy root) ast_y ctx $ \ty_y (Forall_Repr_with_Context y) ->
-       check_type_eq ex ast ty_lit ty_x $ \Refl ->
-       check_type_eq ex ast ty_lit ty_y $ \Refl ->
+       check_eq_type ex ast ty_lit ty_x $ \Refl ->
+       check_eq_type ex ast ty_lit ty_y $ \Refl ->
                k ty_x $ Forall_Repr_with_Context $
                 \c -> x c `op` y c
 
@@ -515,19 +515,19 @@ error_expr_unsupported ex ast =
 
 -- | Parsing utility to check that two types are equal,
 -- or raise 'Error_Expr_Type_mismatch'.
-check_type_eq
+check_eq_type
  :: forall ast ex root ty x y ret.
  ( root ~ Root_of_Expr ex
  , ty ~ Type_Root_of_Expr ex
- , Type_Eq ty
+ , Eq_Type ty
  , Error_Expr_Lift (Error_Expr (Error_of_Type ast ty) ty ast)
                    (Error_of_Expr ast root)
  )
  => Proxy ex -> ast -> ty x -> ty y
  -> (x :~: y -> Either (Error_of_Expr ast root) ret)
  -> Either (Error_of_Expr ast root) ret
-check_type_eq ex ast x y k =
-       case x `type_eq` y of
+check_eq_type ex ast x y k =
+       case x `eq_type` y of
         Just Refl -> k Refl
         Nothing -> Left $ error_expr ex $
                Error_Expr_Type_mismatch ast
@@ -536,19 +536,19 @@ check_type_eq ex ast x y k =
 
 -- | Parsing utility to check that a type is has instance of a given 'Constraint',
 -- or raise 'Error_Expr_Constraint_missing'.
-check_type_constraint
+check_constraint_type
  :: forall ast ex c root ty h ret.
  ( root ~ Root_of_Expr ex
  , ty ~ Type_Root_of_Expr ex
  , Error_Expr_Lift (Error_Expr (Error_of_Type ast ty) ty ast)
                    (Error_of_Expr ast root)
- , Type_Constraint c ty
+ , Constraint_Type c ty
  )
  => Proxy ex -> Proxy c -> ast -> ty h
  -> (Dict (c h) -> Either (Error_of_Expr ast root) ret)
  -> Either (Error_of_Expr ast root) ret
-check_type_constraint ex c ast ty k =
-       case type_constraint c ty of
+check_constraint_type ex c ast ty k =
+       case constraint_type c ty of
         Just Dict -> k Dict
         Nothing -> Left $ error_expr ex $
                Error_Expr_Constraint_missing ast
index 60e7936682b8cc96cd63b66a7d785c7b765a9e4f..9292d71bda378c6c22663d1624142efabe91acbb 100644 (file)
@@ -41,12 +41,12 @@ eq_from
  :: forall root ty ast hs ret.
  ( ty ~ Type_Root_of_Expr (Expr_Eq root)
  , Type_Root_Lift Type_Bool (Type_Root_of_Expr root)
- , Type_Eq (Type_Root_of_Expr root)
+ , Eq_Type (Type_Root_of_Expr root)
  , Expr_from ast root
  , Error_Expr_Lift (Error_Expr (Error_of_Type ast ty) ty ast)
                    (Error_of_Expr ast root)
  , Root_of_Expr root ~ root
- , Type_Constraint Eq ty
+ , Constraint_Type Eq ty
  ) => ast -> ast
  -> Expr_From ast (Expr_Eq root) hs ret
 eq_from ast_x ast_y ex ast ctx k =
@@ -54,7 +54,7 @@ eq_from ast_x ast_y ex ast ctx k =
         \(ty_x::Type_Root_of_Expr root h_x) (Forall_Repr_with_Context x) ->
        expr_from (Proxy::Proxy root) ast_y ctx $
         \(ty_y::Type_Root_of_Expr root h_y) (Forall_Repr_with_Context y) ->
-       check_type_eq ex ast ty_x ty_y $ \Refl ->
-       check_type_constraint ex (Proxy::Proxy Eq) ast ty_x $ \Dict ->
+       check_eq_type ex ast ty_x ty_y $ \Refl ->
+       check_constraint_type ex (Proxy::Proxy Eq) ast ty_x $ \Dict ->
                k type_bool $ Forall_Repr_with_Context $
                 \c -> x c == y c
index d2f9a78169e0ce852ac4e00fe50d67f8e5b35cb7..1de4116ec8a03b21136d330941df83bec40956ea 100644 (file)
@@ -42,7 +42,7 @@ ex_from = root_expr_from (Proxy::Proxy (Ex lam)) (Proxy::Proxy lam)
                 Left (_, err) -> Right ("…"::String) @?= Left err
                 Right (ty_expected::Type_Root_of_Expr (Ex IO) h, _::h, _::Text) ->
                        (>>= (@?= (\(_::Proxy h, err) -> err) `left` expected)) $
-                       case ty `type_eq` ty_expected of
+                       case ty `eq_type` ty_expected of
                         Nothing -> return $ Left $
                                error_expr (Proxy::Proxy (Ex IO)) $
                                Error_Expr_Type_mismatch ast
index 72edeb309f9605dd045238934d4157d4af4895bd..cb397e1ff1cee0eeb5f774a134214c4143252e4f 100644 (file)
@@ -51,7 +51,7 @@ type instance Error_of_Expr ast (Expr_If root)      = No_Error_Expr
 if_from
  :: forall root ty ast hs ret.
  ( ty ~ Type_Root_of_Expr (Expr_If root)
- , Type_Eq ty
+ , Eq_Type ty
  , Type_Root_Lift Type_Bool (Type_Root_of_Expr root)
  , Expr_from ast root
  , Error_Expr_Lift (Error_Expr (Error_of_Type ast ty) ty ast)
@@ -66,8 +66,8 @@ if_from ast_cond ast_ok ast_ko ex ast ctx k =
         \(ty_ok::Type_Root_of_Expr root h_ok) (Forall_Repr_with_Context ok) ->
        expr_from (Proxy::Proxy root) ast_ko ctx $
         \(ty_ko::Type_Root_of_Expr root h_ko) (Forall_Repr_with_Context ko) ->
-       check_type_eq ex ast type_bool ty_cond $ \Refl ->
-       check_type_eq ex ast ty_ok ty_ko $ \Refl ->
+       check_eq_type ex ast type_bool ty_cond $ \Refl ->
+       check_eq_type ex ast ty_ok ty_ko $ \Refl ->
                k ty_ok $ Forall_Repr_with_Context $
                 \c -> if_ (cond c) (ok c) (ko c)
 
@@ -82,7 +82,7 @@ type instance Error_of_Expr ast (Expr_When root)      = No_Error_Expr
 when_from
  :: forall root ty ast hs ret.
  ( ty ~ Type_Root_of_Expr (Expr_When root)
- , Type_Eq ty
+ , Eq_Type ty
  , Type_Root_Lift Type_Bool (Type_Root_of_Expr root)
  , Type_Root_Lift Type_Unit (Type_Root_of_Expr root)
  , Expr_from ast root
@@ -96,7 +96,7 @@ when_from ast_cond ast_ok ex ast ctx k =
         \(ty_cond::Type_Root_of_Expr root h_n) (Forall_Repr_with_Context cond) ->
        expr_from (Proxy::Proxy root) ast_ok ctx $
         \(ty_ok::Type_Root_of_Expr root h_ok) (Forall_Repr_with_Context ok) ->
-       check_type_eq ex ast type_bool ty_cond $ \Refl ->
-       check_type_eq ex ast type_unit ty_ok $ \Refl ->
+       check_eq_type ex ast type_bool ty_cond $ \Refl ->
+       check_eq_type ex ast type_unit ty_ok $ \Refl ->
                k ty_ok $ Forall_Repr_with_Context $
                 \c -> when (cond c) (ok c)
index 562210703c605a717a417fc2167adc16d1c49509..584164c00510142541a364a66ca502ec2395aa23 100644 (file)
@@ -39,7 +39,7 @@ ex_from = root_expr_from (Proxy::Proxy (Ex lam)) (Proxy::Proxy lam)
                 Left (_, err) -> Right ("…"::String) @?= Left err
                 Right (ty_expected::Type_Root_of_Expr (Ex IO) h, _::h, _::Text) ->
                        (>>= (@?= (\(_::Proxy h, err) -> err) `left` expected)) $
-                       case ty `type_eq` ty_expected of
+                       case ty `eq_type` ty_expected of
                         Nothing -> return $ Left $
                                error_expr (Proxy::Proxy (Ex IO)) $
                                Error_Expr_Type_mismatch ast
index b1df17fb159baf21744702f88ddd14386e8c4c04..c683565a140928993ace8de74888564441562006 100644 (file)
@@ -60,7 +60,7 @@ ex_from = root_expr_from (Proxy::Proxy (Ex lam)) (Proxy::Proxy lam)
                 Left (_, err) -> Right ("…"::String) @?= Left err
                 Right (ty_expected::Type_Root_of_Expr (Ex IO) h, _::h, _::Text) ->
                        (>>= (@?= (\(_::Proxy h, err) -> err) `left` expected)) $
-                       case ty `type_eq` ty_expected of
+                       case ty `eq_type` ty_expected of
                         Nothing -> return $ Left $
                                error_expr (Proxy::Proxy (Ex IO)) $
                                Error_Expr_Type_mismatch ast
index 86fd725aa2ceba59e862ed57437265ab0b765ac3..438886cff8888b90d90e7a45341595ac57e0b1b0 100644 (file)
@@ -185,7 +185,7 @@ app_from ast_lam ast_arg_actual ex ast ctx k =
                         (Exists_Type ty_lam)
                 Just (ty_arg_expected `Type_Fun` ty_res
                  :: Type_Fun lam (Type_Root_of_Expr root) h_lam) ->
-                       check_type_eq ex ast
+                       check_eq_type ex ast
                         ty_arg_expected ty_arg_actual $ \Refl ->
                                k ty_res $ Forall_Repr_with_Context $
                                 \c -> lam c `app` arg_actual c
index 656bc36aea1226f75db2f23046c1ea142be09567..263afb9d293f87bf0519cf4bbe4e4c0bd2fa5646 100644 (file)
@@ -16,7 +16,6 @@ import Language.Symantic.Repr.Dup
 import Language.Symantic.Trans.Common
 import Language.Symantic.Expr.Common
 import Language.Symantic.Expr.Lambda
-import Language.Symantic.Expr.Bool
 
 -- * Class 'Sym_List_Lam'
 -- | Symantic.
@@ -119,7 +118,7 @@ list_empty_from ast_ty_a ex ast _ctx k =
 list_cons_from
  :: forall root lam ty ast hs ret.
  ( ty ~ Type_Root_of_Expr (Expr_List lam root)
- , Type_Eq (Type_Root_of_Expr root)
+ , Eq_Type (Type_Root_of_Expr root)
  , Expr_from ast root
  , Type_Lift   Type_List (Type_of_Expr root)
  , Type_Unlift Type_List (Type_of_Expr root)
@@ -134,16 +133,52 @@ list_cons_from ast_a ast_l ex ast ctx k =
        expr_from (Proxy::Proxy root) ast_l ctx $
         \(ty_l::Type_Root_of_Expr root h_l) (Forall_Repr_with_Context l) ->
        check_type_list ex ast ty_l $ \(Type_List ty_l_a) ->
-       check_type_eq ex ast ty_a ty_l_a $ \Refl ->
+       check_eq_type ex ast ty_a ty_l_a $ \Refl ->
        k (type_list ty_a) $ Forall_Repr_with_Context $
                \c -> list_cons (a c) (l c)
 
+-- | Parse 'list'.
+list_from
+ :: forall root lam ex ty ty_root ast hs ret.
+ ( ty ~ Type_Root_of_Expr (Expr_List lam root)
+ , ty_root ~ Type_Root_of_Expr root
+ , ex ~ Expr_List lam root
+ , Eq_Type (Type_Root_of_Expr root)
+ , Type_from ast ty_root
+ , Expr_from ast root
+ , Type_Lift   Type_List (Type_of_Expr root)
+ , Type_Unlift Type_List (Type_of_Expr root)
+ , Error_Expr_Lift (Error_Expr (Error_of_Type ast ty) ty ast)
+                   (Error_of_Expr ast root)
+ , Root_of_Expr root ~ root
+ , Root_of_Type ty_root ~ ty_root
+ ) => ast -> [ast]
+ -> Expr_From ast ex hs ret
+list_from ast_ty_a ast_as =
+       case type_from (Proxy::Proxy ty_root)
+        ast_ty_a (Right . Exists_Type) of
+        Left err -> \ex ast _ctx _k -> Left $ error_expr ex $ Error_Expr_Type err ast
+        Right (Exists_Type ty_a) -> go ty_a [] ast_as
+       where
+       go :: Type_Root_of_Expr root ty_a
+          -> [Forall_Repr_with_Context root hs ty_a]
+          -> [ast]
+          -> Expr_From ast (Expr_List lam root) hs ret
+       go ty_a as [] _ex _ast _ctx k =
+               k (type_list ty_a) $ Forall_Repr_with_Context $
+                       \c -> list ((\(Forall_Repr_with_Context a) -> a c) <$> as)
+       go ty_a as (ast_x:ast_xs) ex ast ctx k =
+               expr_from (Proxy::Proxy root) ast_x ctx $
+                \(ty_x::Type_Root_of_Expr root h_x) x ->
+               check_eq_type ex ast ty_a ty_x $ \Refl ->
+               go ty_a (x:as) ast_xs ex ast ctx k
+
 -- | Parse 'list_filter'.
 list_filter_from
  :: forall root lam ty ty_root ast hs ret.
  ( ty ~ Type_Root_of_Expr (Expr_List lam root)
  , ty_root ~ Type_of_Expr root
- , Type_Eq (Type_Root_of_Expr root)
+ , Eq_Type (Type_Root_of_Expr root)
  , Expr_from ast root
  , Type_Lift   Type_Bool      ty_root
  , Type_Lift   (Type_Fun lam) ty_root
@@ -162,29 +197,8 @@ list_filter_from ast_f ast_l ex ast ctx k =
         \(ty_l::Type_Root_of_Expr root h_l) (Forall_Repr_with_Context l) ->
        check_type_fun ex ast ty_f $ \(ty_f_a `Type_Fun` ty_f_b
         :: Type_Fun lam (Type_Root_of_Expr root) h_f) ->
-       check_type_eq ex ast type_bool ty_f_b $ \Refl ->
+       check_eq_type ex ast type_bool ty_f_b $ \Refl ->
        check_type_list ex ast ty_l $ \(Type_List ty_l_a) ->
-       check_type_eq ex ast ty_f_a ty_l_a $ \Refl ->
+       check_eq_type ex ast ty_f_a ty_l_a $ \Refl ->
        k ty_l $ Forall_Repr_with_Context $
         \c -> list_filter (f c) (l c)
-
--- ** Type 'Expr_Lambda_List_Bool'
--- | Convenient alias.
-type Expr_Lambda_List_Bool lam
- =   Expr_Root (Expr_Lambda lam .|. Expr_List lam .|. Expr_Bool)
-
--- | Convenient alias around 'expr_from'.
-expr_lambda_list_bool_from
- :: forall lam ast root.
- ( Expr_from ast (Expr_Lambda_List_Bool lam)
- , root ~ Expr_Lambda_List_Bool lam
- ) => Proxy lam
- -> ast
- -> Either (Error_of_Expr ast root)
-           (Exists_Type_and_Repr (Type_Root_of_Expr root)
-                                 (Forall_Repr root))
-expr_lambda_list_bool_from _lam ast =
-       expr_from (Proxy::Proxy root) ast
-        Context_Empty $ \ty (Forall_Repr_with_Context repr) ->
-               Right $ Exists_Type_and_Repr ty $
-                       Forall_Repr $ repr Context_Empty
index d7b1e31a23b85a956a422a53669623042bcbeece..54b9ce503198a919e9c53f54acd37c46a0646a58 100644 (file)
@@ -7,12 +7,14 @@
 module Expr.List.Test where
 
 import Test.Tasty
+{-
 import Test.Tasty.HUnit
 
 import Control.Arrow (left)
 import Data.Proxy (Proxy(..))
 import Data.Text (Text)
 import Data.Type.Equality ((:~:)(Refl))
+-}
 import Prelude hiding (mod, (==))
 
 import Language.Symantic.Repr
@@ -31,16 +33,16 @@ e1 = list_filter (inline $ \x -> if_ (x `mod` int 2 == int 0) t f)
 -- * Tests
 (==>) ast expected =
        testCase (show ast) $
-       case expr_lambda_maybe_bool_from (Proxy::Proxy IO) ast of
+       case ex_from (Proxy::Proxy IO) ast of
         Left err -> Left err @?= snd `left` expected
         Right (Exists_Type_and_Repr ty (Forall_Repr r)) ->
                case expected of
                 Left (_, err) -> Right ("…"::String) @?= Left err
-                Right (ty_expected::Type_Root_of_Expr (Expr_Lambda_List_Bool IO) h, _::h, _::Text) ->
+                Right (ty_expected::Type_Root_of_Expr (Ex IO) h, _::h, _::Text) ->
                        (>>= (@?= (\(_::Proxy h, err) -> err) `left` expected)) $
-                       case ty `type_eq` ty_expected of
+                       case ty `eq_type` ty_expected of
                         Nothing -> return $ Left $
-                               error_expr (Proxy::Proxy (Expr_Lambda_List_Bool IO)) $
+                               error_expr (Proxy::Proxy (Ex IO)) $
                                Error_Expr_Type_mismatch ast
                                 (Exists_Type ty)
                                 (Exists_Type ty_expected)
index d2d1e335df3580f5f2cb23021ff4a6463d5ec63d..031d7ef2fafa10f0abf8fd65ab0e2ddb162644c7 100644 (file)
@@ -89,7 +89,7 @@ map_from_list_from
  , Type_Lift   Type_Map       ty_root
  , Type_Lift   Type_Tuple2    ty_root
  , Type_Unlift Type_Tuple2    ty_root
- , Type_Constraint Ord ty
+ , Constraint_Type Ord ty
  , Error_Expr_Lift (Error_Expr (Error_of_Type ast ty) ty ast)
                    (Error_of_Expr ast root)
  , Root_of_Expr root ~ root
@@ -100,7 +100,7 @@ map_from_list_from ast_l ex ast ctx k =
         \(ty_l::Type_Root_of_Expr root h_l) (Forall_Repr_with_Context l) ->
        check_type_list ex ast ty_l $ \(Type_List ty_l_t) ->
        check_type_tuple2 ex ast ty_l_t $ \(Type_Tuple2 ty_k ty_a) ->
-       check_type_constraint ex (Proxy::Proxy Ord) ast ty_k $ \Dict ->
+       check_constraint_type ex (Proxy::Proxy Ord) ast ty_k $ \Dict ->
        k (type_map ty_k ty_a) $ Forall_Repr_with_Context $
         \c -> map_from_list (l c)
 
@@ -109,13 +109,13 @@ map_map_from
  :: forall root lam ty ty_root ast hs ret.
  ( ty ~ Type_Root_of_Expr (Expr_Map lam root)
  , ty_root ~ Type_of_Expr root
- , Type_Eq ty
+ , Eq_Type ty
  , Expr_from ast root
  , Type_Lift   (Type_Fun lam) ty_root
  , Type_Unlift (Type_Fun lam) ty_root
  , Type_Lift   Type_Map       ty_root
  , Type_Unlift Type_Map       ty_root
- , Type_Constraint Ord ty
+ , Constraint_Type Ord ty
  , Error_Expr_Lift (Error_Expr (Error_of_Type ast ty) ty ast)
                    (Error_of_Expr ast root)
  , Root_of_Expr root ~ root
@@ -129,8 +129,8 @@ map_map_from ast_f ast_m ex ast ctx k =
        check_type_fun ex ast ty_f $ \(ty_f_a `Type_Fun` ty_f_b
         :: Type_Fun lam (Type_Root_of_Expr root) h_f) ->
        check_type_map ex ast ty_m $ \(Type_Map ty_m_k ty_m_a) ->
-       check_type_eq ex ast ty_f_a ty_m_a $ \Refl ->
-       check_type_constraint ex (Proxy::Proxy Ord) ast ty_m_k $ \Dict ->
+       check_eq_type ex ast ty_f_a ty_m_a $ \Refl ->
+       check_constraint_type ex (Proxy::Proxy Ord) ast ty_m_k $ \Dict ->
        k (type_map ty_m_k ty_f_b) $ Forall_Repr_with_Context $
         \c -> map_map (f c) (m c)
 
index 2764b726670fa0786a2d4d14ec37f4bc17cf8c80..da81fa11bad9a7f30c41cc4736a751e8864509d2 100644 (file)
@@ -94,7 +94,7 @@ maybe_from
  :: forall root lam ty ty_root ast hs ret.
  ( ty ~ Type_Root_of_Expr (Expr_Maybe lam root)
  , ty_root ~ Type_of_Expr root
- , Type_Eq ty
+ , Eq_Type ty
  , Expr_from ast root
  , Type_Lift   (Type_Fun lam) ty_root
  , Type_Unlift (Type_Fun lam) ty_root
@@ -115,8 +115,8 @@ maybe_from ast_n ast_j ast_m ex ast ctx k =
        check_type_fun ex ast ty_j $ \(ty_j_a `Type_Fun` ty_j_b
         :: Type_Fun lam (Type_Root_of_Expr root) h_j) ->
        check_type_maybe ex ast ty_m $ \(Type_Maybe ty_m_a) ->
-       check_type_eq ex ast ty_n   ty_j_b $ \Refl ->
-       check_type_eq ex ast ty_m_a ty_j_a $ \Refl ->
+       check_eq_type ex ast ty_n   ty_j_b $ \Refl ->
+       check_eq_type ex ast ty_m_a ty_j_a $ \Refl ->
                k ty_n $ Forall_Repr_with_Context $
                 \c -> maybe (n c) (j c) (m c)
 
index 4fe7a8ccafc395f9effdd4a971be0e051686da4e..3a4b0ede6b0cee00ecd1f3b3abe10414a0a58256 100644 (file)
@@ -38,7 +38,7 @@ ex_from = root_expr_from (Proxy::Proxy (Ex lam)) (Proxy::Proxy lam)
                 Left (_, err) -> Right ("…"::String) @?= Left err
                 Right (ty_expected::Type_Root_of_Expr (Ex IO) h, _::h, _::Text) ->
                        (>>= (@?= (\(_::Proxy h, err) -> err) `left` expected)) $
-                       case ty `type_eq` ty_expected of
+                       case ty `eq_type` ty_expected of
                         Nothing -> return $ Left $
                                error_expr (Proxy::Proxy (Ex IO)) $
                                Error_Expr_Type_mismatch ast
index e774fe8d649be8f8dbffcee9030d0bcd705a7fd3..f11c9f959f465c9515548c1550734b3b32f40652 100644 (file)
@@ -41,12 +41,12 @@ compare_from
  :: forall root ty ast hs ret.
  ( ty ~ Type_Root_of_Expr (Expr_Ord root)
  , Type_Root_Lift Type_Ordering (Type_Root_of_Expr root)
- , Type_Eq (Type_Root_of_Expr root)
+ , Eq_Type (Type_Root_of_Expr root)
  , Expr_from ast root
  , Error_Expr_Lift (Error_Expr (Error_of_Type ast ty) ty ast)
                    (Error_of_Expr ast root)
  , Root_of_Expr root ~ root
- , Type_Constraint Ord ty
+ , Constraint_Type Ord ty
  ) => ast -> ast
  -> Expr_From ast (Expr_Ord root) hs ret
 compare_from ast_x ast_y ex ast ctx k =
@@ -54,7 +54,7 @@ compare_from ast_x ast_y ex ast ctx k =
         \(ty_x::Type_Root_of_Expr root h_x) (Forall_Repr_with_Context x) ->
        expr_from (Proxy::Proxy root) ast_y ctx $
         \(ty_y::Type_Root_of_Expr root h_y) (Forall_Repr_with_Context y) ->
-       check_type_eq ex ast ty_x ty_y $ \Refl ->
-       check_type_constraint ex (Proxy::Proxy Ord) ast ty_x $ \Dict ->
+       check_eq_type ex ast ty_x ty_y $ \Refl ->
+       check_constraint_type ex (Proxy::Proxy Ord) ast ty_x $ \Dict ->
                k type_ordering $ Forall_Repr_with_Context $
                 \c -> x c `compare` y c
index 2f0992650e4e5fc059ce573766e44692073429eb..401eafc74455cfacc39e0d2ba3de3f18b7bbec65 100644 (file)
@@ -68,7 +68,7 @@ check_type_tuple2 ex ast ty k =
 tuple2_from
  :: forall root lam ty ast hs ret.
  ( ty ~ Type_Root_of_Expr (Expr_Tuple2 lam root)
- , Type_Eq (Type_Root_of_Expr root)
+ , Eq_Type (Type_Root_of_Expr root)
  , Expr_from ast root
  , Type_Lift   Type_Tuple2 (Type_of_Expr root)
  , Type_Unlift Type_Tuple2 (Type_of_Expr root)
index 19d96cf18ccf34483fca4dd359171892375aa893..91346beea906effc5b223545c35bd0a7e5b076ec 100644 (file)
@@ -11,6 +11,7 @@ import qualified Expr.Bool.Test as Bool.Test
 import qualified Expr.Maybe.Test as Maybe.Test
 import qualified Expr.Eq.Test as Eq.Test
 import qualified Expr.If.Test as If.Test
+import qualified Expr.List.Test as List.Test
 
 tests :: TestTree
 tests = testGroup "Text" $
@@ -50,4 +51,7 @@ tests = testGroup "Text" $
         [ If.Test.e1 ==> "if True then False else True"
         , If.Test.e2 ==> "if True && True then False else True"
         ]
+ , testGroup "List"
+        [ List.Test.e1 ==> "list_filter (\\!x0 -> if x0 % 2 == 0 then True else False):[1, 2, 3, 4, 5]"
+        ]
  ]
index 49aa832194bcaaa70d8419893716b28760f05446..6df03521884d9fdeb8d6ff6fb073fdab4e5db20e 100644 (file)
@@ -19,22 +19,22 @@ data Type_Bool (root:: * -> *) h where
 type instance Root_of_Type      (Type_Bool root) = root
 type instance Error_of_Type ast (Type_Bool root) = No_Error_Type
 
-instance -- Type_Eq
Type_Eq (Type_Bool root) where
-       type_eq Type_Bool Type_Bool = Just Refl
+instance -- Eq_Type
Eq_Type (Type_Bool root) where
+       eq_type Type_Bool Type_Bool = Just Refl
 instance -- Eq
  Eq (Type_Bool root h) where
-       x == y = isJust $ x `type_eq` y
+       x == y = isJust $ x `eq_type` y
 instance -- String_from_Type
  String_from_Type (Type_Bool root) where
        string_from_type Type_Bool = "Bool"
 instance -- Show
  Show (Type_Bool root h) where
        show = string_from_type
-instance Type_Constraint Eq (Type_Bool root) where
-       type_constraint _c Type_Bool = Just Dict
-instance Type_Constraint Ord (Type_Bool root) where
-       type_constraint _c Type_Bool = Just Dict
+instance Constraint_Type Eq (Type_Bool root) where
+       constraint_type _c Type_Bool = Just Dict
+instance Constraint_Type Ord (Type_Bool root) where
+       constraint_type _c Type_Bool = Just Dict
 
 -- | Convenient alias to include a 'Type_Bool' within a type.
 type_bool :: Type_Root_Lift Type_Bool root => root Bool
index df43a309b39f4e688ee32b870c79d3a9b01a9e1d..60c158f5c66fd0a08183fc3cd54f6d83de3ed977 100644 (file)
@@ -18,21 +18,21 @@ import Data.Type.Equality ((:~:))
 import Language.Symantic.Lib.Data.Peano
 import GHC.Prim (Constraint)
 
--- * Class 'Type_Eq'
+-- * Class 'Eq_Type'
 
 -- | Test two types for equality,
 -- returning an Haskell type-level proof
 -- of the equality when it holds.
-class Type_Eq (ty:: * -> *) where
-       type_eq :: forall h1 h2. ty h1 -> ty h2 -> Maybe (h1 :~: h2)
+class Eq_Type (ty:: * -> *) where
+       eq_type :: forall h1 h2. ty h1 -> ty h2 -> Maybe (h1 :~: h2)
 
--- * Class 'Type_Constraint'
+-- * Class 'Constraint_Type'
 -- | Test if a type satisfies a given 'Constraint',
 -- returning an Haskell type-level proof
 -- of that satisfaction when it holds.
-class Type_Constraint (c:: * -> Constraint) (ty:: * -> *) where
-       type_constraint :: forall h. Proxy c -> ty h -> Maybe (Dict (c h))
-       type_constraint _c _ = Nothing
+class Constraint_Type (c:: * -> Constraint) (ty:: * -> *) where
+       constraint_type :: forall h. Proxy c -> ty h -> Maybe (Dict (c h))
+       constraint_type _c _ = Nothing
 
 -- ** Type 'Dict'
 -- | 'Dict' captures the dictionary of a 'Constraint':
@@ -48,7 +48,7 @@ data Exists_Dict
 -- * Class 'Type_from'
 -- | Parse given @ast@ into a 'Root_of_Type',
 -- or return an 'Error_of_Type'.
-class Type_Eq ty =>
+class Eq_Type ty =>
       Type_from ast (ty:: * -> *) where
        type_from
         :: Proxy ty
@@ -80,20 +80,20 @@ type instance Root_of_Type (Type_Root ty) = Type_Root ty
 type instance Error_of_Type ast (Type_Root ty)
  = Error_Type_Alt (Error_Type ast)
                   (Error_of_Type ast (ty (Type_Root ty)))
-instance -- Type_Eq
Type_Eq (ty (Type_Root ty)) =>
Type_Eq (Type_Root ty) where
-       type_eq (Type_Root x) (Type_Root y) = x `type_eq` y
+instance -- Eq_Type
Eq_Type (ty (Type_Root ty)) =>
Eq_Type (Type_Root ty) where
+       eq_type (Type_Root x) (Type_Root y) = x `eq_type` y
 instance -- Eq
Type_Eq (Type_Root ty) =>
Eq_Type (Type_Root ty) =>
  Eq (Type_Root ty h) where
-       x == y = isJust $ x `type_eq` y
-instance -- Type_Constraint c Type_Root
Type_Constraint c (ty (Type_Root ty)) =>
Type_Constraint c (Type_Root ty) where
-       type_constraint c (Type_Root ty) = type_constraint c ty
+       x == y = isJust $ x `eq_type` y
+instance -- Constraint_Type c Type_Root
Constraint_Type c (ty (Type_Root ty)) =>
Constraint_Type c (Type_Root ty) where
+       constraint_type c (Type_Root ty) = constraint_type c ty
 instance -- Type_from
- ( Type_Eq (Type_Root ty)
+ ( Eq_Type (Type_Root ty)
  , Type_from ast (ty (Type_Root ty))
  , Root_of_Type (ty (Type_Root ty)) ~ Type_Root ty
  ) => Type_from ast (Type_Root ty) where
@@ -141,26 +141,26 @@ data No_Error_Type
  =   No_Error_Type
  deriving (Eq, Show)
 
-instance -- Type_Eq
- ( Type_Eq (curr root)
- , Type_Eq (next root)
- ) => Type_Eq (Type_Alt curr next root) where
-       type_eq (Type_Alt_Curr x) (Type_Alt_Curr y) = x `type_eq` y
-       type_eq (Type_Alt_Next x) (Type_Alt_Next y) = x `type_eq` y
-       type_eq _ _ = Nothing
+instance -- Eq_Type
+ ( Eq_Type (curr root)
+ , Eq_Type (next root)
+ ) => Eq_Type (Type_Alt curr next root) where
+       eq_type (Type_Alt_Curr x) (Type_Alt_Curr y) = x `eq_type` y
+       eq_type (Type_Alt_Next x) (Type_Alt_Next y) = x `eq_type` y
+       eq_type _ _ = Nothing
 instance -- Eq
- ( Type_Eq (curr root)
- , Type_Eq (next root)
+ ( Eq_Type (curr root)
+ , Eq_Type (next root)
  ) => Eq (Type_Alt curr next root h) where
-       x == y = isJust $ x `type_eq` y
-instance -- Type_Constraint c Type_Alt
- ( Type_Constraint c (curr root)
- , Type_Constraint c (next root)
- ) => Type_Constraint c (Type_Alt curr next root) where
-       type_constraint c (Type_Alt_Curr ty) = type_constraint c ty
-       type_constraint c (Type_Alt_Next ty) = type_constraint c ty
+       x == y = isJust $ x `eq_type` y
+instance -- Constraint_Type c Type_Alt
+ ( Constraint_Type c (curr root)
+ , Constraint_Type c (next root)
+ ) => Constraint_Type c (Type_Alt curr next root) where
+       constraint_type c (Type_Alt_Curr ty) = constraint_type c ty
+       constraint_type c (Type_Alt_Next ty) = constraint_type c ty
 instance -- Type_from
- ( Type_Eq (curr root)
+ ( Eq_Type (curr root)
  , Type_from ast (curr root)
  , Type_from ast (next root)
  , Root_of_Type (curr root) ~ root
@@ -378,10 +378,10 @@ class String_from_Type ty where
 data Exists_Type ty
  = forall h. Exists_Type (ty h)
 instance -- Eq
Type_Eq ty =>
Eq_Type ty =>
  Eq (Exists_Type ty) where
        Exists_Type xh == Exists_Type yh =
-               isJust $ xh `type_eq` yh
+               isJust $ xh `eq_type` yh
 instance -- Show
  String_from_Type ty =>
  Show (Exists_Type ty) where
index 05d17ffea6b0c90fcbbdd8d4101bd0d09aa65b60..29ad2c729eb734a7bdccd1f0ae32b2a7887c8fa5 100644 (file)
@@ -23,20 +23,20 @@ data Type_Fun lam root h where
 type instance Root_of_Type      (Type_Fun lam root) = root
 type instance Error_of_Type ast (Type_Fun lam root) = ()
 
-instance -- Type_Eq
Type_Eq root =>
Type_Eq (Type_Fun lam root) where
-       type_eq
+instance -- Eq_Type
Eq_Type root =>
Eq_Type (Type_Fun lam root) where
+       eq_type
         (arg1 `Type_Fun` res1)
         (arg2 `Type_Fun` res2)
-        | Just Refl <- arg1 `type_eq` arg2
-        , Just Refl <- res1 `type_eq` res2
+        | Just Refl <- arg1 `eq_type` arg2
+        , Just Refl <- res1 `eq_type` res2
         = Just Refl
-       type_eq _ _ = Nothing
+       eq_type _ _ = Nothing
 instance -- Eq
Type_Eq root =>
Eq_Type root =>
  Eq (Type_Fun lam root h) where
-       x == y = isJust $ x `type_eq` y
+       x == y = isJust $ x `eq_type` y
 instance -- String_from_Type
  String_from_Type root =>
  String_from_Type (Type_Fun lam root) where
@@ -47,8 +47,8 @@ instance -- Show
  String_from_Type root =>
  Show (Type_Fun lam root h) where
        show = string_from_type
-instance Type_Constraint Eq  (Type_Fun lam root)
-instance Type_Constraint Ord (Type_Fun lam root)
+instance Constraint_Type Eq  (Type_Fun lam root)
+instance Constraint_Type Ord (Type_Fun lam root)
 
 type_fun_from
  :: forall (lam :: * -> *) (root :: * -> *) ast ret.
index 9ac7b736c92e041d15103ad33014fd3c50fc3284..52ce47343bd9b79197c07edf9c99e402aa1d4889 100644 (file)
@@ -19,22 +19,22 @@ data Type_Int (root:: * -> *) h where
 type instance Root_of_Type      (Type_Int root) = root
 type instance Error_of_Type ast (Type_Int root) = No_Error_Type
 
-instance -- Type_Eq
Type_Eq (Type_Int root) where
-       type_eq Type_Int Type_Int = Just Refl
+instance -- Eq_Type
Eq_Type (Type_Int root) where
+       eq_type Type_Int Type_Int = Just Refl
 instance -- Eq
  Eq (Type_Int root h) where
-       x == y = isJust $ x `type_eq` y
+       x == y = isJust $ x `eq_type` y
 instance -- String_from_Type
  String_from_Type (Type_Int root) where
        string_from_type Type_Int = "Int"
 instance -- Show
  Show (Type_Int root h) where
        show = string_from_type
-instance Type_Constraint Eq (Type_Int root) where
-       type_constraint _c Type_Int = Just Dict
-instance Type_Constraint Ord (Type_Int root) where
-       type_constraint _c Type_Int = Just Dict
+instance Constraint_Type Eq (Type_Int root) where
+       constraint_type _c Type_Int = Just Dict
+instance Constraint_Type Ord (Type_Int root) where
+       constraint_type _c Type_Int = Just Dict
 
 -- | Convenient alias to include a 'Type_Int' within a type.
 type_int :: Type_Root_Lift Type_Int root => root Int
index f2d6e4c095280b37a504f797018ed98c0c6c567f..39469651e8d86f56b5ffefb7d47476a5d0401e26 100644 (file)
@@ -23,17 +23,17 @@ data Type_List root h where
 type instance Root_of_Type      (Type_List root) = root
 type instance Error_of_Type ast (Type_List root) = No_Error_Type
 
-instance -- Type_Eq
Type_Eq root =>
Type_Eq (Type_List root) where
-       type_eq (Type_List a1) (Type_List a2)
-        | Just Refl <- a1 `type_eq` a2
+instance -- Eq_Type
Eq_Type root =>
Eq_Type (Type_List root) where
+       eq_type (Type_List a1) (Type_List a2)
+        | Just Refl <- a1 `eq_type` a2
         = Just Refl
-       type_eq _ _ = Nothing
+       eq_type _ _ = Nothing
 instance -- Eq
Type_Eq root =>
Eq_Type root =>
  Eq (Type_List root h) where
-       x == y = isJust $ type_eq x y
+       x == y = isJust $ eq_type x y
 instance -- String_from_Type
  String_from_Type root =>
  String_from_Type (Type_List root) where
index a8882c3a20d32b2d1f7db45f0d3a2e99056d3785..76ddc77f2a36fe344c1971ca0e999b4784c39c11 100644 (file)
@@ -23,18 +23,18 @@ data Type_Map root h where
 type instance Root_of_Type      (Type_Map root) = root
 type instance Error_of_Type ast (Type_Map root) = No_Error_Type
 
-instance -- Type_Eq
Type_Eq root =>
Type_Eq (Type_Map root) where
-       type_eq (Type_Map k1 a1) (Type_Map k2 a2)
-        | Just Refl <- k1 `type_eq` k2
-        , Just Refl <- a1 `type_eq` a2
+instance -- Eq_Type
Eq_Type root =>
Eq_Type (Type_Map root) where
+       eq_type (Type_Map k1 a1) (Type_Map k2 a2)
+        | Just Refl <- k1 `eq_type` k2
+        , Just Refl <- a1 `eq_type` a2
         = Just Refl
-       type_eq _ _ = Nothing
+       eq_type _ _ = Nothing
 instance -- Eq
Type_Eq root =>
Eq_Type root =>
  Eq (Type_Map root h) where
-       x == y = isJust $ type_eq x y
+       x == y = isJust $ eq_type x y
 instance -- String_from_Type
  String_from_Type root =>
  String_from_Type (Type_Map root) where
index 70a6b82f4aab5ca82abb17bdacf3857faa9d9176..8c56ff82cc45b537a98cb89def73a0c88d774f62 100644 (file)
@@ -21,17 +21,17 @@ data Type_Maybe root h where
 type instance Root_of_Type      (Type_Maybe root) = root
 type instance Error_of_Type ast (Type_Maybe root) = No_Error_Type
 
-instance -- Type_Eq
Type_Eq root =>
Type_Eq (Type_Maybe root) where
-       type_eq (Type_Maybe a1) (Type_Maybe a2)
-        | Just Refl <- a1 `type_eq` a2
+instance -- Eq_Type
Eq_Type root =>
Eq_Type (Type_Maybe root) where
+       eq_type (Type_Maybe a1) (Type_Maybe a2)
+        | Just Refl <- a1 `eq_type` a2
         = Just Refl
-       type_eq _ _ = Nothing
+       eq_type _ _ = Nothing
 instance -- Eq
Type_Eq root =>
Eq_Type root =>
  Eq (Type_Maybe root h) where
-       x == y = isJust $ type_eq x y
+       x == y = isJust $ eq_type x y
 instance -- String_from_Type
  String_from_Type root =>
  String_from_Type (Type_Maybe root) where
index 33110ef9803e835a0ddc1d5b3676360fd93c346b..51a71001ea85343f69d8b08b7985e8eda8a0583f 100644 (file)
@@ -18,12 +18,12 @@ data Type_Ordering (root:: * -> *) h where
 type instance Root_of_Type      (Type_Ordering root) = root
 type instance Error_of_Type ast (Type_Ordering root) = No_Error_Type
 
-instance -- Type_Eq
Type_Eq (Type_Ordering root) where
-       type_eq Type_Ordering Type_Ordering = Just Refl
+instance -- Eq_Type
Eq_Type (Type_Ordering root) where
+       eq_type Type_Ordering Type_Ordering = Just Refl
 instance -- Eq
  Eq (Type_Ordering root h) where
-       x == y = isJust $ x `type_eq` y
+       x == y = isJust $ x `eq_type` y
 instance -- String_from_Type
  String_from_Type (Type_Ordering root) where
        string_from_type Type_Ordering = "Ordering"
index 5efb942a6d902bc069f5ddc20a69af70c28d34a1..c47f6d3cc44e44505e7d3eecb98153d402a5d5b3 100644 (file)
@@ -24,18 +24,18 @@ data Type_Tuple2 root h where
 type instance Root_of_Type      (Type_Tuple2 root) = root
 type instance Error_of_Type ast (Type_Tuple2 root) = No_Error_Type
 
-instance -- Type_Eq
Type_Eq root =>
Type_Eq (Type_Tuple2 root) where
-       type_eq (Type_Tuple2 a1 b1) (Type_Tuple2 a2 b2)
-        | Just Refl <- a1 `type_eq` a2
-        , Just Refl <- b1 `type_eq` b2
+instance -- Eq_Type
Eq_Type root =>
Eq_Type (Type_Tuple2 root) where
+       eq_type (Type_Tuple2 a1 b1) (Type_Tuple2 a2 b2)
+        | Just Refl <- a1 `eq_type` a2
+        , Just Refl <- b1 `eq_type` b2
         = Just Refl
-       type_eq _ _ = Nothing
+       eq_type _ _ = Nothing
 instance -- Eq
Type_Eq root =>
Eq_Type root =>
  Eq (Type_Tuple2 root h) where
-       x == y = isJust $ type_eq x y
+       x == y = isJust $ eq_type x y
 instance -- String_from_Type
  String_from_Type root =>
  String_from_Type (Type_Tuple2 root) where
index 8631b2a2efdc216e7c9c6961cf0c32fb9355fdc6..b278d3240fc92d624075ffb138f395434d88e3eb 100644 (file)
@@ -16,22 +16,22 @@ data Type_Unit (root:: * -> *) h where
 type instance Root_of_Type      (Type_Unit root) = root
 type instance Error_of_Type ast (Type_Unit root) = No_Error_Type
 
-instance -- Type_Eq
Type_Eq (Type_Unit root) where
-       type_eq Type_Unit Type_Unit = Just Refl
+instance -- Eq_Type
Eq_Type (Type_Unit root) where
+       eq_type Type_Unit Type_Unit = Just Refl
 instance -- Eq
  Eq (Type_Unit root h) where
-       x == y = isJust $ x `type_eq` y
+       x == y = isJust $ x `eq_type` y
 instance -- String_from_Type
  String_from_Type (Type_Unit root) where
        string_from_type Type_Unit = "Unit"
 instance -- Show
  Show (Type_Unit root h) where
        show = string_from_type
-instance Type_Constraint Eq (Type_Unit root) where
-       type_constraint _c Type_Unit = Just Dict
-instance Type_Constraint Ord (Type_Unit root) where
-       type_constraint _c Type_Unit = Just Dict
+instance Constraint_Type Eq (Type_Unit root) where
+       constraint_type _c Type_Unit = Just Dict
+instance Constraint_Type Ord (Type_Unit root) where
+       constraint_type _c Type_Unit = Just Dict
 
 -- | Convenient alias to include a 'Type_Unit' within a type.
 type_unit :: Type_Root_Lift Type_Unit root => root ()
index 65c7da26c7685bb5e3c4f210e9c06f3ae42a5dc6..686dffc8cb365a1be871f1b79a3ec9c983a190b1 100644 (file)
@@ -20,12 +20,12 @@ data Type_Var (root:: * -> *) p where
 type instance Root_of_Type      (Type_Var root) = root
 type instance Error_of_Type ast (Type_Var root) = No_Error_Type
 
-instance -- Type_Eq
Type_Eq (Type_Var root) where
-       type_eq (Type_Var x) (Type_Var y) = x `peano_eq` y
+instance -- Eq_Type
Eq_Type (Type_Var root) where
+       eq_type (Type_Var x) (Type_Var y) = x `peano_eq` y
 instance -- Eq
  Eq (Type_Var root h) where
-       x == y = isJust $ x `type_eq` y
+       x == y = isJust $ x `eq_type` y
 instance -- String_from_Type
  String_from_Type (Type_Var root) where
        string_from_type (Type_Var p) =
@@ -33,8 +33,8 @@ instance -- String_from_Type
 instance -- Show
  Show (Type_Var root h) where
        show = string_from_type
-instance Type_Constraint Eq  (Type_Var root)
-instance Type_Constraint Ord (Type_Var root)
+instance Constraint_Type Eq  (Type_Var root)
+instance Constraint_Type Ord (Type_Var root)
 
 -- | Convenient alias to include a 'Type_Var' within a type.
 type_var :: Type_Root_Lift Type_Var root => SPeano p -> root p
index 87d7172ba80b9a73b483093d7cfa1144abc4a67b..aa18304dee4374a1db0d2288d9d840c0565617fa 100644 (file)
@@ -41,6 +41,9 @@ description:
  and then interpret them at will.
  .
  Your comments, problem reports, or questions are very welcome! :-)
+ .
+ NOTE: alternative libraries to do more or less the same things
+ include: <https://hackage.haskell.org/package/syntactic syntactic>.
 extra-source-files:
 extra-tmp-files:
 -- homepage: http://pad.autogeree.net/informatique/symantic/