git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Add Unit data type and instances
d201dcaBrian McKenna
prelude/prelude.purs+13
@@ -21,6 +21,7 @@ module Prelude
21 , BoolLike, (&&), (||)
21 , BoolLike, (&&), (||)
22 , not
22 , not
23 , Semigroup, (<>), (++)
23 , Semigroup, (<>), (++)
24+ , Unit(..)
24 ) where
25 ) where
25
26
26 flip :: forall a b c. (a -> b -> c) -> b -> a -> c
27 flip :: forall a b c. (a -> b -> c) -> b -> a -> c
@@ -207,6 +208,8 @@ module Prelude
207 (%) = numMod
208 (%) = numMod
208 negate = numNegate
209 negate = numNegate
209
210
211+ data Unit = Unit {}
212+
210 infix 4 ==
213 infix 4 ==
211 infix 4 /=
214 infix 4 /=
212
215
@@ -228,6 +231,10 @@ module Prelude
228 \ };\
231 \ };\
229 \}" :: forall a. a -> a -> Boolean
232 \}" :: forall a. a -> a -> Boolean
230
233
234+ instance eqUnit :: Eq Unit where
235+ (==) (Unit {}) (Unit {}) = true
236+ (/=) (Unit {}) (Unit {}) = false
237+
231 instance eqString :: Eq String where
238 instance eqString :: Eq String where
232 (==) = refEq
239 (==) = refEq
233 (/=) = refIneq
240 (/=) = refIneq
@@ -297,6 +304,9 @@ module Prelude
297 \ return n1 < n2 ? LT : n1 > n2 ? GT : EQ;\
304 \ return n1 < n2 ? LT : n1 > n2 ? GT : EQ;\
298 \ };\
305 \ };\
299 \}" :: forall a. a -> a -> Ordering
306 \}" :: forall a. a -> a -> Ordering
307+
308+ instance ordUnit :: Ord Unit where
309+ compare (Unit {}) (Unit {}) = EQ
300
310
301 instance ordBoolean :: Ord Boolean where
311 instance ordBoolean :: Ord Boolean where
302 compare false false = EQ
312 compare false false = EQ
@@ -421,6 +431,9 @@ module Prelude
421 \ };\
431 \ };\
422 \}" :: String -> String -> String
432 \}" :: String -> String -> String
423
433
434+ instance semigroupUnit :: Semigroup Unit where
435+ (<>) (Unit {}) (Unit {}) = Unit {}
436+
424 instance semigroupString :: Semigroup String where
437 instance semigroupString :: Semigroup String where
425 (<>) = concatString
438 (<>) = concatString
426
439