[Haskell-cafe] How to bring existentially quantified type variables into scope

Alexis King lexi.lambda at gmail.com
Fri Aug 11 00:29:09 UTC 2017


> On Aug 10, 2017, at 5:08 PM, Wolfgang Jeltsch
> <wolfgang-it at jeltsch.info> wrote:
> 
> Is there also a solution that does not involve using this
> (unimplemented) feature?

I get the feeling there is a better way to do this, but I found
something of a hack that I think does what you want. Using
Data.Type.Equality, you can match on Refl to bring the `b` into scope.

  import Data.Type.Equality

  f :: forall a. IsListType a -> ()
  f IsListType = case Refl of
    (Refl :: (a :~: [b])) -> ()

This is sort of silly, though.

Alexis



More information about the Haskell-Cafe mailing list