[Haskell] (.) . (.)

Robert Dockins robdockins at fastmail.fm
Sun May 28 17:09:15 EDT 2006


On Sunday 28 May 2006 05:02 pm, Brian Hulley wrote:
> Lennart Augustsson wrote:
> > Why not ask the computer?
> >
> > -- Lennart
> >
> > bamse% ghci
> >    ___         ___ _
> >   / _ \ /\  /\/ __(_)
> >  / /_\// /_/ / /  | |      GHC Interactive, version 6.4.1, for
> > Haskell 98. / /_\\/ __  / /___| |      http://www.haskell.org/ghc/
> > \____/\/ /_/\____/|_|      Type :? for help.
> >
> > Loading package base-1.0 ... linking ... done.
> > Prelude> :t (.) . (.)
> > (.) . (.) :: (b -> c) -> (a -> a1 -> b) -> a -> a1 -> c
> > Prelude> Leaving GHCi.
> > bamse% djinn
> > Welcome to Djinn version 2005-12-12.
> > Type :h to get help.
> > Djinn> f ? (b -> c) -> (a -> a1 -> b) -> a -> a1 -> c
> > f :: (b -> c) -> (a -> a1 -> b) -> a -> a1 -> c
> > f x1 x2 x3 x4 = x1 (x2 x3 x4)
> > Djinn> :q
> > Bye.
>
> Thanks! Although I note that Djinn will give a representative function
> corresponding to the type which is not necessarily (.) . (.), and the type
> given by GHCi doesn't tell me how it got there...
>
> > Brian Hulley wrote:
> >> Taral wrote:
> >>> On 5/28/06, Dominic Steinitz <dominic.steinitz at blueyonder.co.uk>
> >>>
> >>> wrote:
> >>>> Is this defined in some library? Thanks, Dominic.
> >>>
> >>> Don't think so. I use:
> >>>
> >>> \a b -> f (g a b)
> >>
> >> I don't see how (.) . (.) translates into something so simple.
> >> Using c for (.) to make things easier to write, I get:

[snip]

> I see my error was that I was reversing the args in eta expansion, so the
> correct derivation is:

FYI, eta-expansions isn't valid in Haskell.  Its safe in this derivation, but 
it isn't always.

> (.) . (.)
> === c c c
> === \x -> c c c x
> === \x -> c (c x)
> === \x -> (\y z -> c (c x) y z)
> === \x -> (\y z -> (c x) (y z))
> === \x -> (\y z -> (\p q -> c x p q)(y z))  -- where I went wrong before
> === \x -> (\y z -> (\p q -> x (p q))(y z))
> === \x -> (\y z -> (\q -> x ((y z) q))
>
> === \x y z q -> x (y z q)
>
> My apologies to Taral for doubting the original simplification...
>
> Regards, Brian.


-- 
Rob Dockins

Talk softly and drive a Sherman tank.
Laugh hard, it's a long way to the bank.
       -- TMBG


More information about the Haskell mailing list