module crossproduct import StdEnv ($) infixr 1;($) a b :== a b;(>>=) infixl 0;(>>=) a b = \ w -> (\ (x, w) -> b x w ) (a w);liftM m :== \ lst -> \ w -> (m lst, w); join del [x:xs]= (toString x) +++ del +++ (join del xs); join _ [] = ""; :: Elem= ElemChar Char | ElemStr String | ElemInt Int class toElem a where toElem :: a -> Elem instance toElem Int where toElem a = ElemInt a instance toElem Char where toElem a = ElemChar a instance toElem String where toElem a = ElemStr a instance toString Elem where toString (ElemInt a) = toString a toString (ElemStr a) = a toString (ElemChar a) = toString a Start w =snd ((stdio >>= liftM ( fwrites str) >>= fclose) w) where str = join "\n" $ map (join ",") $ crossProduct [] elems2 elems2 = [map toElem [0,1],map toElem ['ab'], map toElem ["Foo","Bar"]] crossProduct :: [Elem] [[Elem]] -> [[Elem]] crossProduct knil [[x:xs]:ys] = crossProduct [x:knil] ys ++ (crossProduct knil [xs:ys]) crossProduct knil [[]:ys] = [] crossProduct knil [] = [knil]