Skip to content
This repository was archived by the owner on Oct 4, 2020. It is now read-only.

Commit a38359f

Browse files
ethulpaf31
authored andcommitted
Adding void instance (#47)
* Adding void instance Resolves #46 * Remove SVoid * Remove SigVoid
1 parent 4242b01 commit a38359f

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/Data/Generic.purs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@ instance genericUnit :: Generic Unit where
8585
fromSpine SUnit = Just unit
8686
fromSpine _ = Nothing
8787

88+
instance genericVoid :: Generic Void where
89+
toSpine = absurd
90+
toSignature _ = SigProd "Data.Void.Void" []
91+
fromSpine _ = Nothing
92+
8893
instance genericTuple :: (Generic a, Generic b) => Generic (Tuple a b) where
8994
toSpine (Tuple x y) =
9095
SProd "Data.Tuple.Tuple" [\_ -> toSpine x, \_ -> toSpine y]

test/Main.purs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ data UnitPlus = UnitPlus Unit Unit
3030

3131
derive instance genericUnitPlus :: Generic UnitPlus
3232

33+
data VoidPlus = VoidPlus Void Void
34+
35+
derive instance genericVoidPlus :: Generic VoidPlus
36+
3337
instance showFoo :: Show Foo where
3438
show = gShow
3539

0 commit comments

Comments
 (0)