Skip to content

Add Exists2, Exists3... ? #20

@m-bock

Description

@m-bock

In case you want to hide two type arguments, the best I could figure out to do with the existing Exist is:

data Sample a b = Sample a b

newtype Sample' a = Sample' (Exists (Sample a))

type Sample'' = Exists Sample'

Does anyone know a better way? If not, I would suggest to add something like this:

foreign import data Exists2 :: (Type -> Type -> Type) -> Type

type role Exists2 representational

mkExists2 :: forall f a b. f a b -> Exists2 f
mkExists2 = unsafeCoerce

runExists2 :: forall f r. (forall a b. f a b -> r) -> Exists2 f -> r
runExists2 = unsafeCoerce

You can use it like this:

data Sample a b = Sample a b
type Sample' = Exists2 Sample

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions