]> gitweb @ CieloNegro.org - Rakka.git/blobdiff - Rakka/Utils.hs
Implemented the outline command
[Rakka.git] / Rakka / Utils.hs
index 4da609cd48b0baf42d015c3975f2644a2190f2da..9f2873c9ae328d626d9679b2ac0c777750c1e50e 100644 (file)
@@ -1,9 +1,10 @@
 module Rakka.Utils
-    ( parseYesOrNo
+    ( yesOrNo
+    , parseYesOrNo
     , maybeA
-    , defaultTo
     , deleteIfEmpty
     , formatW3CDateTime
+    , chomp
     )
     where
 
@@ -13,6 +14,11 @@ import           System.Time
 import           Text.Printf
 
 
+yesOrNo :: Bool -> String
+yesOrNo True  = "yes"
+yesOrNo False = "no"
+
+
 parseYesOrNo :: ArrowChoice a => a String Bool
 parseYesOrNo 
     = proc str -> do case str of
@@ -29,13 +35,6 @@ 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
@@ -73,4 +72,8 @@ formatW3CDateTime time
             
       show2 :: Int -> String
       show2 n | n < 10    = '0':(show n)
-              | otherwise = show n
\ No newline at end of file
+              | otherwise = show n
+
+
+chomp :: String -> String
+chomp = reverse . snd . break (/= '\n') . reverse