[Haskell-beginners] list of integers to list of nats

Daniel Fischer daniel.is.fischer at web.de
Sun Feb 21 10:28:58 EST 2010


Am Sonntag 21 Februar 2010 15:57:09 schrieb kane96 at gmx.de:
> I tried: map toEnum [1,2,3,4]) :: [Nat]
> which works normally, but not for Maybe in: mapIntsToNats :: [Int] ->
> Maybe [Nat]
>

To use mapM, you need a function of type (f :: Int -> Maybe Nat). toEnum 
has type (Int -> Nat), so you can't use that directly.
Think: when should f k be Nothing and what should f k be in the other 
cases?


More information about the Beginners mailing list