emgm-0.4: Extensible and Modular Generics for the Masses




Summary: Generic function thats transposes a value f (g a) to g (f a).

This is an interesting generic function since it uses multiple other generic functions: Crush, Enum, Map, and ZipWith. Notably, Map and ZipWith are required for definining the sum and product cases of the generic function. The others make the generic function easy to use.

NOTE: Be aware of the special case for empty values noted in the documentation of tranpose.



newtype Monad m => Transpose m f c b a Source

The type of a generic function that takes a generic value and non-generic container and returns the container filled with other generic values.




selTranspose :: a -> f c -> m (f b)


(Monad m, FRep2 Map f, FRep3 (ZipWith m) f) => Generic2 (Transpose m f c) 

transpose :: (Monad m, FRep (Crush [g a]) f, FRep2 (Transpose m g a) f) => f (g a) -> m (g (f a))Source

Transposes the structure of nested containers (types f and g). fail if the outermost container is empty, because there is no generic way to guarantee that both have unit constructors or, if they do, decide which one to choose. See transposeE for an alternative approach.

transposeE :: (Rep Enum (g (f a)), FRep (Crush [g a]) f, FRep2 (Transpose Maybe g a) f) => f (g a) -> g (f a)Source

A convenient version of transpose that returns the empty value on failure.