harendra.kumar at gmail.com
Mon Sep 24 10:42:23 UTC 2018
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?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe