From 609a119e934630954773a2c53b6a8e51f66c17ca Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Wed, 9 Dec 2020 13:26:00 -0500 Subject: Add Biz.Namespace library --- Alpha.hs | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'Alpha.hs') diff --git a/Alpha.hs b/Alpha.hs index 5d53f71..5ced72d 100644 --- a/Alpha.hs +++ b/Alpha.hs @@ -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, <$> ( (a -> b) -> f a -> f b f 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 -- cgit v1.2.3