{-# LANGUAGE NoImplicitPrelude #-} -- | Commonly useful functions, a Prelude replacement. module Com.Simatime.Alpha ( -- * Re-export Protolude module X -- * Applying , (<|) , (|>) -- * Mapping , (/>) , () ) import Data.String import Data.Text ( Text ) import qualified Data.Text as Text import qualified Data.Text.Lazy as LazyText import qualified Prelude import Protolude as X -- | Debugging printf say :: Text -> IO () say msg = putStrLn msg -- $operators -- -- Operators have a pattern to their characters -- -- `|` normal function-level applications -- `/` indicates doing something inside a functor -- `<` and `>` indicate the direction in which values flow btw functions -- | Alias for map, fmap, <$> ( (a -> b) -> f a -> f b ( (a -> b) -> f0 (f1 a) -> f0 (f1 b) ( b) -> a -> b (<|) = ($) infixr 0 <| -- | Reverse function application. Do the left side, then pass the -- return value to the function on the right side. (|>) :: a -> (a -> b) -> b (|>) = (&) -- | Alias for <&>. Can be read as "and then". Basically does into a -- functor, does some computation, then returns the same kind of -- functor. Could also be defined as `f >>= return . g` (/>) :: Functor f => f a -> (a -> b) -> f b (/>) = (<&>) -- | Removes newlines from text. chomp :: Text -> Text chomp = Text.filter (/= '\n') -- | Removes newlines from lazy text. lchomp :: LazyText.Text -> LazyText.Text lchomp = LazyText.filter (/= '\n')