"Rebox Package" or "To Hackage or not to Hackage"

Hi List, I've recently had a situation where I used the same pattern quite a bit while reducing and evaluating an AST. I quickly wrapped the operation in a package and stuck it on github. http://github.com/sw17ch/rebox/blob/master/src/Data/Rebox.hs I'm wondering two things: 1) Does any one recognize the pattern I'm using here as something with a different name? 2) Is this worth sticking on Hackage? It's trivial, but we have plenty of trivial concepts on Hackage (and it's not a bad thing). Any feedback would be great. /jve

Hi John,
I don't know if this is useful for you, but these are instances of
Cofunctor's comap. For example if we use TypeCompose package we have:
rebox f = unFlip . cofmap f . Flip
The rest are also Cofunctors. There are a few options. You can either
specify instances or use type combinators from category-extras or
TypeCompose packages. Basically (a -> a -> b) is curried composition
of diagonal Functor from Bifunctor (,) and Cofunctor (Flip (->) a)
etc.
It's interesting to know more about usage of the pattern for AST reduction.
Vitaliy
On Tue, Dec 8, 2009 at 9:37 PM, John Van Enk
Hi List, I've recently had a situation where I used the same pattern quite a bit while reducing and evaluating an AST. I quickly wrapped the operation in a package and stuck it on github. http://github.com/sw17ch/rebox/blob/master/src/Data/Rebox.hs I'm wondering two things: 1) Does any one recognize the pattern I'm using here as something with a different name? 2) Is this worth sticking on Hackage? It's trivial, but we have plenty of trivial concepts on Hackage (and it's not a bad thing). Any feedback would be great. /jve
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Am Dienstag, den 08.12.2009, 23:25 +0200 schrieb Vitaliy Akimov:
Hi John,
I don't know if this is useful for you, but these are instances of Cofunctor's comap. For example if we use TypeCompose package we have:
rebox f = unFlip . cofmap f . Flip
The rest are also Cofunctors. There are a few options. You can either specify instances or use type combinators from category-extras or TypeCompose packages. Basically (a -> a -> b) is curried composition of diagonal Functor from Bifunctor (,) and Cofunctor (Flip (->) a) etc.
You can also define them recursively: rebox0 :: (a -> b) -> c -> c rebox0 _ x = x reboxN :: ((a -> b) -> d -> e) -> (a -> b) -> (b -> d) -> a -> e reboxN reboxM un re = reboxM un . re . un rebox1 :: (a -> b) -> (b -> c) -> a -> c rebox1 = reboxN rebox0 rebox2 :: (a -> b) -> (b -> b -> c) -> a -> a -> c rebox2 = reboxN rebox1 rebox3 :: (a -> b) -> (b -> b -> b -> c) -> a -> a -> a -> c rebox3 = reboxN rebox2 rebox4 = reboxN rebox3 rebox5 = reboxN rebox4

On Tue, Dec 8, 2009 at 4:25 PM, Vitaliy Akimov
Hi John,
I don't know if this is useful for you, but these are instances of Cofunctor's comap. For example if we use TypeCompose package we have:
rebox f = unFlip . cofmap f . Flip
Alternately, rebox = flip (.)
--
Dave Menendez
participants (4)
-
David Menendez
-
Holger Siegel
-
John Van Enk
-
Vitaliy Akimov