Adjust old type checker to new syntax, and refactor lambda lifter to use typed AST
This commit is contained in:
parent
514c809b1e
commit
210e55bb15
18 changed files with 554 additions and 145 deletions
|
|
@ -1,4 +1,4 @@
|
|||
|
||||
{-# LANGUAGE LambdaCase #-}
|
||||
module Auxiliary (module Auxiliary) where
|
||||
import Control.Monad.Error.Class (liftEither)
|
||||
import Control.Monad.Except (MonadError)
|
||||
|
|
@ -9,3 +9,13 @@ snoc x xs = xs ++ [x]
|
|||
|
||||
maybeToRightM :: MonadError l m => l -> Maybe r -> m r
|
||||
maybeToRightM err = liftEither . maybeToRight err
|
||||
|
||||
mapAccumM :: Monad m => (s -> a -> m (s, b)) -> s -> [a] -> m (s, [b])
|
||||
mapAccumM f = go
|
||||
where
|
||||
go acc = \case
|
||||
[] -> pure (acc, [])
|
||||
x:xs -> do
|
||||
(acc', x') <- f acc x
|
||||
(acc'', xs') <- go acc' xs
|
||||
pure (acc'', x':xs')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue