Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view


Harendra Kumar
Often, we need to create a newtype that is equivalent to a given type for safety reasons. Using type  synonym is useless from type safety perspective. With newtype, we have to add a "deriving" clause to it for deriving the required instances, to make it practically useful.

Does it make sense, and is it possible to have something like a "clonetype" that creates a new type and derives all the instances of the parent type as well? It will be quite helpful in creating equivalent newtype synonyms quickly. Almost always, I do not use a newtype where I should just because of the inconvenience of deriving the instances. Ideally, we should just be able to say something like:

clonetype MyString = String

and we are good to go.  What is the shortest possible way to achieve this with currently available mechanisms, if any?


ghc-devs mailing list
[hidden email]