-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clarify what's unused #13
Conversation
Following `profunctors`, make the types indicate what's unused.
Ah, neat trick. I didn't know about this. Waiting for travis, then I'll take another look. |
@sjakobi what are your thoughts on this? I'm in favour. The only drawback might be that type errors are slightly more confusing, though it's unlikely that users are going to pass anything but a function in practise anyway. also, perhaps the use of this trick should be documented. |
I'm not so sure about the type variable name/presentation. I think we should use something infix to suggest a function arrow. Since we can't use actual operator characters in a type variable, maybe something like |
Or maybe |
Neat idea! We have the following note in the haddocks:
So how about something like
We could then have haddocks on the type alias. |
BTW @chessai, had you seen sjakobi/newtype-generics#5? I sometimes feel bad about having this neat API just lying around. I suspect that it's actually better than what either |
I think I'd prefer something more like |
I'm not a fan of this |
I think the right place to document what the |
By the way... if you want to keep precisely the same API as before while still communicating the same thing, one option would be class IsArrow p | -> p
instance IsArrow (->)
-- or
class IsArrow p where
type Silly p -- banish overlapping instances
instance p ~ (->) => IsArrow p where
type Silly (->) = ()
(#.) :: (Coercible b c, IsArrow p) => p b c -> (a -> b) -> a -> c
(#.) _ = coerce (#.) _ = coerce This means the argument will be inferred as having a function type, but |
I generally share this opinion. Type synonyms are generally distracting, I only like using them for quick hacking. Almost all usage of type synonyms are banned at work, except for the common transformers+Identity story. Okay, I think we should just name |
@chessai, for what it's worth, I have found more uses for type synonyms than that. Several higher-rank ones can be useful, like type family ReverseOnto acc xs where
ReverseOnto acc '[] = acc
ReverseOnto acc (x ': xs) = ReverseOnto (x ': acc) xs
type Reverse xs = ReverseOnto '[] xs I recently found them useful for working around nasty limitations of the type role system, where sticking a My final "approved by me!" use for type synonyms is as throw-away constraint synonyms appearing once as a superclass constraint, once as an instance constraint, and never again. type CS a b c d = (Blah a, Boop a b, Bleep b c, Huh c d b, .......)
class CS a b c d => C a b c d
instance CS a b c d => C a b c d Sorry for the irrelevant ramble; can't help myself. |
it's ok; i enjoy your rambles. i can see uses for all of those. |
Yeah, I'd be fine with something like
or
Although I'd like to see the haddocks before we make the final decision. |
I changed the name of the type variable and updated the documentation. |
Co-Authored-By: Simon Jakobi <simon.jakobi@gmail.com>
Thank you @treeowl! :) |
Following
profunctors
, make the types indicate what's unused.