Giter Site home page Giter Site logo

Comments (5)

fizruk avatar fizruk commented on August 23, 2024

This makes perfect sense to me, I'd be happy to update TH module. Do you have a name for the command in mind? Or would it be better to pass options to makeFree?

from free.

Gabriella439 avatar Gabriella439 commented on August 23, 2024

It's probably best not to change makeFree for backwards compatibility.

The issue with template haskell functions that take options is that in order to use them you have to apply them to their arguments in a separate module because of the stage restriction, so I wouldn't go down that route unless absolutely necessary. I'd be happy with just makeFree_ or makeFreeNoTypes.

from free.

fizruk avatar fizruk commented on August 23, 2024

I think there might be one more nice command. We can introduce makeFreeCon for single constructors and prepend Haddock documentation to makeFreeCon invocation like this:

data LangF x
  = Input (String -> x)
  | Output String x
  | Halt
  deriving (Functor)

-- | Get string.
makeFreeCon 'Input

-- | Put string.
makeFreeCon 'Output

-- | Abort computation.
makeFreeCon 'Halt

This way one does not need to write down type signatures (which I find long and boring).

makeFree_ (and, perhaps, makeFreeCon_) would still make sense when one would like to comment individual arguments like this:

makeFreeCon_ 'Output

-- | Output.
output :: MonadFree LangF m =>
          String    -- ^ String to output.
          -> m ()   -- ^ No result.

from free.

Gabriella439 avatar Gabriella439 commented on August 23, 2024

Yeah, I like that, too

from free.

ekmett avatar ekmett commented on August 23, 2024

Merged

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.