From 1f424d332ec56c8598c89feb2b36f66d98bfc412 Mon Sep 17 00:00:00 2001 From: Mirek Kratochvil Date: Wed, 4 Jan 2023 17:14:09 +0100 Subject: ops op --- app/Operators.hs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'app/Operators.hs') 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)) -- cgit v1.2.3