1 {-# LANGUAGE UndecidableInstances #-}
2 {-# OPTIONS_GHC -fno-warn-orphans #-}
3 {-# OPTIONS_GHC -fconstraint-solver-iterations=7 #-}
4 -- | Symantic for 'Int'.
5 module Language.Symantic.Lib.Int where
8 import Data.Type.Equality ((:~:)(Refl))
9 import qualified Data.Text as Text
11 import Language.Symantic.Parsing
12 import Language.Symantic.Typing
13 import Language.Symantic.Compiling
14 import Language.Symantic.Interpreting
15 import Language.Symantic.Transforming
16 import Language.Symantic.Lib.MonoFunctor (TyFam_MonoElement(..))
19 class Sym_Int term where
20 int :: Int -> term Int
21 default int :: Trans t term => Int -> t term Int
22 int = trans_lift . int
24 type instance Sym_of_Iface (Proxy Int) = Sym_Int
25 type instance TyConsts_of_Iface (Proxy Int) = Proxy Int ': TyConsts_imported_by (Proxy Int)
26 type instance TyConsts_imported_by (Proxy Int) =
37 instance Sym_Int HostI where
39 instance Sym_Int TextI where
40 int a = TextI $ \_p _v ->
42 instance (Sym_Int r1, Sym_Int r2) => Sym_Int (DupI r1 r2) where
43 int x = int x `DupI` int x
46 ( Read_TyNameR TyName cs rs
48 ) => Read_TyNameR TyName cs (Proxy Int ': rs) where
49 read_TyNameR _cs (TyName "Int") k = k (ty @Int)
50 read_TyNameR _rs raw k = read_TyNameR (Proxy @rs) raw k
51 instance Show_TyConst cs => Show_TyConst (Proxy Int ': cs) where
52 show_TyConst TyConstZ{} = "Int"
53 show_TyConst (TyConstS c) = show_TyConst c
55 instance Proj_TyFamC cs TyFam_MonoElement Int
57 instance -- Proj_TyConC
59 , Proj_TyConsts cs (TyConsts_imported_by (Proxy Int))
60 ) => Proj_TyConC cs (Proxy Int) where
61 proj_TyConC _ (TyConst q :$ TyConst c)
62 | Just Refl <- eq_skind (kind_of_TyConst c) SKiType
63 , Just Refl <- proj_TyConst c (Proxy @Int)
65 _ | Just Refl <- proj_TyConst q (Proxy @Bounded) -> Just TyCon
66 | Just Refl <- proj_TyConst q (Proxy @Enum) -> Just TyCon
67 | Just Refl <- proj_TyConst q (Proxy @Eq) -> Just TyCon
68 | Just Refl <- proj_TyConst q (Proxy @Integral) -> Just TyCon
69 | Just Refl <- proj_TyConst q (Proxy @Num) -> Just TyCon
70 | Just Refl <- proj_TyConst q (Proxy @Ord) -> Just TyCon
71 | Just Refl <- proj_TyConst q (Proxy @Real) -> Just TyCon
72 | Just Refl <- proj_TyConst q (Proxy @Show) -> Just TyCon
74 proj_TyConC _c _q = Nothing
75 data instance TokenT meta (ts::[*]) (Proxy Int)
77 deriving instance Eq_Token meta ts => Eq (TokenT meta ts (Proxy Int))
78 deriving instance Show_Token meta ts => Show (TokenT meta ts (Proxy Int))
82 CompileI cs is (Proxy Int) where
85 Token_Term_Int i -> k (ty @Int) $ TermO $ \_c -> int i
86 instance TokenizeT meta ts (Proxy Int)
87 instance Gram_Term_AtomsT meta ts (Proxy Int) g