Skip to content

Commit

Permalink
make it build with newer mtl
Browse files Browse the repository at this point in the history
  • Loading branch information
albertov committed Jul 25, 2024
1 parent 3c376b2 commit 40633d0
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 14 deletions.
2 changes: 1 addition & 1 deletion inferno-core/src/Inferno/Core.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module Inferno.Core where

import Control.Monad (foldM)
import Control.Monad.Catch (MonadCatch, MonadThrow)
import Control.Monad.Except (MonadFix)
import Control.Monad.Fix (MonadFix)
import Data.Bifunctor (bimap, first)
import Data.List.NonEmpty (NonEmpty)
import qualified Data.Map as Map
Expand Down
2 changes: 1 addition & 1 deletion inferno-core/src/Inferno/Eval.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

module Inferno.Eval where

import Control.Monad (forM)
import Control.Monad.Catch (MonadCatch, MonadThrow (throwM), try)
import Control.Monad.Except (forM)
import Control.Monad.Reader (ask, local)
import Data.Foldable (foldrM)
import Data.Functor ((<&>))
Expand Down
10 changes: 6 additions & 4 deletions inferno-core/src/Inferno/Infer.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,16 @@ module Inferno.Infer
)
where

import Control.Monad (when)
import Control.Monad
( foldM,
forM,
forM_,
when
)
import Control.Monad.Except
( Except,
ExceptT,
MonadError (catchError, throwError),
foldM,
forM,
forM_,
runExcept,
runExceptT,
)
Expand Down
1 change: 1 addition & 0 deletions inferno-core/src/Inferno/Instances/Arbitrary.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}

Expand Down
3 changes: 2 additions & 1 deletion inferno-core/src/Inferno/Utils/QQ/Script.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ module Inferno.Utils.QQ.Script where
import Control.Monad.Catch (MonadCatch (..), MonadThrow (..))
import Control.Monad.IO.Class (MonadIO)
import Control.Monad.Reader (ReaderT (..))
import Control.Monad.Writer (WriterT (..), appEndo)
import Control.Monad.Writer (WriterT (..))
import Data.Monoid (appEndo)
import qualified Crypto.Hash as Crypto
import Data.ByteArray (convert)
import Data.ByteString (ByteString, unpack)
Expand Down
15 changes: 8 additions & 7 deletions inferno-types/src/Inferno/Types/Value.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ module Inferno.Types.Value where

import Control.DeepSeq (NFData, rnf)
import Control.Monad.Catch (MonadCatch (..), MonadThrow (..))
import Control.Monad.Except (MonadError, lift)
import Control.Monad.Except (MonadError)
import Control.Monad.Fix (MonadFix)
import Control.Monad.IO.Class (MonadIO)
import Control.Monad.Reader (MonadReader, ReaderT (..))
import Control.Monad.Trans (lift)
import Data.Int (Int64)
import qualified Data.Map as Map
import Data.Text (Text)
Expand Down Expand Up @@ -51,7 +52,7 @@ data Value custom m
| VTypeRep InfernoType
| VCustom custom

instance NFData custom => NFData (Value custom m) where
instance (NFData custom) => NFData (Value custom m) where
rnf (VInt x) = x `seq` ()
rnf (VDouble x) = x `seq` ()
rnf (VWord16 x) = x `seq` ()
Expand All @@ -69,7 +70,7 @@ instance NFData custom => NFData (Value custom m) where
rnf (VTypeRep x) = rnf x
rnf (VCustom x) = rnf x

instance Eq c => Eq (Value c m) where
instance (Eq c) => Eq (Value c m) where
(VInt i1) == (VInt i2) = i1 == i2
(VDouble v1) == (VDouble v2) = v1 == v2
(VWord16 w1) == (VWord16 w2) = w1 == w2
Expand All @@ -88,7 +89,7 @@ instance Eq c => Eq (Value c m) where
(VCustom c1) == (VCustom c2) = c1 == c2
_ == _ = False

instance Pretty c => Pretty (Value c m) where
instance (Pretty c) => Pretty (Value c m) where
pretty = \case
VInt n -> pretty n
VDouble n -> pretty n
Expand All @@ -113,14 +114,14 @@ instance Pretty c => Pretty (Value c m) where
newtype ImplEnvM m c a = ImplEnvM {unImplEnvM :: ReaderT (Map.Map ExtIdent (Value c (ImplEnvM m c))) m a}
deriving (Applicative, Functor, Monad, MonadReader (Map.Map ExtIdent (Value c (ImplEnvM m c))), MonadError e, MonadFix, MonadIO)

instance MonadThrow m => MonadThrow (ImplEnvM m c) where
instance (MonadThrow m) => MonadThrow (ImplEnvM m c) where
throwM = ImplEnvM . lift . throwM

instance MonadCatch m => MonadCatch (ImplEnvM m c) where
instance (MonadCatch m) => MonadCatch (ImplEnvM m c) where
catch (ImplEnvM (ReaderT m)) c = ImplEnvM $ ReaderT $ \env ->
m env `catch` \e -> runImplEnvM env (c e)

liftImplEnvM :: Monad m => m a -> ImplEnvM m c a
liftImplEnvM :: (Monad m) => m a -> ImplEnvM m c a
liftImplEnvM = ImplEnvM . lift

runImplEnvM :: Map.Map ExtIdent (Value c (ImplEnvM m c)) -> ImplEnvM m c a -> m a
Expand Down

0 comments on commit 40633d0

Please sign in to comment.