[prev in list] [next in list] [prev in thread] [next in thread]
List: haskell-beginners
Subject: Re: [Haskell-beginners] \x -> x < 0.5 && x > -0.5
From: Daniel Fischer <daniel.is.fischer () web ! de>
Date: 2009-10-23 15:32:29
Message-ID: 200910231732.29850.daniel.is.fischer () web ! de
[Download RAW message or body]
Am Freitag 23 Oktober 2009 17:25:57 schrieb Darrin Thompson:
> On Fri, Oct 23, 2009 at 10:25 AM, pl <pl.listas@gmail.com> wrote:
> > filter ((<=0.5) . abs) xs
>
> pure (&&) <*> (< 0.5) <*> (> -0.5)
>
> liftM2 (&&) (< 0.5) (> -0.5)
>
> Someone suggested that this was an example of the reader monad but I
> don't get that.
It's because ((->) r) *is* the reader monad.
Control.Monad.Reader's Reader r a is just that wrapped in a newtype:
newtype Reader r a = Reader { runReader :: r -> a }
>
> > :i (->)
>
> data (->) a b -- Defined in GHC.Prim
> instance Monad ((->) r) -- Defined in Control.Monad.Instances
> instance Functor ((->) r) -- Defined in Control.Monad.Instances
> instance Applicative ((->) a) -- Defined in Control.Applicative
>
> That's what I see working here.
>
> --
> Darrin
_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://www.haskell.org/mailman/listinfo/beginners
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic