Re thimoteus post ('Existential without unsafeCoerce'): can we write this using the type Exists from above?

re https://thimoteus.github.io/posts/2018-09-21-existential-types.html

@thimoteus asks

newtype Showable = Showable (forall r. (forall a. Show a => a -> r) -> r)

(Question: can we write this using the type Exists from above?)

I think we cannot refactor this using type Exists f = ∀ r. (∀ a. f a -> r) -> r, right?


This doesn’t work newtype Showable = Showable (Exists (forall a . Show a => a))

No, because it requires a constraint. PureScript does not support constraint polymorphism.

1 Like