<div dir="ltr"><br><div class="gmail_quote"><div dir="ltr">On Wed, 26 Sep 2018 at 18:11, Wolfgang Jeltsch <<a href="mailto:wolfgang-it@jeltsch.info">wolfgang-it@jeltsch.info</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>Am Dienstag, den 25.09.2018, 02:05 +0530 schrieb Harendra Kumar:</div><blockquote type="cite"><div dir="ltr"><div dir="ltr">That's where I started. I already use a newtype with GND for this, and it looks like this:<br><div class="gmail_quote"><div><br></div><div><div><font face="monospace"><b>newtype</b> Count = Count Int64</font></div><div><font face="monospace">    <b>deriving</b> ( Eq</font></div><div><font face="monospace">             , Read</font></div><div><font face="monospace">             , Show</font></div><div><font face="monospace">             , Enum</font></div><div><font face="monospace">             , Bounded</font></div><div><font face="monospace">             , Num</font></div><div><font face="monospace">             , Real</font></div><div><font face="monospace">             , Integral</font></div><div><font face="monospace">             , Ord</font></div><div><font face="monospace">             )</font></div></div><div><br></div><div>The problem is that most programmers are lazy or hard pressed for time and having to write a <font face="monospace"><b>newtype</b></font> with a big list of instances actually discourages the use of <font face="monospace"><b>newtype</b></font>s freely for this case, they may just make it a habit to let it go. We can't just deny this and say that programmers must be disciplined. They will often try taking the path of least effort.</div></div></div></div></blockquote><div><br></div><div>I think that the time it takes to come up with and write down such explicit lists is usually small compared to the time it takes to do all the other development. And once you have made the instantiation lists explicit, you will probably save time in the future, because bugs will detected automatically more often. The latter point is something that is often overlooked: people are under time pressure and strive for quick solutions but spend more time in the long run this way.</div></blockquote><div><br></div><div>Two quick thoughts:</div><div><br></div><div>1) Nobody has pointed out what kind of bugs (with specific examples) will arise if we have something like clonetype. Are those bugs more dangerous or will consume more time compared to what we are trying to avoid in the first place? I am just trying to learn more about it, not claiming that this is better.</div><div><br></div><div>2) It is a real unsolvable problem that people take shortcuts when available, people will be people; this is also one of the reasons why Haskell is not so successful, other languages are easy in the short run. If we accept that this a fact of life, we have two options in general, (1) provide a safer shorter route so that we automatically choose that one (2) close the unsafe shorter route to force ourselves to choose the safe one. I was trying to explore if there is a solution on the lines of the first option. The second option means that we should not allow two arguments of the same type in a function, forcing them to always make a newtype, perhaps a much more draconian solution and not worth the pain.</div><div><br></div><div>-harendra</div><div> </div></div></div>