Skip to content

Instantly share code, notes, and snippets.

@techtangents
Created July 20, 2018 06:52
Show Gist options
  • Save techtangents/e457479e8df1b50740919e651b256ce9 to your computer and use it in GitHub Desktop.
Save techtangents/e457479e8df1b50740919e651b256ce9 to your computer and use it in GitHub Desktop.
mtl
{-# 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