I'm a Haskell newbie, so please excuse me if you find this question trivial:
How would I get GHCi to accept a declaration of this sort: let foo = fmap (*3) . fmap (+10)?
I tried adding a type declaration to foo (let foo :: [Int] -> [Int] = etc) to make the functor type explicit but the compiler responds Illegal Signature.
Thanks!
EDIT - Apparently there are quite a few ways to do this. I picked Tikhon's answer because his was among the first, and also fairly intuitive. Thanks, everyone!
To give type signatures in ghci, the best way, not requiring any extensions, is to separate the signature and the binding with a semicolon,
let foo :: Num n => [n] -> [n]; foo = map (*3) . map (+ 10)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With