[Haskell-beginners] typeclass

Gesh gesh at gesh.uni.cx
Fri Mar 28 10:48:53 UTC 2014


On March 28, 2014 4:35:11 AM GMT+03:00, Dennis Raddle <dennis.raddle at gmail.com> wrote:
>If I write a function like this:
>
>f (x1,y1) (x2,y2) = (x1++x2,y1++y2)
>
>My understanding of typeclasses is just developing, but I notice this
>is a
>bit like "lifting" (++) into a tuple. Maybe there is some existing
>typeclass and a 2-tuple is already an instance of it? Like arrow?
>
>D
>
>
>------------------------------------------------------------------------
>
>_______________________________________________
>Beginners mailing list
>Beginners at haskell.org
>http://www.haskell.org/mailman/listinfo/beginners

Indeed. The (->) instance of Arrow exposes all sorts of nice combinators, such as:
(***) :: (a -> b) -> (c -> d) -> (a,c) -> (b,d)
(&&&) :: (a -> b) -> (a -> c) -> a -> (b,c)
(+++) :: (a -> b) -> (a' -> b') -> Either a a' -> Either b b'
(|||) :: (a -> c) -> (b -> c) -> Either a b -> c


More information about the Beginners mailing list