Question

I was trying out some of the examples in the A Fistful of Monads chapter of Learn you a Haskell, and some returned errors when I ran them in GHCi 7.6.3:

Prelude> Just (+3) <*> Just 3

<interactive>:2:11: Not in scope: `<*>'

I get a similar error when using <$>.

Was it helpful?

Solution

These operators are from Control.Applicative. You need to import Control.Applicative or say :m +Control.Applicative in ghci. You can find out where many standard operators come from using Hoogle.

As of GHC 7.10, with the Functor-Applicative-Monad Proposal implemented in base 4.8, <*> is now present in the Prelude and does not require an import.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top