Skip to content

Commit 8817c69

Browse files
Merge pull request #273 from sanctuary-js/davidchambers/underline
fix underlining of higher-order functions
2 parents 61dc793 + dc6bb49 commit 8817c69

File tree

2 files changed

+43
-14
lines changed

2 files changed

+43
-14
lines changed

index.js

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -242,9 +242,6 @@
242242
// K :: a -> b -> a
243243
function K(x) { return function(y) { return x; }; }
244244

245-
// W :: (a -> a -> b) -> a -> b
246-
function W(f) { return function(x) { return f (x) (x); }; }
247-
248245
// always0 :: a -> () -> a
249246
function always0(x) { return function() { return x; }; }
250247

@@ -2359,18 +2356,14 @@
23592356
// :: Integer -> (String -> String) -> Type -> PropPath -> String -> String
23602357
) {
23612358
var st = typeInfo.types.reduce (function(st, t, index) {
2362-
var formatType4 = formatType5 (index);
2363-
function f(g) {
2364-
return function(type) {
2365-
return B (B (B (when (type.type === FUNCTION)
2366-
(parenthesize (_)))))
2367-
(formatType4 (g));
2368-
};
2369-
}
2370-
st.carets.push (_underline (t, [], W (f (r ('^')))));
2371-
st.numbers.push (_underline (t, [], W (f (function(s) {
2359+
var f = B (when (t.type === FUNCTION)
2360+
(parenthesize (_)))
2361+
(B (function(f) { return _underline (t, [], f); })
2362+
(formatType5 (index)));
2363+
st.carets.push (f (r ('^')));
2364+
st.numbers.push (f (function(s) {
23722365
return label (show (st.counter += 1)) (s);
2373-
}))));
2366+
}));
23742367
return st;
23752368
}, {carets: [], numbers: [], counter: 0});
23762369

test/index.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2824,6 +2824,42 @@ T :: a -> (a -> b) -> b
28242824
1
28252825
28262826
Expected one argument but received zero arguments.
2827+
`));
2828+
2829+
throws (() => { def ('once') ({}) ([$.Fn (a) (b), a, b]) (f => x => f (x)) (null); })
2830+
(new TypeError (`Invalid value
2831+
2832+
once :: (a -> b) -> a -> b
2833+
^^^^^^
2834+
1
2835+
2836+
1) null :: Null
2837+
2838+
The value at position 1 is not a member of ‘a -> b’.
2839+
`));
2840+
2841+
throws (() => { def ('twice') ({}) ([$.Fn (a) ($.Fn (a) (b)), a, b]) (f => x => f (x) (x)) (null); })
2842+
(new TypeError (`Invalid value
2843+
2844+
twice :: (a -> a -> b) -> a -> b
2845+
^^^^^^^^^^^
2846+
1
2847+
2848+
1) null :: Null
2849+
2850+
The value at position 1 is not a member of ‘a -> a -> b’.
2851+
`));
2852+
2853+
throws (() => { def ('thrice') ({}) ([$.Fn (a) ($.Fn (a) ($.Fn (a) (b))), a, b]) (f => x => f (x) (x) (x)) (null); })
2854+
(new TypeError (`Invalid value
2855+
2856+
thrice :: (a -> a -> a -> b) -> a -> b
2857+
^^^^^^^^^^^^^^^^
2858+
1
2859+
2860+
1) null :: Null
2861+
2862+
The value at position 1 is not a member of ‘a -> a -> a -> b’.
28272863
`));
28282864
});
28292865

0 commit comments

Comments
 (0)