module TrieMap.Applicative(Id(..), (.:), (<.>), on, build) where

import Control.Monad
import Control.Applicative
import Data.Traversable (sequenceA)
import GHC.Exts (build)
import TrieMap.MapTypes

instance Applicative Id where
	pure = return
	(<*>) = ap

instance Monad Id where
	return = Id
	m >>= k = k (unId m)

(.:) :: (c -> d) -> (a -> b -> c) -> a -> b -> d
(.:) = (.) . (.)

(<.>) :: Functor f => (b -> c) -> (a -> f b) -> (a -> f c)
(<.>) = (.) . (<$>)

on :: (b -> b -> c) -> (a -> b) -> a -> a -> c
(f `on` g) x y = f (g x) (g y)

infixr 9 <.>
infixr 9 .:
infixr 8 `on`