Git Product home page Git Product logo

Comments (8)

fizruk avatar fizruk commented on August 28, 2024

It is currently possible to define

retractT :: (Functor (t m), Monad (t m), MonadTrans t, Monad m) =>
    FreeT (t m) m a -> t m a
retractT = iterTM join

Would you like this implementation?

from free.

ekmett avatar ekmett commented on August 28, 2024

That looks right.

from free.

fizruk avatar fizruk commented on August 28, 2024

Hm. There appears to be also a different version:

retractM :: (Functor m, Monad m) => FreeT m m a -> m a
retractM = iterT join

With that

retractT = retractM . hoistFreeT lift

Alternatively

retractM = runIdentityT . retractT . transFreeT IdentityT

Though I think iterT* join would be a better implementation for retract*.

Would you like both retractM and retractT?

from free.

ekmett avatar ekmett commented on August 28, 2024

I'd check to see which matches the semantics of concats from Pipes.Group, but I think that is (obviously) the former.

retractM is kinda boring though. I think just doing retractT might offer a path to reduce the amount of pipes-specific code that @Gabriel439 has to write. ;)

from free.

Gabriella439 avatar Gabriella439 commented on August 28, 2024

Oh wow, I didn't even realize there was an iterTM. I'm probably going to keep the pipes-group code the way it is just because it helps people understand how to write their own folds.

from free.

torgeirsh avatar torgeirsh commented on August 28, 2024

Having both a more general function and the example of fold code would be great. Perhaps the current concats code could be moved to a comment or the tutorial, and then let concats = retractT just like maps = transFreeT?

from free.

Gabriella439 avatar Gabriella439 commented on August 28, 2024

Alright, that sounds good. I can include the current implementation as a comment alongside the retractT version.

from free.

ekmett avatar ekmett commented on August 28, 2024

Added in patch b75fbf5

from free.

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.