This question already has an answer here:
- Default for Code Golf: Input/Output methods 76 answers
The vote on this output option has moved here.
Haskell has a very strong type system, so there is a type called
Maybe to work around some restrictions.
The Maybe type is defined as follows:
data Maybe a = Just a | Nothing deriving (Eq, Ord)
It allows the programmer to specify something may not be there.
From the Haskell wiki.
Essentially, instead of erroring out, a function can return a
Maybe that is either a
Just x where
x is the intended output or it can return
Nothing, which indicates that there is no possible output.
One example is the second solution in one of my answers. As you can see, in the output, the answer asked for is
This can be fixed by applying
foldl1 seq to the result, which I think is the golfiest way to do this.
Is outputting a
Maybe we can allow this...