Re: [Haskell-cafe] Re: Re: Data.Ring -- Pre-announce

2010-01-05 Thread John Van Enk
For those interested, the version of data-clist without Empty is here:

http://github.com/sw17ch/data-clist/tree/noEmpty



On Tue, Jan 5, 2010 at 2:53 AM, Luke Palmer  wrote:

> On Mon, Jan 4, 2010 at 1:13 PM, Maciej Piechotka 
> wrote:
> > However then we lost the monoid (ok. I haven't send patch but please
> > accept[1]) along with alternative/monad plus - which is much more
> > popular, standard and useful then Copointed/Comonad.
>
> This point is a self-fulfilling prophecy.  We don't have very much
> experience working with copointeds and comonads, but I don't think
> that makes them useless, just unfamiliar.
>
> "One must never confuse what is natural with what is habitual."  --
> Mahatma Gandhi
>
> Luke
> ___
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Re: Data.Ring -- Pre-announce

2010-01-04 Thread Luke Palmer
On Mon, Jan 4, 2010 at 1:13 PM, Maciej Piechotka  wrote:
> However then we lost the monoid (ok. I haven't send patch but please
> accept[1]) along with alternative/monad plus - which is much more
> popular, standard and useful then Copointed/Comonad.

This point is a self-fulfilling prophecy.  We don't have very much
experience working with copointeds and comonads, but I don't think
that makes them useless, just unfamiliar.

"One must never confuse what is natural with what is habitual."  --
Mahatma Gandhi

Luke
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Re: Data.Ring -- Pre-announce

2010-01-04 Thread Derek Elkins
On Tue, Jan 5, 2010 at 5:13 AM, Maciej Piechotka  wrote:
> On Mon, 2010-01-04 at 07:17 -0700, Luke Palmer wrote:
>> On Mon, Jan 4, 2010 at 6:51 AM, Maciej Piechotka  
>> wrote:
>> > About comonad - not exactly as every comonad is copointed and the only
>> > possible way is extract Empty = _|_
>>
>> I think this module could be cleaned up by disallowing empty lists.
>> You have this nice semantic property that "every clist has a focus",
>> but when you add empty you have to add "unless it's empty".  focus
>> returns a Maybe, isEmpty is necessary.
>>
>> I mean, it could be that your use case requires empty clists and would
>> be uglier without empty, but think about it.  I find in Haskell that
>> simplicity breeds simplicity; i.e. I'm willing to wager that whatever
>> algorithm you are using clist for will actually be cleaner if you got
>> rid of empty and modify the algorithm accordingly.  We shall see
>> though...
>>
>> Luke
>
> However then we lost the monoid (ok. I haven't send patch but please
> accept[1]) along with alternative/monad plus - which is much more
> popular, standard and useful then Copointed/Comonad.
>
> Additionally it would introduce:
> fromList [] = _|_

This isn't a big deal, it just means fromList is not appropriate
(which it is not, it should be fromNonEmptyList in this case.  We can
of course, also, simply return Maybe (NonEmptyCList a) which works
out.

> Is is somehow similar to 0 \in N - sometimes it is better to include it
> sometimes to not include it.
>
> Regards
>
> [1]
>> instance Monoid CList where
>>   mempty = Empry
>>   mappend = mplus

This is a bigger issue, however, given a type with a associative
binary operation, a semigroup, we can complete it to a monoid using a
Maybe-like type constructor to formally attach a unit.

data AddUnit a = Unit | Value a

class SemiGroup a where op :: a -> a -> a -- associative

instance (SemiGroup a) => Monoid (AddUnit a) where
mempty = Unit
Unit `mappend` y = y
x `mappend` Unit = x
Val x `mappend` Val y = Val (x `op` y)

We then have,
type CList a = AddUnit (NonEmptyCList a)
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: Re: Data.Ring -- Pre-announce

2010-01-04 Thread Maciej Piechotka
On Mon, 2010-01-04 at 07:17 -0700, Luke Palmer wrote:
> On Mon, Jan 4, 2010 at 6:51 AM, Maciej Piechotka  
> wrote:
> > About comonad - not exactly as every comonad is copointed and the only
> > possible way is extract Empty = _|_
> 
> I think this module could be cleaned up by disallowing empty lists.
> You have this nice semantic property that "every clist has a focus",
> but when you add empty you have to add "unless it's empty".  focus
> returns a Maybe, isEmpty is necessary.
> 
> I mean, it could be that your use case requires empty clists and would
> be uglier without empty, but think about it.  I find in Haskell that
> simplicity breeds simplicity; i.e. I'm willing to wager that whatever
> algorithm you are using clist for will actually be cleaner if you got
> rid of empty and modify the algorithm accordingly.  We shall see
> though...
> 
> Luke

However then we lost the monoid (ok. I haven't send patch but please
accept[1]) along with alternative/monad plus - which is much more
popular, standard and useful then Copointed/Comonad.

Additionally it would introduce:
fromList [] = _|_

Is is somehow similar to 0 \in N - sometimes it is better to include it
sometimes to not include it.

Regards

[1]
> instance Monoid CList where
>   mempty = Empry
>   mappend = mplus




___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe