purescript-deprecated/purescript-generics

Generic1

Opened this issue · 2 comments

Not sure how simple this. Maybe something like

class Generic1 f where
  toSpine1 :: forall a. f a -> GenericSpine
  fromSpine1 :: forall a. GenericSpine -> Maybe (f a)
  toSignature1 :: Proxy1 f -> GenericSignature1

where GenericSignature1 adds a constructor for the type argument somehow.

With a view to deriving Functor, Foldable, Traversable, etc.

gbaz commented

I have a hunch we can derive those without a new class.

In particular, introduce a "fresh type" Placeholder that instantiates generic and is essentially a newtype for unit.

Now you can examine the Spine of Foo Placeholder and see the "shape of Foo with an arbitary placeholder" and work from there...?

Ah, neat idea.