Skip to content

Kind-Polymorphism and Show #260

@csicar

Description

@csicar

As of 0.14, the Proxy-Zoo should get reduced to just one: Proxy. This means that creating type-class instances for proxied values is no longer possible (as far as I know)

For example in typelevel-peano (https://github.com/csicar/purescript-typelevel-peano/pull/4/files#diff-7de00383917fea851d52cc5de4f18f87329b6b3f4e2819a8ebcbf9d8c0d85a80R47) I had a Show-Instance for typelevel Ints, that would print the value representation:

>>> instance showNat :: Show (IProxy a) where show = reflectInt
>>> show (IProxy :: IProxy N10)
10

I think it would be nice to have the same functionality for Proxy as well:

-- In Type.Proxy
class KindShow a where
  kindShow :: Proxy a -> String

instance showkindShow :: (KindShow a) => Show (Proxy a) where
  show a = kindShow a

---- In client
data Int

reflectInt = ...

instance show :: KindShow Int where
  kindShow p = reflectInt p

Does that make sense? Is there an easier way?

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: needs more infoThis issue needs more info before any action can be done.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions