diff options
author | Ben Sima <ben@bsima.me> | 2020-12-09 13:26:00 -0500 |
---|---|---|
committer | Ben Sima <ben@bsima.me> | 2020-12-09 13:26:00 -0500 |
commit | 609a119e934630954773a2c53b6a8e51f66c17ca (patch) | |
tree | a130658669c92e657345c93e828471b7db070294 /Alpha.hs | |
parent | bdd2fa156d7158bca9f7da47915f55f06333484c (diff) |
Add Biz.Namespace library
Diffstat (limited to 'Alpha.hs')
-rw-r--r-- | Alpha.hs | 26 |
1 files changed, 24 insertions, 2 deletions
@@ -22,6 +22,10 @@ module Alpha module X, String, + -- * Composing + compose, + (.>), + -- * Applying (<|), (|>), @@ -64,6 +68,22 @@ import Protolude as X hiding (($), (&)) say :: Text -> IO () say = putText +-- | Composition +compose :: (a -> b) -> (b -> c) -> (a -> c) +compose f g x = g (f x) + +-- | Right-composition operator +infixl 9 .> + +(.>) :: (a -> b) -> (b -> c) -> (a -> c) +f .> g = compose f g + +-- | Left-composition operator +infixr 9 <. + +(<.) :: (b -> c) -> (a -> b) -> (a -> c) +g <. f = compose f g + -- | Alias for map, fmap, <$> (</) :: Functor f => (a -> b) -> f a -> f b f </ g = fmap f g @@ -76,13 +96,15 @@ f </ g = fmap f g -- | Normal function application. Do the right side, then pass the -- return value to the function on the left side. +infixr 0 <| + (<|) :: (a -> b) -> a -> b f <| g = f g -infixr 0 <| - -- | Reverse function application. Do the left side, then pass the -- return value to the function on the right side. +infixl 0 |> + (|>) :: a -> (a -> b) -> b f |> g = g f |