Skip to content

Instantly share code, notes, and snippets.

@saurabhnanda
Created June 28, 2019 11:45
Show Gist options
  • Save saurabhnanda/04d18e93f0ded52c9055f8782b7f1e56 to your computer and use it in GitHub Desktop.
Save saurabhnanda/04d18e93f0ded52c9055f8782b7f1e56 to your computer and use it in GitHub Desktop.
/Users/saurabhnanda/projects/vl-gitlab/haskell/src/Try2.hs:25:13: error:
• Couldn't match type ‘auth’ with ‘auth1’
‘auth’ is a rigid type variable bound by
the instance declaration
at /Users/saurabhnanda/projects/vl-gitlab/haskell/src/Try2.hs:24:10-27
‘auth1’ is a rigid type variable bound by
the type signature for:
getEnv :: forall auth1. AppM auth (Env auth1)
at /Users/saurabhnanda/projects/vl-gitlab/haskell/src/Try2.hs:25:13-48
Expected type: AppM auth (Env auth1)
Actual type: AppM auth (Env auth)
• When checking that instance signature for ‘getEnv’
is more general than its signature in the class
Instance sig: forall auth. AppM auth (Env auth)
Class sig: forall auth1. AppM auth (Env auth1)
In the instance declaration for ‘HasEnv (AppM auth)’
|
25 | getEnv :: forall auth . (AppM auth) (Env auth)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE InstanceSigs #-}
{-# LANGUAGE RankNTypes #-}
module Try2 where
import Control.Monad.Reader
import System.Log.FastLogger
data Env auth = Env
{ envLogger :: FastLogger
, envAuth :: auth
}
class (Monad m, MonadIO m) => HasEnv m where
getEnv :: m (Env auth)
type AppM auth = ReaderT (Env auth) IO
instance HasEnv (AppM auth) where
getEnv :: forall auth . (AppM auth) (Env auth)
getEnv = ask
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment