lambdageek / unbound-generics

Specify variable binding in syntax trees using GHC.Generics (reimplementation of Unbound)
https://hackage.haskell.org/package/unbound-generics/
BSD 3-Clause "New" or "Revised" License
55 stars 18 forks source link

Add instances for Monads defined in exceptions #20

Closed alex-mckenna closed 7 years ago

alex-mckenna commented 7 years ago

Instances of the exception-related monads in the exceptions package have been added for the FreshMT and LFreshMT types. This allows these monads to be used in transformer stacks which make use of extensible exceptions. For example, a compiler may want a typechecking monad

newtype CheckM a = C { unCheckM :: StateT TypeEnv FreshM a }

to derive MonadThrow, allowing exceptions to be thrown using a custom exception type with typechecking-specific exceptions.