module ParenthesesLess where
import Control.Monad ( Monad((>>=), (>>)) )
import Prelude (($))
-- | Left-associative application with precedence 1, equivalent to `Prelude.$`.
--
-- It removes parentheses from nested applications:
--
-- >>> import Prelude
-- >>> import ParenthesesLess
-- >>> let s3 a b c = a + b + c
-- >>> s3 % 8 `div` 3 % 2 * 2 % 2 + 2 :: Int
-- 10
-- >>> s3 (8 `div` 3) (2 * 2) (2 + 2) :: Int
-- 10
--
-- A custom left-associative comparison can follow the chain:
--
-- >>> let { go = (==); infixl 1 `go` } in s3 % 8 `div` 3 % 2 * 2 % 2 + 2 `go` 10
-- True
(%) :: (a -> b) -> a -> b
(%) = ($)
infixl 0 %
(%%) :: (a -> b) -> a -> b
(%%) = ($)
infixl 1 %%
(%%%) :: (a -> b) -> a -> b
(%%%) = ($)
infixl 2 %%%
(%%%%) :: (a -> b) -> a -> b
(%%%%) = ($)
infixl 3 %%%%
-- | Unicode comma-like symbol alternative to `(%)`.
--
-- Cedilla symbol offers better visual perception.
--
-- >>> import Prelude
-- >>> import ParenthesesLess
-- >>> let s3 a b c = a + b + c
-- >>> s3 ¸ 8 `div` 3 ¸ 2 * 2 ¸ 2 + 2 :: Int
-- 10
-- >>> s3 (8 `div` 3) (2 * 2) (2 + 2) :: Int
-- 10
--
-- A custom left-associative comparison can follow the chain:
--
-- >>> let { go = (==); infixl 1 `go` } in s3 ¸ 8 `div` 3 ¸ 2 * 2 ¸ 2 + 2 `go` 10
-- True
(¸) :: (a -> b) -> a -> b
(¸) = ($)
infixl 0 ¸
(¸¸) :: (a -> b) -> a -> b
(¸¸) = ($)
infixl 1 ¸¸
(¸¸¸) :: (a -> b) -> a -> b
(¸¸¸) = ($)
infixl 2 ¸¸¸
(¸¸¸¸) :: (a -> b) -> a -> b
(¸¸¸¸) = ($)
infixl 3 ¸¸¸¸
(>>>) :: Monad m => m a -> m b -> m b
(>>>) = (>>)
infixl 2 >>>
(>>>=) :: Monad m => m a -> (a -> m b) -> m b
(>>>=) = (>>=)
infixl 2 >>>=
(>>>>) :: Monad m => m a -> m b -> m b
(>>>>) = (>>)
infixl 3 >>>>
(>>>>=) :: Monad m => m a -> (a -> m b) -> m b
(>>>>=) = (>>=)
infixl 3 >>>>=