[Haskell-cafe] Re: Lazy IO and closing of file handles

Pete Kazmier pete-expires-20070513 at kazmier.com
Mon Mar 19 16:35:11 EDT 2007


Bryan O'Sullivan <bos at serpentine.com> writes:

> Pete Kazmier wrote:
>
>> I understand the intent of this code, but I am having a hard time
>> understanding the implementation, specifically the combination of
>> 'fix', 'flip', and 'interate'.  I looked up 'fix' and I'm unsure how
>> one can call 'flip' on a function that takes one argument.

> As to why it's okay to call "flip" on "fix" at all, look at the types
> involved.
>
> fix :: (a -> a) -> a
> flip :: (a -> b -> c) -> b -> a -> c
>
> By substitution:
>
> flip fix :: a -> ((a -> b) -> a -> b) -> b

Sadly, I'm still confused.  I understand how 'flip' works in the case
where its argument is a function that takes two arguments.  I've
started to use this in my own code lately.  But my brain refuses to
understand how 'flip' is applied to 'fix', a function that takes one
argument only, which happens to be a function itself.  What is 'flip'
flipping when the function passed to it only takes one argument?

Thanks,
Pete



More information about the Haskell-Cafe mailing list