[Haskell-cafe] Haskell-Cafe Digest, Vol 145, Issue 41
David Banas
capn.freako at gmail.com
Wed Sep 30 22:54:23 UTC 2015
Thanks for your reply, Tom.
That last expression doesn’t seem to have the correct type:
Prelude Control.Applicative> let l1 = \x f -> pure f <*> x
Prelude Control.Applicative> :t l1
l1 :: Applicative f => f a -> (a -> b) -> f b
Prelude Control.Applicative> let l2 = \x f -> fmap f x
Prelude Control.Applicative> :t l2
l2 :: Functor f => f a -> (a -> b) -> f b
Prelude Control.Applicative> let l3 = \x f -> ($ x) <*> pure f
Prelude Control.Applicative> :t l3
l3 :: a1 -> a -> (a1 -> a -> b) -> b
Is there a typo?
Thanks,
-db
On Sep 29, 2015, at 9:08 AM, haskell-cafe-request at haskell.org wrote:
> Message: 2
> Date: Tue, 29 Sep 2015 16:40:38 +0100
> From: Tom Ellis <tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk>
> To: haskell-cafe at haskell.org
> Subject: Re: [Haskell-cafe] Question, re: Typeclassopedia Ex. 4.2.1
> Message-ID: <20150929154037.GS14111 at weber>
> Content-Type: text/plain; charset=us-ascii
>
> On Tue, Sep 29, 2015 at 07:48:05AM -0700, David Banas wrote:
>> pure (flip ($)) <*> x <*> pure f = (interchange)
>> pure (flip ($)) <*> pure ($ f) <*> x = (homomorphism)
>
> For one thing, this step doesn't look right. <*> does not associate that
> way.
>
> It's probably worth at least putting each expression into ghci to check they
> have the same time
>
> Prelude> import Control.Applicative
> Prelude Control.Applicative> let l = \x f -> pure (flip ($)) <*> x <*> pure f
> Prelude Control.Applicative> :t l
> l :: Applicative f => f a -> (a -> b) -> f b
> Prelude Control.Applicative> let l2 = \x f -> pure (flip ($)) <*> pure ($ f) <*> x
> Prelude Control.Applicative> :t l2
> l2 :: Applicative f => f (((a -> b1) -> b1) -> b) -> a -> f b
>
> I imagine you're probably going to want to go via ($ x) rather than ($ f),
> and possibly use that 'pure f <*> x = fmap f x = ($ x) <*> pure f'.
>
> Tom
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20150930/a9306a98/attachment.html>
More information about the Haskell-Cafe
mailing list