git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Merge pull request #519 from purescript/ffi-safe-compare

Make `unsafeCompare` "FFI-safe"

commit3fa1d04373872d2c43919e8590a82f8dcd1189bf authorPhil Freeman <paf31@cantab.net> dateSun 27 Jul 2014, 15:04 (12 years ago) parentf1f52957aa36af
1 file changed+14−5
prelude/prelude.purs+14−5
prelude/prelude.purs+14−5
@@ -332,12 +332,21 @@ module Prelude
332332 LT -> false
333333 _ -> true
334334
335− foreign import unsafeCompare
336− "function unsafeCompare(n1) {\
337− \ return function(n2) {\
338− \ return n1 < n2 ? LT.value : n1 > n2 ? GT.value : EQ.value;\
335+ foreign import unsafeCompareImpl
336+ "function unsafeCompareImpl(lt) {\
337+ \ return function (eq) {\
338+ \ return function (gt) {\
339+ \ return function (x) {\
340+ \ return function (y) {\
341+ \ return x < y ? lt : x > y ? gt : eq;\
342+ \ };\
343+ \ };\
344+ \ };\
339345 \ };\
340− \}" :: forall a. a -> a -> Ordering
346+ \}" :: forall a. Ordering -> Ordering -> Ordering -> a -> a -> Ordering
347+
348+ unsafeCompare :: forall a. a -> a -> Ordering
349+ unsafeCompare = unsafeCompareImpl LT EQ GT
341350
342351 instance ordUnit :: Ord Unit where
343352 compare (Unit {}) (Unit {}) = EQ