[Haskell-cafe] ANNOUNCE: tupleinstances-0.0.1

Diego Echeverri diegoeche at gmail.com
Tue Mar 16 00:39:01 EDT 2010


TupleInstances It's a really small library that provides
instances for Functor, Applicative, Foldable and Traversable for
tuples of the form (a,a...a). It uses newtypes to wrap the tuples
and Template Haskell to generate the code.

Here's an example of these instances in action:

example6 :: (Int, Int) -> [(Int, Int)]
example6 p = map unT $ liftA2 (+) (T2 p) <$> moves
         where moves = tail $ traverse (\x -> [0,x+1,x-1]) (pure 0 :: T2 Int)
-- > Result with (1,1): [(1,2),(1,0),(2,1),(2,2),(2,0),(0,1),(0,2),(0,0)]

More examples here: http://github.com/diegoeche/tupleinstances/raw/master/README

PS: This is also my first package uploaded to Hackage. I would
appreciate any feedback.

Best Regards,
Diego Echeverri

More information about the Haskell-Cafe mailing list