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...
nilor something equivalent. \$\endgroup\$
Maybeas mentioned in the Haskell wiki is not the way it is defined. Try
data Mby a = Jst a | Nope deriving (Eq, Ord)and then
(+1) <$> Jst 41which will complain that
Mbyis not an instance of
Functorwhereas the real
Maybecertainly is and it implements a lot of other classes too (check