aboutsummaryrefslogtreecommitdiff
path: root/src/Data/Array/Mixed/Internal/Arith/Lists.hs
diff options
context:
space:
mode:
authorTom Smeding <tom@tomsmeding.com>2025-03-12 23:20:13 +0100
committerTom Smeding <tom@tomsmeding.com>2025-03-13 09:27:51 +0100
commited6acbe5f409aba2fb222693da567ce04b7c4e01 (patch)
treebecbef3f3afeed63c248f057dae6fef0cb6c6147 /src/Data/Array/Mixed/Internal/Arith/Lists.hs
parentbcda5b7eb20874f948fbdc23b6daa3ebb792ffe0 (diff)
Implement quot/rem
Diffstat (limited to 'src/Data/Array/Mixed/Internal/Arith/Lists.hs')
-rw-r--r--src/Data/Array/Mixed/Internal/Arith/Lists.hs27
1 files changed, 22 insertions, 5 deletions
diff --git a/src/Data/Array/Mixed/Internal/Arith/Lists.hs b/src/Data/Array/Mixed/Internal/Arith/Lists.hs
index a284bc1..370b708 100644
--- a/src/Data/Array/Mixed/Internal/Arith/Lists.hs
+++ b/src/Data/Array/Mixed/Internal/Arith/Lists.hs
@@ -14,6 +14,12 @@ data ArithType = ArithType
, atCName :: String -- "i32"
}
+intTypesList :: [ArithType]
+intTypesList =
+ [ArithType ''Int32 "i32"
+ ,ArithType ''Int64 "i64"
+ ]
+
floatTypesList :: [ArithType]
floatTypesList =
[ArithType ''Float "float"
@@ -21,11 +27,7 @@ floatTypesList =
]
typesList :: [ArithType]
-typesList =
- [ArithType ''Int32 "i32"
- ,ArithType ''Int64 "i64"
- ]
- ++ floatTypesList
+typesList = intTypesList ++ floatTypesList
-- data ArithBOp = BO_ADD | BO_SUB | BO_MUL deriving (Show, Enum, Bounded)
$(genArithDataType Binop "ArithBOp")
@@ -42,6 +44,21 @@ $(do clauses <- readArithLists Binop
,return $ FunD (mkName "aboNumOp") clauses])
+-- data ArithIBOp = IB_QUOT deriving (Show, Enum, Bounded)
+$(genArithDataType IBinop "ArithIBOp")
+
+$(genArithNameFun IBinop ''ArithIBOp "aiboName" (map toLower . drop 3))
+$(genArithEnumFun IBinop ''ArithIBOp "aiboEnum")
+
+$(do clauses <- readArithLists IBinop
+ (\name _num hsop -> return (Clause [ConP (mkName name) [] []]
+ (NormalB (VarE 'mkName `AppE` LitE (StringL hsop)))
+ []))
+ return
+ sequence [SigD (mkName "aiboNumOp") <$> [t| ArithIBOp -> Name |]
+ ,return $ FunD (mkName "aiboNumOp") clauses])
+
+
-- data ArithFBOp = FB_DIV deriving (Show, Enum, Bounded)
$(genArithDataType FBinop "ArithFBOp")