[Haskell-cafe] Re: Re-order type
Alexander Solla
ajs at 2piix.com
Sat Oct 9 19:30:20 EDT 2010
On Oct 9, 2010, at 4:17 PM, André Batista Martins wrote:
> If i want compose f and f1, i need to do a correct input to f1
> from the output of f.
> So i want one function to convert the output of "f" to input off
> "f!".
> In this case, we do f1 fst (snd (t,(t1,t2))) snd (snd (t,
> (t1,t2)))
> But i want do this automaticaly, for type of any two function. I
> search for the "glue".
You have to write the glue. There is no way to do it automatically,
for all cases. If there was a way to derive the glue, they wouldn't
be separate cases.
Type classes are a common approach for writing glue functions. The
Functor and Monad type classes are good examples. (And there is a
nice algebra of functors in the small category of functors, too) I
wrote a weird little functorial type class yesterday, specifically to
handle newtypes as functors over their underlying datatype/category.
class Transform obj functor where
transform :: (obj -> obj) -> functor -> functor
instance Functor f => Transform obj (f obj) where transform = fmap
More information about the Haskell-Cafe
mailing list