Giter VIP home page Giter VIP logo

Comments (5)

ElvishJerricco avatar ElvishJerricco commented on August 16, 2024

It is possible, when working directly in DeclareT, to erase declared values.

ghci> execDeclare [] $ do
  declare [1]
  DeclareT $ const $ return ([], ())
[]

Now, I see that the laws are carefully constructed such that this isn't a violation of any sort. But it does make me question the usefulness of those laws. When given an arbitrary MonadDeclare d m => m a, you have no idea if it behaves as a state monad or a declare monad, as it might wipe any declarations you make before using it. I imagine this should be seen as a problem?

from mtl.

fizruk avatar fizruk commented on August 16, 2024

@ElvishJerricco I suspect you didn't actually run that in GHCi:

  • execDeclare receives arguments in different order;
  • DeclareT $ const $ return ([], ()) is essentially declare [];
  • the output is actually [1], as expected.

Here's what I get:

$ stack ghci
...
>>> flip execDeclare [] $ do { declare [1]; DeclareT $ const $ return ([], ()); }
[1]

I believe the laws are useful and although you made me doubt it, I still think they don't allow any MonadDeclare instance to erase output. However they probably might be better and/or clearer and I am open to suggestions!

from mtl.

ElvishJerricco avatar ElvishJerricco commented on August 16, 2024

Oh geez you're right. That's what I get for browsing github issues on my phone =P My bad!

from mtl.

fizruk avatar fizruk commented on August 16, 2024

Starting with transformers-0.5.4.0 there's Control.Monad.Trans.Accum which is DeclareT under a different (more general) name — AccumT.

from mtl.

chessai avatar chessai commented on August 16, 2024

Since AccumT is now in transformers, and #44 is an open issue, I am going to close this. Anyone feel free to re-open or ping to re-open if I'm missing something.

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.