diff --git a/src/Data/Generic.purs b/src/Data/Generic.purs index 502c7d1..e72e596 100755 --- a/src/Data/Generic.purs +++ b/src/Data/Generic.purs @@ -139,6 +139,15 @@ isValidSpine (SigRecord fieldSigs) (SRecord fieldVals) = (sortBy (\a b -> compare a.recLabel b.recLabel) fieldVals) isValidSpine _ _ = false + +instance genericUnit :: Generic Unit where + toSpine _ = SProd "Prelude.Unit" [] + toSignature _ = SigProd "Prelude.Unit" [{ sigConstructor : "Prelude.Unit" + , sigValues : [] + }] + fromSpine (SProd "Prelude.Unit" []) = Just unit + fromSpine _ = Nothing + instance genericNumber :: Generic Number where toSpine x = SNumber x toSignature _ = SigNumber diff --git a/test/Main.purs b/test/Main.purs index 1160f45..46f25c6 100755 --- a/test/Main.purs +++ b/test/Main.purs @@ -57,6 +57,7 @@ main = do , Corge ['H', 'i', ' ', 'D', 'e', 'r', 'e'] ] log "Testing Show GenericSignature instance:" + print (toSignature (Proxy :: Proxy Unit)) print (toSignature (Proxy :: Proxy Number)) print (toSignature (Proxy :: Proxy Char)) print (toSignature (Proxy :: Proxy (Array (Array Number))))