diff options
Diffstat (limited to 'Alpha.hs')
-rw-r--r-- | Alpha.hs | 35 |
1 files changed, 27 insertions, 8 deletions
@@ -42,12 +42,17 @@ module Alpha (<%), (%>), - -- * inding + -- * Binding bind, (+>), -- * Bool don't, + (?>), + (?<), + (?:), + (?.), + (?+), -- * Text tshow, @@ -66,9 +71,6 @@ module Alpha -- * Data Validation require, - - -- * Debugging tools - say, ) where @@ -85,10 +87,6 @@ import qualified Prelude list :: a -> [a] list a = [a] --- | Debugging printf -say :: Text -> IO () -say = putText - -- | Composition compose :: (a -> b) -> (b -> c) -> (a -> c) compose f g x = g (f x) @@ -163,6 +161,27 @@ a +> b = a Prelude.>>= b infixl 1 +> +-- | If-then-else. wutcol +(?:) :: Bool -> (Bool -> p, Bool -> p) -> p +a ?: (f, g) = if a then f a else g a + +-- | Inverted if-then-else. wutdot +(?.) :: Bool -> (Bool -> p, Bool -> p) -> p +a ?. (g, f) = if a then f a else g a + +-- | Positive assertion. wutgar +(?>) :: Bool -> (Bool -> Text -> a) -> Text -> a +a ?> f = if a then f a else panic "wutgar failed" + +-- | Lisp-style cond. wutlus +(?+) :: t -> [(t -> Bool, p)] -> p +a ?+ ((p, v) : ls) = if p a then v else a ?+ ls +_ ?+ [] = panic "wutlus: empty cond list" + +-- | Negative assertion. wutgal +(?<) :: Bool -> (Bool -> Text -> a) -> Text -> a +a ?< f = if not a then f a else panic "wutgal failed" + -- | Removes newlines from text. chomp :: Text -> Text chomp = Text.filter (/= '\n') |