1 {-# LANGUAGE DefaultSignatures #-}
2 {-# LANGUAGE FlexibleContexts #-}
3 {-# LANGUAGE ScopedTypeVariables #-}
4 {-# LANGUAGE TypeFamilies #-}
5 {-# LANGUAGE TypeOperators #-}
6 -- | Expression for 'Num'.
7 module Language.Symantic.Expr.Num where
9 import Prelude hiding ((+), (-), (*), abs, mod, negate)
11 import Language.Symantic.Type
12 import Language.Symantic.Expr.Root
13 import Language.Symantic.Expr.Error
14 import Language.Symantic.Expr.From
15 import Language.Symantic.Trans.Common
19 class Sym_Num repr where
20 abs :: Num n => repr n -> repr n
21 negate :: Num n => repr n -> repr n
22 (+) :: Num n => repr n -> repr n -> repr n
23 (-) :: Num n => repr n -> repr n -> repr n
24 (*) :: Num n => repr n -> repr n -> repr n
25 default abs :: (Trans t repr, Num n) => t repr n -> t repr n
26 default negate :: (Trans t repr, Num n) => t repr n -> t repr n
27 default (+) :: (Trans t repr, Num n) => t repr n -> t repr n -> t repr n
28 default (-) :: (Trans t repr, Num n) => t repr n -> t repr n -> t repr n
29 default (*) :: (Trans t repr, Num n) => t repr n -> t repr n -> t repr n
31 negate = trans_map1 negate
41 data Expr_Num (root:: *)
42 type instance Root_of_Expr (Expr_Num root) = root
43 type instance Type_of_Expr (Expr_Num root) = No_Type
44 type instance Sym_of_Expr (Expr_Num root) repr = Sym_Num repr
45 type instance Error_of_Expr ast (Expr_Num root) = No_Error_Expr