Created
July 20, 2018 06:52
-
-
Save techtangents/e457479e8df1b50740919e651b256ce9 to your computer and use it in GitHub Desktop.
mtl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE TemplateHaskell #-} | |
{-# LANGUAGE ConstraintKinds #-} | |
{-# LANGUAGE FlexibleInstances #-} | |
module Experiment where | |
import Control.Lens | |
import Control.Lens.TH (makeClassyPrisms) | |
import Control.Monad.Error.Class | |
data BaseError = BaseFoo | BaseGoo deriving (Eq, Show) | |
makeClassyPrisms ''BaseError | |
data TopError = Base BaseError | TopGoo deriving (Eq, Show) | |
makeClassyPrisms ''TopError | |
instance AsBaseError TopError where | |
_BaseError = _Base | |
type BaseContext e m = (MonadError e m, AsBaseError e) | |
type TopContext e m = (MonadError e m, AsTopError e) | |
doBaseThing :: (BaseContext e m) => Int -> m e | |
doBaseThing _ = undefined | |
doTopThing :: (TopContext e m) => Int -> m e | |
doTopThing i = undefined | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment