Last active
November 3, 2020 15:06
-
-
Save dminuoso/79855d359ea2d21a8184e235870ecb44 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
flip :: (a -> b -> c) -> b -> a -> c | |
id :: a -> a | |
-------------------------------------------------------------------------------- | |
Given: | |
t = flip id | |
Step 1: Instantiate with unification variables: | |
(1) flip id :: _w | |
(2) flip :: (_s -> _t -> _u) -> _t -> _s -> _u | |
(3) id :: _v -> _v | |
Using (2) and (1) we get | |
(4) _w ~ (_t -> _s -> _u) | |
Substitute (4) into (1) | |
(5) flip id :: _t -> _s -> _u | |
From application we also get: | |
(6) (_v -> _v) ~ (_s -> _t -> u) | |
Which gives us: | |
(7) _v ~ _s | |
(8) _v ~ (_t -> _u) | |
Which gives us: | |
(9) _s ~ (_t -> _u) | |
Substitute (9) into (5) | |
10) flip id :: _t -> (_t -> _u) -> _u | |
We cant make any more progress, generalize over all left overs: | |
flip id :: a -> (a -> b) -> b |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment