Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/Data/Generic/Rep.purs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module Data.Generic.Rep
( class Generic
, to
, from
, toRep
, NoConstructors
, NoArguments(..)
, Sum(..)
Expand All @@ -10,6 +11,8 @@ module Data.Generic.Rep
, Argument(..)
) where

import Type.Proxy (Proxy(..))

-- | A representation for types with no constructors.
data NoConstructors

Expand All @@ -34,3 +37,6 @@ newtype Argument a = Argument a
class Generic a rep | a -> rep where
to :: rep -> a
from :: a -> rep

toRep :: forall from to. Generic from to => Proxy from -> Proxy to
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we reuse a and rep variables, like in the class declaration?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also I don’t know about you but I frequently confuse to and from, and I’m sure having to :: rep -> a but toRep :: Proxy a -> Proxy rep is going to be even more confusing to me 😬 May I suggest repOf instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good to me!

toRep _ = Proxy