Guest User

Untitled

a guest
Jul 20th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. {-# LANGUAGE TemplateHaskell #-}
  2. {-# LANGUAGE ConstraintKinds #-}
  3. {-# LANGUAGE FlexibleInstances #-}
  4.  
  5. module Experiment where
  6.  
  7. import Control.Lens
  8. import Control.Lens.TH (makeClassyPrisms)
  9. import Control.Monad.Error.Class
  10.  
  11.  
  12.  
  13. data BaseError = BaseFoo | BaseGoo deriving (Eq, Show)
  14. makeClassyPrisms ''BaseError
  15.  
  16. data TopError = Base BaseError | TopGoo deriving (Eq, Show)
  17. makeClassyPrisms ''TopError
  18.  
  19. instance AsBaseError TopError where
  20. _BaseError = _Base
  21.  
  22. type BaseContext e m = (MonadError e m, AsBaseError e)
  23.  
  24. type TopContext e m = (MonadError e m, AsTopError e)
  25.  
  26.  
  27. doBaseThing :: (BaseContext e m) => Int -> m e
  28. doBaseThing _ = undefined
  29.  
  30. doTopThing :: (TopContext e m) => Int -> m e
  31. doTopThing i = undefined
Add Comment
Please, Sign In to add comment