{-# LANGUAGE NoImplicitPrelude #-}

module Precursor.Control.Functor
  ( Functor(..)
  , ($>)
  , (<$>)
  , void
  , (<&>)
  , (<-<)
  , (>->)
  ) where

import           Precursor.Control.Category
import           Data.Functor

infixl 1 <&>
-- | A flipped version of 'fmap'.
(<&>) :: Functor f => f a -> (a -> b) -> f b
x <&> f = fmap f x
{-# INLINE (<&>) #-}

infixl 1 <-<
-- | Arrow-like operator. Useful for chaining with the '<<<' and
-- 'Precursor.Control.Monad.<=<' combinators.
(<-<) :: Functor f => (b -> c) -> (a -> f b) -> a -> f c
g <-< f = fmap g . f

infixr 1 >->
-- | Arrow-like operator. Useful for chaining with the '>>>' and
-- 'Precursor.Control.Monad.>=>' combinators.
(>->) :: Functor f => (a -> f b) -> (b -> c) -> a -> f c
f >-> g = fmap g . f