aboutsummaryrefslogtreecommitdiff
path: root/src/Data/Array/Nested/Internal/Arith/Lists.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Data/Array/Nested/Internal/Arith/Lists.hs')
-rw-r--r--src/Data/Array/Nested/Internal/Arith/Lists.hs47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/Data/Array/Nested/Internal/Arith/Lists.hs b/src/Data/Array/Nested/Internal/Arith/Lists.hs
new file mode 100644
index 0000000..1b29770
--- /dev/null
+++ b/src/Data/Array/Nested/Internal/Arith/Lists.hs
@@ -0,0 +1,47 @@
+{-# LANGUAGE TemplateHaskellQuotes #-}
+module Data.Array.Nested.Internal.Arith.Lists where
+
+import Data.Int
+
+import Language.Haskell.TH
+
+
+data Commutative = Comm | NonComm
+ deriving (Show, Eq)
+
+data ArithType = ArithType
+ { atType :: Name -- ''Int32
+ , atCName :: String -- "i32"
+ }
+
+typesList :: [ArithType]
+typesList =
+ [ArithType ''Int32 "i32"
+ ,ArithType ''Int64 "i64"
+ ,ArithType ''Float "float"
+ ,ArithType ''Double "double"
+ ]
+
+data ArithBOp = ArithBOp
+ { aboName :: String -- "add"
+ , aboComm :: Commutative -- Comm
+ , aboScalFun :: ArithType -> Name -- \_ -> '(+)
+ }
+
+binopsList :: [ArithBOp]
+binopsList =
+ [ArithBOp "add" Comm (\_ -> '(+))
+ ,ArithBOp "sub" NonComm (\_ -> '(-))
+ ,ArithBOp "mul" Comm (\_ -> '(*))
+ ]
+
+data ArithUOp = ArithUOp
+ { auoName :: String -- "neg"
+ }
+
+unopsList :: [ArithUOp]
+unopsList =
+ [ArithUOp "neg"
+ ,ArithUOp "abs"
+ ,ArithUOp "signum"
+ ]