]> gitweb @ CieloNegro.org - Rakka.git/blobdiff - Rakka/Utils.hs
code relocation
[Rakka.git] / Rakka / Utils.hs
index cb77474553c42fee4f6cdcaf340a32a8db4e38a9..9eb667c115971c10d816f0176e8d9bda2b4a1632 100644 (file)
@@ -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