Giter VIP home page Giter VIP logo

Comments (5)

ekmett avatar ekmett commented on August 16, 2024

This would violate user expectation somewhat severely.

from mtl.

AshleyYakeley avatar AshleyYakeley commented on August 16, 2024

Just as a datapoint, it happened to be the instance I wanted, inasmuch as MonadReader is "simpler" than MonadState: indeed you can kinda/sorta make MonadReader a superclass of MonadState, though I'm not actually proposing this.

instance MonadReader s m where
    ask = get
    -- | imperfect, but you get the idea
    local ss ma = do
        s <- get
        put (ss s)
        a <- ma
        put s
        return a

from mtl.

ekmett avatar ekmett commented on August 16, 2024

Reader and State do have a sort of incestuous relationship.

Codensity (Reader s) ~ State s, because State is made up of the composition of Reader s and its adjoint functor: (, s). Using this you can always embed reader effects into State.

In an almost equally universal manner you can embed writer effects into state, but there are some minor complications on that front, and while the reader embedding costs you commutativity the latter costs you productivity.

from mtl.

treeowl avatar treeowl commented on August 16, 2024

Would it be worth the trouble to come up with a ContT wrapper offering this instance?

from mtl.

ekmett avatar ekmett commented on August 16, 2024

Possibly. If so it should belong in transformers though, not mtl, and then mtl would inherit support for it.

from mtl.

Related Issues (20)

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.