]> Git — Sourcephile - haskell/symantic.git/blob - Language/Symantic/Expr/Int.hs
MonoFunctor
[haskell/symantic.git] / Language / Symantic / Expr / Int.hs
1 {-# LANGUAGE DefaultSignatures #-}
2 {-# LANGUAGE FlexibleContexts #-}
3 {-# LANGUAGE ScopedTypeVariables #-}
4 {-# LANGUAGE TypeFamilies #-}
5 {-# LANGUAGE TypeOperators #-}
6 -- | Expression for 'Int'.
7 module Language.Symantic.Expr.Int where
8
9 import qualified Data.Text as Text
10
11 import Language.Symantic.Type
12 import Language.Symantic.Repr
13 import Language.Symantic.Expr.Root
14 import Language.Symantic.Expr.Error
15 import Language.Symantic.Expr.From
16 import Language.Symantic.Trans.Common
17
18 -- * Class 'Sym_Int'
19 -- | Symantic.
20 class Sym_Int repr where
21 int :: Int -> repr Int
22 default int :: Trans t repr => Int -> t repr Int
23 int = trans_lift . int
24 instance Sym_Int Repr_Host where
25 int = Repr_Host
26 instance Sym_Int Repr_Text where
27 int a = Repr_Text $ \_p _v ->
28 Text.pack (show a)
29 instance
30 ( Sym_Int r1
31 , Sym_Int r2
32 ) => Sym_Int (Dup r1 r2) where
33 int x = int x `Dup` int x
34
35 -- * Type 'Expr_Int'
36 -- | Expression.
37 data Expr_Int (root:: *)
38 type instance Root_of_Expr (Expr_Int root) = root
39 type instance Type_of_Expr (Expr_Int root) = Type_Int
40 type instance Sym_of_Expr (Expr_Int root) repr = Sym_Int repr
41 type instance Error_of_Expr ast (Expr_Int root) = No_Error_Expr