Purescript: Allow wildcards without warning for type variables that only appear once?

Created on 3 Feb 2019  Â·  3Comments  Â·  Source: purescript/purescript

By convention some of us already use _1, etc. for type variables that are unused aside from in constraint computations, but perhaps we could support that explicitly and further allow _ to be used in types where the naming of that variable would be "meaningless", even at the top level.

An example: someone on Twitter objecting to a Halogen type signature again, I pointed out that there's only one type variable that is actually relevant:

raise :: forall s f g p o m. o -> HalogenM s f g p o m Unit

Could be:

raise :: forall o. o -> HalogenM _ _ _ _ o _ Unit

In this scheme.

Similar thing with _ in constraints:

expandError ∷ forall e1 e2 _1. Row.Union e1 _1 e2 ⇒ Error e1 → Error e2
expandError ∷ forall e1 e2. Row.Union e1 _ e2 ⇒ Error e1 → Error e2
error-message question typechecker

Most helpful comment

How about "if the resulting type is inferred to be an unconstrained unknown, don't warn"?

All 3 comments

How about "if the resulting type is inferred to be an unconstrained unknown, don't warn"?

I think @paf31 rule is simple enough and would be straightforward to implement. Do we want to move this to "Approved"?

Sure, moved.

Was this page helpful?
0 / 5 - 0 ratings