Questions tagged [fam-proposal]

The Functor-Applicative-Monad proposal is an overhaul of the Haskell type-class hierarchy, which was implemented in GHC 7.10, and according to which Monad became a subclass of Applicative (itself already a subclass of Functor).

For more details, consult the relevant Haskell wiki page.

6 questions
45
votes
4 answers

Why should Applicative be a superclass of Monad?

Given: Applicative m, Monad m => mf :: m (a -> b), ma :: m a it seems to be considered a law that: mf <*> ma === do { f <- mf; a <- ma; return (f a) } or more concisely: (<*>) === ap The documentation for Control.Applicative says that <*> is…
mergeconflict
  • 8,156
  • 34
  • 63
10
votes
1 answer

Is there an "ApplicativeIO" class?

Is there somewhere in Hackage a typeclass analogous to MonadIO but for Applicatives, that allows one to easily lift IO actions to "applicative composition stacks" based on IO? If such a typeclass existed, would it be made obsolete by the…
danidiaz
  • 26,936
  • 4
  • 45
  • 95
9
votes
1 answer

Haskell - can you have a monad that is not an applicative functor?

In this set of slides by Jim Duey at slide 13 - he suggests that all Monads are applicative functors. In the Haskell 7.7 compiler output - I'm seeing the following (another example is here): ‛Parser’ is an instance of Monad but not Applicative -…
hawkeye
  • 34,745
  • 30
  • 150
  • 304
7
votes
3 answers

Must I implement Applicative and Functor to implement a Monad

I'm trying to implement a Monad instance. As a simpler example, assume the following: data Maybee a = Notheeng | Juust a instance Monad Maybee where return x = Juust x Notheeng >>= f = Notheeng Juust x >>= f = f x fail _ = Notheeng…
trevore
  • 425
  • 2
  • 10
2
votes
0 answers

simple tree monad implementation error

Consider the next piece of code - module Main where data MyTree a = MyLeaf a | MyNode (MyTree a) (MyTree a) deriving (Show) instance Monad MyTree where return = MyLeaf (MyLeaf x) >>= f = f x (MyNode x y) >>= f…
0
votes
0 answers

Omit defining an Applicative instance for a Monad

I'm defining a data an instance Monad just for utilizing the do notation. However, by the Applicative-Monad Proposal implemented in GHC 7.10+, I will have to also define the data as an instance of Applicative and Functor. I don't plan to define…
shouya
  • 2,863
  • 1
  • 24
  • 45