[Haskell-beginners] \x -> x < 0.5 && x > -0.5

Darrin Thompson darrinth at gmail.com
Fri Oct 23 11:25:57 EDT 2009


On Fri, Oct 23, 2009 at 10:25 AM, pl <pl.listas at 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.

> :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


More information about the Beginners mailing list