Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add variation on makeFree without type signatures? #77

Closed
Gabriella439 opened this issue Oct 13, 2014 · 5 comments
Closed

Add variation on makeFree without type signatures? #77

Gabriella439 opened this issue Oct 13, 2014 · 5 comments

Comments

@Gabriella439
Copy link
Contributor

The reason I'm interested in a version of makeFree without type signatures is:

  • So that I can provide type signatures specialized to a particular monad
  • So that I can document auto-generated commands

As far as I can tell, the only way to document commands in haddocks is to put a comment above the type signature, but if I add my own type signature it conflicts with the auto-generated type signature.

@fizruk
Copy link
Collaborator

fizruk commented Oct 13, 2014

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?

@Gabriella439
Copy link
Contributor Author

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.

@fizruk
Copy link
Collaborator

fizruk commented Oct 14, 2014

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.

@Gabriella439
Copy link
Contributor Author

Yeah, I like that, too

@ekmett
Copy link
Owner

ekmett commented Mar 11, 2015

Merged

@ekmett ekmett closed this as completed Mar 11, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants