Skip to content

Commit fd832da

Browse files
committed
Make Eq and Ord foreign functions less JS-specific (restore unsafeCompare)
1 parent a6d9c4e commit fd832da

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

src/Data/Ord/Unsafe.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
"use strict";
2+
3+
exports.unsafeCompareImpl = function (lt) {
4+
return function (eq) {
5+
return function (gt) {
6+
return function (x) {
7+
return function (y) {
8+
return x < y ? lt : x === y ? eq : gt;
9+
};
10+
};
11+
};
12+
};
13+
};

src/Data/Ord/Unsafe.purs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
module Data.Ord.Unsafe (unsafeCompare) where
2+
3+
import Data.Ordering (Ordering(..))
4+
5+
unsafeCompare :: forall a. a -> a -> Ordering
6+
unsafeCompare = unsafeCompareImpl LT EQ GT
7+
8+
foreign import unsafeCompareImpl
9+
:: forall a
10+
. Ordering
11+
-> Ordering
12+
-> Ordering
13+
-> a
14+
-> a
15+
-> Ordering

0 commit comments

Comments
 (0)