I think you make two errors:
maybe
has the following signature:
b -> (a -> b) -> Maybe a -> b
So you should use:
map (maybe True $ inRange (1,9)) list
the fromJust
cannot be used, since then maybe
would work on a
(instead of Maybe a
, and furthermore it is one of the tasks of maybe
simply to allow safe data processing (such that you don't have to worry about whether the value is Nothing
.
Some Haskell users furthermore consider fromJust
to be harmfull: there is no guarantee that a value is a Just
, so even if you manage to let it work with fromJust
, it will error on Nothing
, since fromJust
cannot handle these. Total programming is one of the things most Haskell programmers aim at.
Demo (with ghci
):
Prelude Data.Maybe Data.Ix> (map (maybe True $ inRange (1,9))) [Just 1, Just 15, Just 0, Nothing]
[True,False,False,True]
Prelude Data.Maybe Data.Ix> :t (map (maybe True $ inRange (1,9)))
(map (maybe True $ inRange (1,9))) :: (Num a, Ix a) => [Maybe a] -> [Bool]