import qualified Data.Traversable as Traversable
import Language.Symantic
-import Language.Symantic.Grammar
+import Language.Symantic.Grammar as G
import Language.Symantic.Lib.Function (a0, b1, c2)
import Language.Symantic.Lib.MonoFunctor (Element)
-- * Class 'Sym_List'
-type instance Sym (Proxy []) = Sym_List
+type instance Sym [] = Sym_List
class Sym_List term where
list_empty :: term [a]
list_cons :: term a -> term [a] -> term [a]; infixr 5 `list_cons`
instance (Sym_List term, Sym_Lambda term) => Sym_List (BetaT term)
-- Typing
-instance FixityOf [] where
+instance NameTyOf [] where
+ nameTyOf _c = [] `Mod` "[]"
+instance FixityOf []
instance ClassInstancesFor [] where
proveConstraintFor _ (TyApp _ (TyConst _ _ q) z)
| Just HRefl <- proj_ConstKiTy @_ @[] z
, Gram_Rule g
, Gram_Comment g
, Gram_Term src ss g
- , Inj_Sym ss []
+ , SymInj ss []
) => Gram_Term_AtomsFor src ss g [] where
- g_term_atomsFor _t =
+ g_term_atomsFor =
[ rule "teList_list" $
between (symbol "[") (symbol "]") listG
, rule "teList_empty" $
- g_source $
+ G.source $
(\src -> BinTree0 $ Token_Term $ TermAVT teList_empty `setSource` src)
<$ symbol "["
<* symbol "]"
where
listG :: CF g (AST_Term src ss)
listG = rule "list" $
- g_source $
+ G.source $
(\a mb src ->
case mb of
Just b -> BinTree2 (BinTree2 (BinTree0 $ Token_Term $ TermAVT $ (`setSource` src) $ teList_cons) a) b
(BinTree0 $ Token_Term $ TermAVT $ (`setSource` src) $ teList_empty))
<$> g_term
<*> option Nothing (Just <$ symbol "," <*> listG)
-instance (Source src, Inj_Sym ss []) => ModuleFor src ss [] where
- moduleFor _s = ["List"] `moduleWhere`
+instance (Source src, SymInj ss []) => ModuleFor src ss [] where
+ moduleFor = ["List"] `moduleWhere`
[ "[]" := teList_empty
, "zipWith" := teList_zipWith
, ":" `withInfixR` 5 := teList_cons
]
-- ** 'Type's
-tyList :: Source src => Inj_Len vs => Type src vs a -> Type src vs [a]
+tyList :: Source src => LenInj vs => Type src vs a -> Type src vs [a]
tyList = (tyConst @(K []) @[] `tyApp`)
-- ** 'Term's
-teList_empty :: Source src => Inj_Sym ss [] => Term src ss ts '[Proxy a] (() #> [a])
+teList_empty :: Source src => SymInj ss [] => Term src ss ts '[Proxy a] (() #> [a])
teList_empty = Term noConstraint (tyList a0) $ teSym @[] $ list_empty
-teList_cons :: Source src => Inj_Sym ss [] => Term src ss ts '[Proxy a] (() #> (a -> [a] -> [a]))
+teList_cons :: Source src => SymInj ss [] => Term src ss ts '[Proxy a] (() #> (a -> [a] -> [a]))
teList_cons = Term noConstraint (a0 ~> tyList a0 ~> tyList a0) $ teSym @[] $ lam2 list_cons
-teList_zipWith :: Source src => Inj_Sym ss [] => Term src ss ts '[Proxy a, Proxy b, Proxy c] (() #> ((a -> b -> c) -> [a] -> [b] -> [c]))
+teList_zipWith :: Source src => SymInj ss [] => Term src ss ts '[Proxy a, Proxy b, Proxy c] (() #> ((a -> b -> c) -> [a] -> [b] -> [c]))
teList_zipWith = Term noConstraint ((a0 ~> b1 ~> c2) ~> tyList a0 ~> tyList b1 ~> tyList c2) $ teSym @[] $ lam3 zipWith