Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix underlining of higher-order functions #273

Merged
merged 1 commit into from
Nov 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 7 additions & 14 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,6 @@
// K :: a -> b -> a
function K(x) { return function(y) { return x; }; }

// W :: (a -> a -> b) -> a -> b
function W(f) { return function(x) { return f (x) (x); }; }

// always0 :: a -> () -> a
function always0(x) { return function() { return x; }; }

Expand Down Expand Up @@ -2359,18 +2356,14 @@
// :: Integer -> (String -> String) -> Type -> PropPath -> String -> String
) {
var st = typeInfo.types.reduce (function(st, t, index) {
var formatType4 = formatType5 (index);
function f(g) {
return function(type) {
return B (B (B (when (type.type === FUNCTION)
(parenthesize (_)))))
(formatType4 (g));
};
}
st.carets.push (_underline (t, [], W (f (r ('^')))));
st.numbers.push (_underline (t, [], W (f (function(s) {
var f = B (when (t.type === FUNCTION)
(parenthesize (_)))
(B (function(f) { return _underline (t, [], f); })
(formatType5 (index)));
st.carets.push (f (r ('^')));
st.numbers.push (f (function(s) {
return label (show (st.counter += 1)) (s);
}))));
}));
return st;
}, {carets: [], numbers: [], counter: 0});

Expand Down
36 changes: 36 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2824,6 +2824,42 @@ T :: a -> (a -> b) -> b
1

Expected one argument but received zero arguments.
`));

throws (() => { def ('once') ({}) ([$.Fn (a) (b), a, b]) (f => x => f (x)) (null); })
(new TypeError (`Invalid value

once :: (a -> b) -> a -> b
^^^^^^
1

1) null :: Null

The value at position 1 is not a member of ‘a -> b’.
`));

throws (() => { def ('twice') ({}) ([$.Fn (a) ($.Fn (a) (b)), a, b]) (f => x => f (x) (x)) (null); })
(new TypeError (`Invalid value

twice :: (a -> a -> b) -> a -> b
^^^^^^^^^^^
1

1) null :: Null

The value at position 1 is not a member of ‘a -> a -> b’.
`));

throws (() => { def ('thrice') ({}) ([$.Fn (a) ($.Fn (a) ($.Fn (a) (b))), a, b]) (f => x => f (x) (x) (x)) (null); })
(new TypeError (`Invalid value

thrice :: (a -> a -> a -> b) -> a -> b
^^^^^^^^^^^^^^^^
1

1) null :: Null

The value at position 1 is not a member of ‘a -> a -> a -> b’.
`));
});

Expand Down