[Hugs-users] Pattern Signatures: what can scoped type variables refer to?
anthony_clayden at clear.net.nz
Thu Dec 6 10:15:37 UTC 2018
HugsMode supports signatures in patterns, roughly equivalent to the (now
deprecated) `PatternSignatures` GHC extension. Hugs doesn't support GHC's
full `ScopedTypeVariables` functionality with the daft/bogus `forall`
quantification on stand-alone signatures -- which IMO is a wart.
I'm reading the 2018 paper 'Type variables in patterns'
Eisenberg/Breitner/Peyton Jones, section 3.1, 3.5 "a scoped type variable
may refer only to another type variable". Hugs applies the same rule.
I'm persuaded by section 3.5's saying that seems an arbitrary and
unnecessary restriction. "We therefore propose to simply drop this
restriction." This is github PR #128 in GHC.
Done in Hugs: I've just suppressed the error message, is in one validation
routine in one module.
So this example compiles
> prefix :: Int -> [[Int]] -> [[Int]]
> prefix (x :: b) yss = map xcons yss -- previously :: b was
> where xcons ys = x : ys :: [b] -- now can use b to
annotate the rhs
It seems to me that inline tyvar bindings/annotations like this is
preferable to the `ScopedTypeVariables` explicit `foralls` on a standalone
signature signalling some tyvar is being scoped over some declaration/term.
See also similar comments in github PR #119 'Resurrect PatternSignatures'
(now withdrawn). There were quite a few opinions to the effect that
`PatternSignatures` (but not full bore `ScopedTypeVariables`) should always
have been part of Haskell; and perhaps that'd be ripe for inclusion in
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Hugs-Users