git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Merge pull request #406 from puffnfresh/unit
2def2f6Phil Freeman
examples/passing/Unit.pursnew file+6
@@ -0,0 +1,6 @@
1+module Main where
2+
3+import Prelude
4+import Debug.Trace
5+
6+main = print (unit "Hello world")
prelude/prelude.purs+19
@@ -21,6 +21,7 @@ module Prelude
21 , BoolLike, (&&), (||)
21 , BoolLike, (&&), (||)
22 , not
22 , not
23 , Semigroup, (<>), (++)
23 , Semigroup, (<>), (++)
24+ , Unit(..), 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
@@ -79,6 +80,9 @@ module Prelude
79 \ return JSON.stringify(s);\
80 \ return JSON.stringify(s);\
80 \}" :: String -> String
81 \}" :: String -> String
81
82
83+ instance showUnit :: Show Unit where
84+ show (Unit {}) = "Unit {}"
85+
82 instance showString :: Show String where
86 instance showString :: Show String where
83 show = showStringImpl
87 show = showStringImpl
84
88
@@ -207,6 +211,11 @@ module Prelude
207 (%) = numMod
211 (%) = numMod
208 negate = numNegate
212 negate = numNegate
209
213
214+ data Unit = Unit {}
215+
216+ unit :: forall a. a -> Unit
217+ unit = const (Unit {})
218+
210 infix 4 ==
219 infix 4 ==
211 infix 4 /=
220 infix 4 /=
212
221
@@ -228,6 +237,10 @@ module Prelude
228 \ };\
237 \ };\
229 \}" :: forall a. a -> a -> Boolean
238 \}" :: forall a. a -> a -> Boolean
230
239
240+ instance eqUnit :: Eq Unit where
241+ (==) (Unit {}) (Unit {}) = true
242+ (/=) (Unit {}) (Unit {}) = false
243+
231 instance eqString :: Eq String where
244 instance eqString :: Eq String where
232 (==) = refEq
245 (==) = refEq
233 (/=) = refIneq
246 (/=) = refIneq
@@ -297,6 +310,9 @@ module Prelude
297 \ return n1 < n2 ? LT : n1 > n2 ? GT : EQ;\
310 \ return n1 < n2 ? LT : n1 > n2 ? GT : EQ;\
298 \ };\
311 \ };\
299 \}" :: forall a. a -> a -> Ordering
312 \}" :: forall a. a -> a -> Ordering
313+
314+ instance ordUnit :: Ord Unit where
315+ compare (Unit {}) (Unit {}) = EQ
300
316
301 instance ordBoolean :: Ord Boolean where
317 instance ordBoolean :: Ord Boolean where
302 compare false false = EQ
318 compare false false = EQ
@@ -421,6 +437,9 @@ module Prelude
421 \ };\
437 \ };\
422 \}" :: String -> String -> String
438 \}" :: String -> String -> String
423
439
440+ instance semigroupUnit :: Semigroup Unit where
441+ (<>) (Unit {}) (Unit {}) = Unit {}
442+
424 instance semigroupString :: Semigroup String where
443 instance semigroupString :: Semigroup String where
425 (<>) = concatString
444 (<>) = concatString
426
445