-
Notifications
You must be signed in to change notification settings - Fork 91
[generics-rep] No instance for Unit? #242
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
I don't know why there isn't an instance here - it could be because of the I assume the instance would be instance genericUnit ∷ Generic Unit (Constructor "Unit" NoArguments) where
to _ = unit
from _ = Constructor NoArguments |
This is probably asked a lot too - but why stop at data GenericInt = GenericInt Int
instance genericInt :: Generic Int GenericInt where
to (GenericInt x) = x
from x = GenericInt x
instance genericShowGenericInt :: GenericShow GenericInt where
genericShow' (GenericInt x) = show x Now if I make my own fancy type deriving generic: data Foo a = Bar | Baz a
derive instance genericFoo :: Generic a a' => Generic (Foo a) _
instance showFoo :: (Show a, Generic a a') => Show (Foo a) where
show = genericShow then this wouldn't cause a type error: show (Foo 1) -- "Foo 1" |
That's not really how Generic is meant to be used. Unlike the previous (now-deprecated) See for example the
I suspect that in your case, the issue is the constraint on your data Foo a = Bar | Baz a
derive instance genericFoo :: Generic (Foo a) _
instance showFoo :: (Show a) => Show (Foo a) where
show = genericShow |
Should this issue be closed? |
Yes, I think so. |
Why isn't there a
Generic Unit rep
instance? Is it because there's no data constructors? If so, why would it not be technically trivial to generate a value ofUnit
given the fact that one exists? I'm not sure if I follow the technical reasoning why there isn't an instance, but I could see it because of how weird Unit is for purescript.The text was updated successfully, but these errors were encountered: