You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The standard prelude does not include readMaybe. Text.Read needs to be imported.
The type annotation was insufficient. I needed to add Read a to the Nothing case.
These two issues make it seem too complicated for inclusion in a beginner's text.
It should be revised or deleted ("feature creep" is the problem).
This code compiles:
densityTell::String->String
densityTell input
|Just density <- readMaybe input, density <1.2="Wow! You're going for a ride in the sky!"|Just density <- readMaybe input, density <=1000.0="Have fun swimming, but watch out for sharks!"|Nothing<- readMaybe input :: ((Reada, RealFloata) =>Maybea) ="You know I need a density, right?"|otherwise="If it's sink or swim, you're going to sink."
Suggested revision (to be completed by me someday). I actually think this is ugly (and bad style), and the topic should be removed, but this (relatively cleanly) fixes the issue I noted.
densityRead::String->MaybeDouble
densityRead input = readMaybe input
densityTell'::String->String
densityTell' input
|Just density <- result, density <1.2="Wow! You're going for a ride in the sky!"|Just density <- result, density <1000.0="Have fun swimming, but watch out for sharks!"|Nothing<- result ="You know I need a density, right?"|otherwise="If it's sink or swim, you're going to sink."where result = densityRead input
The text was updated successfully, but these errors were encountered:
This refers to PR #59.
readMaybe
.Text.Read
needs to be imported.Read a
to theNothing
case.It should be revised or deleted ("feature creep" is the problem).
This code compiles:
Suggested revision (to be completed by me someday). I actually think this is ugly (and bad style), and the topic should be removed, but this (relatively cleanly) fixes the issue I noted.
The text was updated successfully, but these errors were encountered: