GithubHelp home page GithubHelp logo

monad-classes's Introduction

Build Status

See this series of articles for the detailed description and motivation.

This is a more flexible version of mtl, the monad transformers library.

  • You can have many layers of e.g. state transformers in your stack, and you don't have to explicitly lift your gets and puts, as soon as different state transformers carry different types of states.

    Example:

    a :: (MonadState Bool m, MonadState Int m) => m ()
    a = do
      put False -- set the boolean state
      modify (+ (1 :: Int)) -- modify the integer state
  • mtl requires Θ(n2) instances (like MonadReader e (StateT s m)); monad-classes requires only Θ(n) of them (where n is the number of different transformer types).

    If you'd like to define your own monad-classes-style class, you have to write much less boilerplate code.

The status of this repo

This repo serves two purposes:

While this is technically open source software, I am not interested in maintaining this as an active open project. In practice this means that:

  • this version of monad-classes is not on hackage
  • I do not accept feature requests and pull requests. The exception is outright bugs; if you find any, please do report them.

There is a hackage package and a repo maintained by M Farkas-Dyck.

monad-classes's People

Contributors

edwardgeorge avatar ibotty avatar ocharles avatar unkindpartition avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

monad-classes's Issues

add io effects à la IOSpec but without it's headaches

what do you think about providing effects for typical operations within IO?

having played a bit with idris effects system, i'd totally like to have a fine-grained specification on what my IO-functions are doing.

as such, i wanted to have (at example) an OpenFile effect, that allows openFile and withFile but not (much) more. There would also be a ReadHandle and WriteHandle effect, that allows reading/seeking or writing to a handle respectively.

i would handle subtyping these effects using ConstraintsKinds (e.g. TeleType = (ConsoleWrite, ConsoleRead)).

implementing them, i would not write them by hand but use template haskell to generate them.

would you say that it's a good idea? and if so if it's in scope for monad-classes or should better be a separate package?

upload to hackage

i am really interested in using monad-classes. do you think there is still much missing before uploading to hackage? if so what do you think is missing?

except effect

i find the except effect pretty limited to use.

how did you intend it to be used? just using the functions from Control.Monad.Trans.Except kind of defeats the point of the effect imo.

looking forward, for e.g. withExcept do you think it should be along the lines of the following?

withExcept :: MonadExcept e' m => (e -> e') -> ExceptT e m a -> m a
withExcept f a = either (throw . f) return =<< runExcept a

i still have to think about whether and, if so, how to integrate Zoom with a possible catch.

catch :: MonadExcept e' m => ExceptT e m a -> (forall e' . MonadExcept e' m => e -> m a) -> m a

furthermore, what do you think about convenience functions as in the errors package, i.e. to lift Either a bs and m (Either a b)s?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.