haskell / haskeline

A Haskell library for line input in command-line programs.
https://hackage.haskell.org/package/haskeline
BSD 3-Clause "New" or "Revised" License
221 stars 75 forks source link

Document why all functions return `Maybe String` rather than `String` #3

Closed jameshfisher closed 5 years ago

jameshfisher commented 10 years ago

Why do all the Haskeline functions return a Maybe String rather than a String? There's no documentation on it, and it seems to me that they should always return String, like standard getLine. I have no idea what the interpretation of Nothing is.

judah commented 10 years ago

The documentation is at the start of the section titled "User interaction functions": http://hackage.haskell.org/package/haskeline-0.7.1.1/docs/System-Console-Haskeline.html#g:4

Probably it could be changed to make the reference to Nothing more prominent. For example:

The following functions read one line or character of input from the user.

They return Nothing if they encounter the end of input:
- When using terminal-style interaction, if the user pressed Ctrl-D when the input text was empty.
- When using file-style interaction, if an EOF was encountered before any characters were read.

Do you think that would be more clear?

jameshfisher commented 10 years ago

Ahhh. Yes, that looks clear to me! J. On Dec 24, 2013 8:10 PM, "Judah Jacobson" notifications@github.com wrote:

The documentation is at the start of the section titled "User interaction functions":

http://hackage.haskell.org/package/haskeline-0.7.1.1/docs/System-Console-Haskeline.html#g:4

Probably it could be changed to make the reference to Nothing more prominent. For example:

The following functions read one line or character of input from the user.

They return Nothing if they encounter the end of input:

  • When using terminal-style interaction, if the user pressed Ctrl-D when the input text was empty.
  • When using file-style interaction, if an EOF was encountered before any characters were read.

Do you think that would be more clear?

— Reply to this email directly or view it on GitHubhttps://github.com/judah/haskeline/issues/3#issuecomment-31183822 .