Search code examples
haskellpointfree

How do I write (:)(.) on pointful form?


I have a hard time understanding what the function (:)(.) in haskell does. Could someone help me write it on pointful form, and explain step by step how to get there? The first step would be to expand the (:) so that we get ((.) :), but then I'm stuck.
It should be of type [(b->c)->(a->b)->a->c]->[(b->c)->(a->b)->a->c], but that doesn't help me, just makes me even more confused.


Solution

  • Well we can first convert the (:) data constructor, and the function (.) :: (b -> c) -> (a -> b) -> a -> c operator as a lambda expression:

    (:) -> (\x y -> (x:y))
    (.) -> (\f g t -> f (g t))
    

    So that means that (:)(.) is short for:

    (\x y -> (x:y)) (\f g t -> f (g t))
    

    So now we can replace x with the lambda expression:

     \y -> (\f g t -> f (g t)) : y
    

    So the function is equal to ((.) :): a partial "cons" where we still need to fill in the tail, and the head is the dot operator.

    So the type is a list of functions with the same signature as the dot operator [(b -> c) -> (a -> b) -> a -> c].

    If we thus for example take as argument [], we have constructed a singleton list (a list with exactly one element): the dot operator.