PROPOSAL: classes for traversals

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

PROPOSAL: classes for traversals

Ross Paterson
Conor McBride and I would like to propose some new classes for traversals
of containers, based around applicative functors (the abstraction formerly
known as idioms):

        http://www.soi.city.ac.uk/~ross/traversals/

They are proposed for the base package, and would replace FunctorM.

Comments most welcome.

_______________________________________________
Libraries mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re: PROPOSAL: classes for traversals

Shae Matijs Erisson
Ross Paterson <[hidden email]> writes:

> Conor McBride and I would like to propose some new classes for traversals
> of containers, based around applicative functors (the abstraction formerly
> known as idioms):
>
> http://www.soi.city.ac.uk/~ross/traversals/
>
> They are proposed for the base package, and would replace FunctorM.
>
> Comments most welcome.

On line 83-84 or Traversable.hs:

-- | Any 'Traversable' can also be made an instance of 'Functor' by
-- thng 'fmap' as this function.

Maybe thng should be assigning? I'm not sure which word should be there.
--
Shae Matijs Erisson - http://www.ScannedInAvian.com/ - Sockmonster once said:
You could switch out the unicycles for badgers, and the game would be the same.

_______________________________________________
Libraries mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re: PROPOSAL: classes for traversals

Tomasz Zielonka
In reply to this post by Ross Paterson
On Fri, Nov 18, 2005 at 11:05:37AM +0000, Ross Paterson wrote:
> Conor McBride and I would like to propose some new classes for traversals
> of containers, based around applicative functors (the abstraction formerly
> known as idioms):
>
> http://www.soi.city.ac.uk/~ross/traversals/
>
> They are proposed for the base package, and would replace FunctorM.

This is very nice (and I say this as one of proponents of FunctorM).

If it's in base package, then it's going to be shipped with newer
compilers, like GHC 6.6, right?

Best regards
Tomasz
_______________________________________________
Libraries mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re: PROPOSAL: classes for traversals

Jacques Carette
In reply to this post by Ross Paterson
This seems like a solid, worthwhile proposal to me as well.  In fact, I
will start using this in new code, regardless of its acceptance into the
library.
Jacques

Ross Paterson wrote:

>Conor McBride and I would like to propose some new classes for traversals
>of containers, based around applicative functors (the abstraction formerly
>known as idioms):
>
> http://www.soi.city.ac.uk/~ross/traversals/
>
>They are proposed for the base package, and would replace FunctorM.
>
>Comments most welcome.
>
>_______________________________________________
>Libraries mailing list
>[hidden email]
>http://www.haskell.org/mailman/listinfo/libraries
>  
>
_______________________________________________
Libraries mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re: PROPOSAL: classes for traversals

Ross Paterson
In reply to this post by Tomasz Zielonka
On Fri, Nov 18, 2005 at 02:24:41PM +0100, Tomasz Zielonka wrote:
> If it's in base package, then it's going to be shipped with newer
> compilers, like GHC 6.6, right?

That's the idea.  These modules are portable (as Data.Monoid recently
became portable), so they would work with all implementations.

_______________________________________________
Libraries mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re: PROPOSAL: classes for traversals

Bulat Ziganshin
In reply to this post by Ross Paterson
Hello Ross,

Friday, November 18, 2005, 2:05:37 PM, you wrote:

RP>         http://www.soi.city.ac.uk/~ross/traversals/
RP> Comments most welcome.

1) imho, it's better to change "Prelude." to "List." here:

instance Foldable [] where
        foldr = Prelude.foldr
        foldl = Prelude.foldl
        foldr1 = Prelude.foldr1
        foldl1 = Prelude.foldl1

and in other places where you use list functions listed in Prelude

2) i can try to make Template Haskell machinery to automatically
derive instances of Foldable and Traversable, using your examples
for Tree as sample

3)
-- If @f@ is also a 'Functor', define @('<$>') = 'fmap'@.
-- If it is also a 'Monad', define @'pure' = 'return'@ and @('<*>') = 'ap'@.

why you don't just define:

instance Monad m => Applicative m where
        pure = return
        (<*>) = ap


RP> They are proposed for the base package, and would replace FunctorM.

it is a beatiful contribution. but it doesn't work without definitions
for All, Any and so on :)

--
Best regards,
 Bulat                            mailto:[hidden email]



_______________________________________________
Libraries mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re: PROPOSAL: classes for traversals

Ross Paterson
On Sat, Nov 19, 2005 at 05:51:44PM +0300, Bulat Ziganshin wrote:
> -- If @f@ is also a 'Functor', define @('<$>') = 'fmap'@.
> -- If it is also a 'Monad', define @'pure' = 'return'@ and @('<*>') = 'ap'@.
>
> why you don't just define:
>
> instance Monad m => Applicative m where
>         pure = return
>         (<*>) = ap

Because that instance would overlap with all others.  As it is, these
classes are Haskell 98.  Better language support for superclasses would
be useful here, but is unavailable right now.

> RP> They are proposed for the base package, and would replace FunctorM.
>
> it is a beatiful contribution. but it doesn't work without definitions
> for All, Any and so on :)

I'm not sure I understand this one.  These types are defined in
Data.Monoid in CVS, and coming soon to a Haskell implementation near you.

_______________________________________________
Libraries mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re[2]: PROPOSAL: classes for traversals

Bulat Ziganshin
Hello Ross,

Monday, November 21, 2005, 1:09:26 PM, you wrote:

>> why you don't just define:
>>
>> instance Monad m => Applicative m where
>>         pure = return
>>         (<*>) = ap

RP> Because that instance would overlap with all others.  As it is, these
RP> classes are Haskell 98.  Better language support for superclasses would
RP> be useful here, but is unavailable right now.

with instances for [], IO and so on? but you can just omit them, they
just repeats this definition. or you think that some Monads will
require alternative definitions?

>> it is a beatiful contribution. but it doesn't work without definitions
>> for All, Any and so on :)

RP> I'm not sure I understand this one.  These types are defined in
RP> Data.Monoid in CVS, and coming soon to a Haskell implementation near you.

but not in ghc 6.4.1. btw, why you not wrote about this to main
Haskell list? imho this is enough important contribution to make all know
about this. and you are not answered about my TH suggestion


--
Best regards,
 Bulat                            mailto:[hidden email]



_______________________________________________
Libraries mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/libraries