summaryrefslogtreecommitdiff
path: root/app/Operators.hs
diff options
context:
space:
mode:
authorMirek Kratochvil <miroslav.kratochvil@uni.lu>2023-01-04 17:14:09 +0100
committerMirek Kratochvil <miroslav.kratochvil@uni.lu>2023-01-04 17:14:09 +0100
commit1f424d332ec56c8598c89feb2b36f66d98bfc412 (patch)
tree43900ebd091673664859a008ef2bf6f5fc2e1b4f /app/Operators.hs
parent3cc35a9414a8ba102a63af64bc5647ea75bc10b2 (diff)
downloadprlg-1f424d332ec56c8598c89feb2b36f66d98bfc412.tar.gz
prlg-1f424d332ec56c8598c89feb2b36f66d98bfc412.tar.bz2
ops op
Diffstat (limited to 'app/Operators.hs')
-rw-r--r--app/Operators.hs11
1 files changed, 11 insertions, 0 deletions
diff --git a/app/Operators.hs b/app/Operators.hs
index 8bf7c1e..2beb875 100644
--- a/app/Operators.hs
+++ b/app/Operators.hs
@@ -26,6 +26,17 @@ numArgs (Op _ f) = go f
type Ops = [(String, Op)]
+argKind :: Char -> Maybe ArgKind
+argKind 'x' = Just X
+argKind 'y' = Just Y
+argKind _ = Nothing
+
+fixity :: String -> Maybe Fixity
+fixity [l, 'f', r] = Infix <$> argKind l <*> argKind r
+fixity ['f', x] = Prefix <$> argKind x
+fixity [x, 'f'] = Suffix <$> argKind x
+fixity _ = Nothing
+
xfx, xfy, yfx, fx, fy, xf, yf :: String -> Int -> (String, Op)
xfx o p = (o, Op p (Infix X X))