[Haskell-cafe] Newclasses

Wvv vitea3v
Fri Oct 4 20:31:05 UTC 2013

Newclasses are something like instances, but out of scope. In a baggage.
We don't use them for interfere their functions.
This why newclasses never overlap each other and between them and any
We use newclasses to plug-in/connect to any related class or combine data

Replying to you question, yes, instance of newclass desugar to instance of

  instance BMonad MyBind where {return= ...}

desugar into 

  instance Monad MyBind where {return= ...; (>>=) = (>>-)}

We already have too many classes: look at
Edward Kmett
13 dependent classes (from Foldable to MonadPlus)
30-60 dependent class
11 dependent classes

We can't divide all classes to atimic ones. 
I do not want to implement all depended class instances, even of atomic, if
I want to work with hight class only.
But I want easy connection with any related class! And newclasses solve this

Also in reality we have several realizations of same class/compose data and
we want to mix them for better realizations. Newclasses allows switch them
as engines! Easy.

Main purpose of newclasses is to make instances as minimal as possible. In
many cases empty.

About newclass and compose data, we can do next:

   newclass Foo [a] => FooList a where {containerMainipulation=...}

   newclass Foo (Set a) => FooSet a where {containerMainipulation=...}

   newclass Foo (Sequence a) => FooSeq a where {containerMainipulation=...}

so now I can switch any container of my data, changing only name of

  instance FooList MyData where {dataMainipulation=...}

Or let I have an MyArrow data. And I need some semigroupoid manipulations.
I just write

  instance ArrSemigroupoid MyArrow     --empty

that's all, I plug-in, let's just use semigroupoids functions!

Or I have MyMonad and I want some Functor, so I just plug-in:

  instance MFunctor MyMonad       --empty

that's all.
I also need some Applicative! Easy:

  instance MApplicative MyMonad   --empty again


About conflicts, I don't understand a bit. Which ones? We catch Overlapped
instances or even Incoherent instances at once we add both newclass
instances of the same class.

John Lato-2 wrote
> I meant to say, does it mean that by
> writing a BMonad instance a Monad instance would be automatically
> generated?  If so, that seems like it would cause conflicts in many cases.
> Regardless, I think "newclass" needs to be better specified if you want
> other people to be able to support it.
> On Thu, Oct 3, 2013 at 7:53 PM, John Lato <

> jwlato@

> > wrote:
>> I don't really understand what a "newclass" is supposed to be.
>> On Thu, Oct 3, 2013 at 2:15 PM, Wvv <

> vitea3v@

> > wrote:
>>>     newclass Bind a => Monad a => BMonad a where { (>>=) = (>>-) }
>> I think this means that `BMonad` is supposed to be a new class that has
>> both Bind and Monad in scope, the same as
>>   class (Bind a, Monad a) => BMonad a
>> except that the Monad instance's (>>=) is replaced by (>>-).
>> If that's what "newclass" means, it seems absolutely pointless.
>> Does it instead mean that one could write
>>   instance Bind MyType where
>>   instance BMonad MyType
> _______________________________________________
> Haskell-Cafe mailing list

> Haskell-Cafe@

> http://www.haskell.org/mailman/listinfo/haskell-cafe

View this message in context: http://haskell.1045720.n5.nabble.com/Newclasses-tp5737596p5737792.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

More information about the Haskell-Cafe mailing list