diff options
-rw-r--r-- | src/LambdaCube/Compiler/DesugaredSource.hs | 9 | ||||
-rw-r--r-- | src/LambdaCube/Compiler/Lexer.hs | 6 | ||||
-rw-r--r-- | src/LambdaCube/Compiler/Parser.hs | 2 |
3 files changed, 10 insertions, 7 deletions
diff --git a/src/LambdaCube/Compiler/DesugaredSource.hs b/src/LambdaCube/Compiler/DesugaredSource.hs index ec08a36f..f8e12ee7 100644 --- a/src/LambdaCube/Compiler/DesugaredSource.hs +++ b/src/LambdaCube/Compiler/DesugaredSource.hs | |||
@@ -125,8 +125,11 @@ getMatchName _ = Nothing | |||
125 | 125 | ||
126 | -------------------------------------------------------------------------------- fixities | 126 | -------------------------------------------------------------------------------- fixities |
127 | 127 | ||
128 | data FixityDef = Infix | InfixL | InfixR deriving (Eq, Show) | 128 | data FixityDir = Infix | InfixL | InfixR |
129 | type Fixity = (FixityDef, Int) | 129 | deriving (Eq, Show) |
130 | |||
131 | data Fixity = Fixity FixityDir Int | ||
132 | deriving (Eq, Show) | ||
130 | 133 | ||
131 | -------------------------------------------------------------------------------- source infos | 134 | -------------------------------------------------------------------------------- source infos |
132 | 135 | ||
@@ -235,7 +238,7 @@ sName (SIName _ s) = s | |||
235 | 238 | ||
236 | --appName f (SIName si n) = SIName si $ f n | 239 | --appName f (SIName si n) = SIName si $ f n |
237 | 240 | ||
238 | getFixity (SIName_ _ f _) = fromMaybe (InfixL, 9) f | 241 | getFixity (SIName_ _ f _) = fromMaybe (Fixity InfixL 9) f |
239 | 242 | ||
240 | ------------- | 243 | ------------- |
241 | 244 | ||
diff --git a/src/LambdaCube/Compiler/Lexer.hs b/src/LambdaCube/Compiler/Lexer.hs index cbf0084d..bd9f2964 100644 --- a/src/LambdaCube/Compiler/Lexer.hs +++ b/src/LambdaCube/Compiler/Lexer.hs | |||
@@ -276,7 +276,7 @@ parseFixity = do | |||
276 | <|> InfixL <$ reserved "infixl" | 276 | <|> InfixL <$ reserved "infixl" |
277 | <|> InfixR <$ reserved "infixr" | 277 | <|> InfixR <$ reserved "infixr" |
278 | LInt n <- parseLit | 278 | LInt n <- parseLit |
279 | return (dir, fromIntegral n) | 279 | return $ Fixity dir $ fromIntegral n |
280 | 280 | ||
281 | calcPrec | 281 | calcPrec |
282 | :: (MonadError (f, f){-operator mismatch-} m) | 282 | :: (MonadError (f, f){-operator mismatch-} m) |
@@ -293,8 +293,8 @@ calcPrec app getFixity = compileOps [] | |||
293 | | c == GT || c == EQ && dir == dir' && dir == InfixR = compileOps ((op, e): acc) e'' es' | 293 | | c == GT || c == EQ && dir == dir' && dir == InfixR = compileOps ((op, e): acc) e'' es' |
294 | | otherwise = throwError (op', op) -- operator mismatch | 294 | | otherwise = throwError (op', op) -- operator mismatch |
295 | where | 295 | where |
296 | (dir', i') = getFixity op' | 296 | Fixity dir' i' = getFixity op' |
297 | (dir, i) = getFixity op | 297 | Fixity dir i = getFixity op |
298 | c | null es = LT | 298 | c | null es = LT |
299 | | null acc = GT | 299 | | null acc = GT |
300 | | otherwise = compare i i' | 300 | | otherwise = compare i i' |
diff --git a/src/LambdaCube/Compiler/Parser.hs b/src/LambdaCube/Compiler/Parser.hs index 48447467..ee91c920 100644 --- a/src/LambdaCube/Compiler/Parser.hs +++ b/src/LambdaCube/Compiler/Parser.hs | |||
@@ -126,7 +126,7 @@ addForalls_ s = addForalls . (Set.fromList (sName <$> s) <>) <$> asks (definedSe | |||
126 | 126 | ||
127 | mkDesugarInfo :: [Stmt] -> DesugarInfo | 127 | mkDesugarInfo :: [Stmt] -> DesugarInfo |
128 | mkDesugarInfo ss = DesugarInfo | 128 | mkDesugarInfo ss = DesugarInfo |
129 | { fixityMap = Map.fromList $ ("'EqCTt", (Infix, -1)): [(sName s, f) | PrecDef s f <- ss] | 129 | { fixityMap = Map.fromList $ ("'EqCTt", Fixity Infix (-1)): [(sName s, f) | PrecDef s f <- ss] |
130 | , consMap = Map.fromList $ | 130 | , consMap = Map.fromList $ |
131 | [(sName cn, Left ((CaseName $ sName t, pars ty), second pars <$> cs)) | Data t ps ty cs <- ss, (cn, ct) <- cs] | 131 | [(sName cn, Left ((CaseName $ sName t, pars ty), second pars <$> cs)) | Data t ps ty cs <- ss, (cn, ct) <- cs] |
132 | ++ [(sName t, Right $ pars $ UncurryS ps ty) | Data t ps ty _ <- ss] | 132 | ++ [(sName t, Right $ pars $ UncurryS ps ty) | Data t ps ty _ <- ss] |