module Text.Boomerang.HStack
( (:-)(..)
, arg, hdTraverse, hdMap, hhead, htail, pop
) where
infixr 8 :-
data a :- b = a :- b deriving (Eq, Show)
pop :: (a -> b -> r) -> (a :- b) -> r
pop f (a :- b) = f a b
hhead :: (a :- b) -> a
hhead (a :- _) = a
htail :: (a :- b) -> b
htail (_ :- b) = b
hdTraverse :: Functor f => (a -> f b) -> a :- t -> f (b :- t)
hdTraverse f (a :- t) = fmap (:- t) (f a)
arg :: (ty -> r -> s) -> (a -> ty) -> (a :- r) -> s
arg c f = pop (c . f)
hdMap :: (a1 -> a2) -> (a1 :- b) -> (a2 :- b)
hdMap = arg (:-)