Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What language extensions does the MTL library require?

I'm trying to understand monad transformers by implementing my own tiny library based on the designs of existing ones.

What I'm stuck on is the language extensions. In MonadError, the only extension mentioned is UndecidableInstances. However, I can't get similar code to compile without also using FunctionalDependencies and FlexibleInstances.

Example that I believe requires FunDeps:

class (Monad m) => MonadError e m | m -> e where

And a flexible instance:

instance MonadError e m => MonadError e (MaybeT m) where

How does the MonadError code avoid the extra two extensions?

like image 451
Matt Fenwick Avatar asked Mar 01 '13 10:03

Matt Fenwick


1 Answers

You don't have to spell out all the extensions in the source file itself. Common extensions that are used by all/most modules can be listed in the project's cabal file. In mtl's case:

extensions:
    MultiParamTypeClasses
    FunctionalDependencies
    FlexibleInstances
like image 101
shang Avatar answered Sep 24 '22 17:09

shang