module Pandora.Pattern.Functor.Alternative where

import Pandora.Pattern.Functor.Covariant (Covariant)

infixl 3 <+>

{- |
> When providing a new instance, you should ensure it satisfies the two laws:
> * Associativity of <+>: (x <+> y) <+> z ≡ x <+> (y <+> z)
> * Left-distributes <$> over <+>: f <$> (x <+> y) ≡ (f <$> x) <+> (f <$> y)
-}

class Covariant t => Alternative t where
	{-# MINIMAL (<+>) #-}
	-- | Infix version of 'alter'

	(<+>) :: t a -> t a -> t a
	-- | Prefix version of '<+>'
	alter :: t a -> t a -> t a
	alter t a
f t a
g = t a
f t a -> t a -> t a
forall (t :: * -> *) a. Alternative t => t a -> t a -> t a
<+> t a
g