-
Notifications
You must be signed in to change notification settings - Fork 4
Add some instances #4
Add some instances #4
Conversation
|
|
||
| instance commutativeRingProxy :: CommutativeRing (Proxy a) | ||
|
|
||
| instance discardProxy :: Discard (Proxy a) where |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this one means we'd allow discarding values of type Proxy a in do notation. Discard is meant for types like Unit so I'm not sure that's what we want.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean, of course, it is a unit type, but somehow it seems to convey more information.
That said, we can't use that information in a pattern match, since we can't bind type variables, so actually I'm fine with this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, up to you whether we keep these Discard instances. I don't have enough experience with it to know if it's a good idea or a bad idea.
|
👍 I like it, thanks! |
|
A question tangentially related to this: what happens about instances with purescript/purescript/pull/2846? They'll just be impossible? |
|
@garyb Do you think those instances would be useful? I'll have to think if the polykindedness of the instances would be an issue. |
|
I don't know, it was just a thought. Maybe this is something that would need real {-# LANGUAGE KindSignatures, PolyKinds #-}
data Proxy (a :: k) = Proxy
instance Functor Proxy where
fmap _ _ = Proxy
data Const a b = Const a
bar :: Proxy Int
bar = Proxy
foo :: Proxy Const
foo = Proxy
barB = const True <$> bar
-- Only becomes an error here, everything before this is 👌
fooB = const True <$> fooKind of interesting! |
|
Thanks! |
|
Any use case of let's say |
|
|
I found myself wanting
Functor Proxy. So I added that. Then I figured, what the heck, let's add everything we can.This does add a dependency on prelude. I'm not sure if that's wanted, or if it's been avoided for a reason.
I'm fine with throwing this all away if it's not wanted.