module TypeMachine.Functions.Infix (
    -- * Intersection
    (<#|>),
    (<:#|>),
    (<#|:>),

    -- ** Flipped Intersection
    (<|#>),
    (<:|#>),
    (<|#:>),

    -- * Union
    (<#&>),
    (<:#&>),
    (<#&:>),

    -- ** Flipped Union
    (<&#>),
    (<:&#>),
    (<&#:>),
) where

import Language.Haskell.TH (Name)
import TypeMachine.Functions
import TypeMachine.TM
import TypeMachine.Type

-- | Alias to 'intersection'
(<#|>) :: Type -> Type -> TM Type
<#|> :: Type -> Type -> TM Type
(<#|>) = Type -> Type -> TM Type
intersection
{-# INLINE (<#|>) #-}

-- | Like '<#|>', but the first parameter is a name
(<:#|>) :: Name -> Type -> TM Type
Name
a <:#|> :: Name -> Type -> TM Type
<:#|> Type
b = Name -> TM Type
toType Name
a TM Type -> (Type -> TM Type) -> TM Type
forall a b.
WriterT [TypeMachineLog] Q a
-> (a -> WriterT [TypeMachineLog] Q b)
-> WriterT [TypeMachineLog] Q b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Type
a' -> Type
a' Type -> Type -> TM Type
<#|> Type
b

-- | Like '<#|>', but the second parameter is a name
(<#|:>) :: Type -> Name -> TM Type
Type
a <#|:> :: Type -> Name -> TM Type
<#|:> Name
b = Name -> TM Type
toType Name
b TM Type -> (Type -> TM Type) -> TM Type
forall a b.
WriterT [TypeMachineLog] Q a
-> (a -> WriterT [TypeMachineLog] Q b)
-> WriterT [TypeMachineLog] Q b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Type
b' -> Type
a Type -> Type -> TM Type
<#|> Type
b'

-- | Alias to 'intersection''
(<|#>) :: Type -> Type -> TM Type
<|#> :: Type -> Type -> TM Type
(<|#>) = Type -> Type -> TM Type
intersection'
{-# INLINE (<|#>) #-}

-- | Like '<|#>', but the first parameter is a name
(<:|#>) :: Name -> Type -> TM Type
Name
a <:|#> :: Name -> Type -> TM Type
<:|#> Type
b = Name -> TM Type
toType Name
a TM Type -> (Type -> TM Type) -> TM Type
forall a b.
WriterT [TypeMachineLog] Q a
-> (a -> WriterT [TypeMachineLog] Q b)
-> WriterT [TypeMachineLog] Q b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Type
a' -> Type
a' Type -> Type -> TM Type
<|#> Type
b

-- | Like '<|#>', but the second parameter is a name
(<|#:>) :: Type -> Name -> TM Type
Type
a <|#:> :: Type -> Name -> TM Type
<|#:> Name
b = Name -> TM Type
toType Name
b TM Type -> (Type -> TM Type) -> TM Type
forall a b.
WriterT [TypeMachineLog] Q a
-> (a -> WriterT [TypeMachineLog] Q b)
-> WriterT [TypeMachineLog] Q b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Type
b' -> Type
a Type -> Type -> TM Type
<|#> Type
b'

-- | Alias to 'union'
(<#&>) :: Type -> Type -> TM Type
<#&> :: Type -> Type -> TM Type
(<#&>) = Type -> Type -> TM Type
union
{-# INLINE (<#&>) #-}

-- | Like '<#&>', but the first parameter is a name
(<:#&>) :: Name -> Type -> TM Type
Name
a <:#&> :: Name -> Type -> TM Type
<:#&> Type
b = Name -> TM Type
toType Name
a TM Type -> (Type -> TM Type) -> TM Type
forall a b.
WriterT [TypeMachineLog] Q a
-> (a -> WriterT [TypeMachineLog] Q b)
-> WriterT [TypeMachineLog] Q b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Type
a' -> Type
a' Type -> Type -> TM Type
<#&> Type
b

-- | Like '<#&>', but the second parameter is a name
(<#&:>) :: Type -> Name -> TM Type
Type
a <#&:> :: Type -> Name -> TM Type
<#&:> Name
b = Name -> TM Type
toType Name
b TM Type -> (Type -> TM Type) -> TM Type
forall a b.
WriterT [TypeMachineLog] Q a
-> (a -> WriterT [TypeMachineLog] Q b)
-> WriterT [TypeMachineLog] Q b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Type
b' -> Type
a Type -> Type -> TM Type
<#&> Type
b'

-- | Alias to 'union''
(<&#>) :: Type -> Type -> TM Type
<&#> :: Type -> Type -> TM Type
(<&#>) = Type -> Type -> TM Type
union'
{-# INLINE (<&#>) #-}

-- | Like '<&#>', but the first parameter is a name
(<:&#>) :: Name -> Type -> TM Type
Name
a <:&#> :: Name -> Type -> TM Type
<:&#> Type
b = Name -> TM Type
toType Name
a TM Type -> (Type -> TM Type) -> TM Type
forall a b.
WriterT [TypeMachineLog] Q a
-> (a -> WriterT [TypeMachineLog] Q b)
-> WriterT [TypeMachineLog] Q b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Type
a' -> Type
a' Type -> Type -> TM Type
<&#> Type
b

-- | Like '<&#>', but the second parameter is a name
(<&#:>) :: Type -> Name -> TM Type
Type
a <&#:> :: Type -> Name -> TM Type
<&#:> Name
b = Name -> TM Type
toType Name
b TM Type -> (Type -> TM Type) -> TM Type
forall a b.
WriterT [TypeMachineLog] Q a
-> (a -> WriterT [TypeMachineLog] Q b)
-> WriterT [TypeMachineLog] Q b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Type
b' -> Type
a Type -> Type -> TM Type
<&#> Type
b'