Applicative functor

From HaskellWiki
Revision as of 07:42, 5 November 2007 by Lemming (talk | contribs) (Monad vs. applicative functor)
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

An applicative functor has more structure than a functor but less than a monad. See the Haddock docs for Control.Applicative.

It has turned out that many applications do not require monad functionality but only those of applicative functors. Monads allow you to run actions depending on the outcomes of earlier actions.

do text <- getLine
   if null text
     then putStrLn "You refuse to enter something?"
     else putStrLn ("You entered " ++ text)

This is obviously necessary is some cases, but in other cases it is disadvantageous.