<div dir="ltr">On Fri, Oct 4, 2013 at 10:31 PM, Wvv <span dir="ltr">&lt;<a href="mailto:vitea3v@rambler.ru" target="_blank">vitea3v@rambler.ru</a>&gt;</span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

Newclasses are something like instances, but out of scope. In a baggage.<br>
</blockquote><div><br></div><div>So under the hood of GHC, newclasses would be partially filled in dictionaries.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

We already have too many classes: (...)<br>
<br>
We can&#39;t divide all classes to atimic ones.<br></blockquote><div><br></div><div>As you have seen, we can. As you also see, it is a little impractical.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">


Main purpose of newclasses is to make instances as minimal as possible. In<br>
many cases empty.<br>
<br>
About newclass and compose data, we can do next:<br>
<br>
š šnewclass Foo [a] =&gt; FooList a where {containerMainipulation=...}<br>
<br>
š šnewclass Foo (Set a) =&gt; FooSet a where {containerMainipulation=...}<br>
<br>
š šnewclass Foo (Sequence a) =&gt; FooSeq a where {containerMainipulation=...}<br>
<br>
so now I can switch any container of my data, changing only name of<br>
newclass:<br>
<br>
š instance FooList MyData where {dataMainipulation=...}<br></blockquote><div><br></div><div>You can already solve that in Haskell 98:</div><div><br></div><div>š š class Foo2 f where { containerManipulation = ... }</div><div>

š š instance Foo2 [] where { ... }</div><div>š š instance Foo2 Set where { ... }</div><div>š š instance Foo2 Sequence where { ... }</div><div><br></div><div>š š class (Foo2 f) =&gt; Foo1 f a where { dataManipulation = ... }</div>

<div><br></div><div>Or even:</div><div><br></div><div>š š class Foo&#39; a where { dataManipulation&#39; = ... }</div><div>š š dataManipulation = dataManipulation&#39; yourDefaultContainerManipulation</div><div><br></div>

<div>Remember: the only special things about type classes is that they are types that can/must be implicit. You can (almost?) always replace them by explicit parameters.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

Or let I have an MyArrow data. And I need some semigroupoid manipulations.<br>
I just write<br>
<br>
š instance ArrSemigroupoid MyArrow š š --empty<br>
<br>
that&#39;s all, I plug-in, let&#39;s just use semigroupoids functions!<br>
<br>
Or I have MyMonad and I want some Functor, so I just plug-in:<br>
<br>
š instance MFunctor MyMonad š š š --empty<br>
<br>
that&#39;s all.<br>
I also need some Applicative! Easy:<br>
<br>
š instance MApplicative MyMonad š --empty again<br>
<br>
done!<br></blockquote><div><br></div><div>Let&#39;s see how many lines of code this costs in Haskell 98:</div><div><br></div><div>š š instance Monad MyMonad where { ... }</div><div>š š instance Functor MyMonad where</div>

<div>š š š š fmap = liftM</div><div>š š instance Applicative MyMonad where</div><div>š š š š pure = return</div><div>š š š š (&lt;*&gt;) = ap</div><div><br></div><div>Only three lines more, and they&#39;re readable.</div>

<div><br></div><div><div>I think newclasses are not solving the existing problems, as you&#39;re only removing three well-understood lines of code in the above example, while people have to look up what you mean by MFunctor and MApplicative.</div>

</div><div><br></div><div>I think default superclass instances are a much better idea, or alternatively, the ConstraintSynonymInstances I previously mentioned (but not both -- they&#39;ll probably bite each other).</div>
<div>
<br></div><div>-Stijn</div></div></div></div>