module Rakka.Utils
- ( parseYesOrNo
+ ( yesOrNo
+ , parseYesOrNo
, maybeA
- , defaultTo
, deleteIfEmpty
+ , chomp
)
where
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
(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