X-Git-Url: http://git.cielonegro.org/gitweb.cgi?a=blobdiff_plain;f=Rakka%2FUtils.hs;h=9eb667c115971c10d816f0176e8d9bda2b4a1632;hb=743f4a87fd557832ce67d6eb51749582820577c4;hp=cb77474553c42fee4f6cdcaf340a32a8db4e38a9;hpb=35f9c2ec3c1e81e42737c54f3f1a8230427691c6;p=Rakka.git diff --git a/Rakka/Utils.hs b/Rakka/Utils.hs index cb77474..9eb667c 100644 --- a/Rakka/Utils.hs +++ b/Rakka/Utils.hs @@ -1,8 +1,9 @@ module Rakka.Utils - ( parseYesOrNo + ( yesOrNo + , parseYesOrNo , maybeA - , defaultTo , deleteIfEmpty + , chomp ) where @@ -10,6 +11,11 @@ import Control.Arrow import Control.Arrow.ArrowList +yesOrNo :: Bool -> String +yesOrNo True = "yes" +yesOrNo False = "no" + + parseYesOrNo :: ArrowChoice a => a String Bool parseYesOrNo = proc str -> do case str of @@ -26,15 +32,12 @@ maybeA a = listA a (x:_) -> returnA -< Just x -defaultTo :: ArrowChoice a => b -> a (Maybe b) b -defaultTo def - = proc m -> case m of - Nothing -> returnA -< def - Just x -> returnA -< x - - deleteIfEmpty :: (ArrowList a, ArrowChoice a) => a String String deleteIfEmpty = proc str -> do case str of "" -> none -< () - _ -> returnA -< str \ No newline at end of file + _ -> returnA -< str + + +chomp :: String -> String +chomp = reverse . snd . break (/= '\n') . reverse