Added a few more helper functions to the Utils module

This commit is contained in:
Neil Brown 2008-01-25 16:12:20 +00:00
parent d2b427c268
commit 86b8185b1f
2 changed files with 9 additions and 1 deletions

View File

@ -401,7 +401,6 @@ genList :: (Int -> GenL a) -> Int -> GenL [a]
genList _ 0 = return [([],[])]
genList f n = (lift $ genNumsToTotal n) >>= mapM f >>= foldList
where
singleton x = [x]
foldList :: [[([Meta], a)]] -> StateT Id Gen [([Meta], [a])]
foldList [g] = comb1 singleton (return g)
foldList gs = return $ foldr foldX [] gs

View File

@ -275,3 +275,12 @@ showListCustom showFunc list = "[" ++ concat (intersperse "," (map showFunc list
showPairCustom :: (a -> String) -> (b -> String) -> (a,b) -> String
showPairCustom showA showB (a,b) = "(" ++ showA a ++ "," ++ showB b ++ ")"
singleton :: a -> [a]
singleton x = [x]
applyPair :: (a -> b) -> (a,a) -> (b,b)
applyPair f = transformPair f f
applyPairM :: Monad m => (a -> m b) -> (a,a) -> m (b,b)
applyPairM f = seqPair . transformPair f f