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