haskellari / some

Existential type.
BSD 3-Clause "New" or "Revised" License
36 stars 13 forks source link

Support for `exists a b. Either a b` and `exists a. Either a Int` #33

Closed gelisam closed 1 year ago

gelisam commented 4 years ago

Some can only express exists a. Either Int a, but not the other two (at least not very easily).

I stumbled upon some old code of mine which supports all three and more, using two transformers I call SomeT and ThisT:

I thought you might want to steal those ideas to make this package useful in more cases. I bet it would be easy to implement a third transformer which would support constraints too:

masaeedu commented 3 years ago

The latter is supported by Some (Flip Either Int) I believe. The former is "supported" to the extent that we can uncurry data types:

type Uncurry :: (x -> y -> *) -> (x, y) -> *
data Uncurry f
  where
  Uncurry :: f a b -> Uncurry f '(a, b)

type TheFirstThing = Some (Uncurry Either)

Although this sometimes tends to run into issues.

Ericson2314 commented 2 years ago

Yeah, I think such Flip and Uncurry tricks are good enough until https://github.com/ghc-proposals/ghc-proposals/pull/473 exists.