small fixed and added qualifiedDo

This commit is contained in:
sebastian 2023-03-27 21:16:48 +02:00
parent a38e96a83b
commit e1633ea147
2 changed files with 108 additions and 80 deletions

View file

@ -1,9 +1,15 @@
{-# LANGUAGE LambdaCase #-}
module Auxiliary (module Auxiliary) where
import Control.Monad.Error.Class (liftEither)
import Control.Monad.Except (MonadError)
import Data.Either.Combinators (maybeToRight)
import TypeChecker.TypeCheckerIr (Type (TFun))
import Control.Monad.Error.Class (liftEither)
import Control.Monad.Except (MonadError)
import Data.Either.Combinators (maybeToRight)
import TypeChecker.TypeCheckerIr (Type (TFun))
import Prelude hiding ((>>), (>>=))
(>>) a b = a ++ " " ++ b
(>>=) a f = f a
snoc :: a -> [a] -> [a]
snoc x xs = xs ++ [x]
@ -15,9 +21,8 @@ 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')
[] -> pure (acc, [])
x : xs -> do
(acc', x') <- f acc x
(acc'', xs') <- go acc' xs
pure (acc'', x' : xs')