We would like to know the type of the function composition $f \circ f$. The function in question is typed as follows:

$f :: (\alpha \rightarrow \beta \rightarrow \gamma) \rightarrow (\alpha \times \beta) \rightarrow \gamma$

Is there a systematic way to find out types of function compositions, given the types of the composed functions?

Edit: As I forgot to mention, $\alpha$, $\beta$, $\gamma$ are polymorphic types, hence this composition is actually possible. Haskell says the type definition is as follows: $f \circ f :: (\alpha \rightarrow \beta_1 \rightarrow \beta_2 \rightarrow \gamma) \rightarrow ((\alpha, \beta_1), \beta_2) \rightarrow \gamma$.

  • 1
    $\begingroup$ i can't see how f∘f could be well-typed, since the type of its output ( γ ) doesn't match either of its inputs ( (α→β→γ) and (α×β) ) - unless i'm misunderstanding what you're asking? $\endgroup$ – Alexis Sep 26 '18 at 10:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.