{-# Language
        TypeFamilies,
        FlexibleInstances,
        FlexibleContexts #-}
module Csound.Control.Overload.Outs(
    Outs(..), onArg
) where

import Data.Kind(Type)

import Csound.Typed

onArg :: Outs b => (a -> b) -> (a -> SE (SigOuts b))
onArg :: forall b a. Outs b => (a -> b) -> a -> SE (SigOuts b)
onArg a -> b
f = b -> SE (SigOuts b)
forall a. Outs a => a -> SE (SigOuts a)
toOuts (b -> SE (SigOuts b)) -> (a -> b) -> a -> SE (SigOuts b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> b
f

class Sigs (SigOuts a) => Outs a where
    type SigOuts a :: Type
    toOuts :: a -> SE (SigOuts a)

instance Outs Sig where
  type SigOuts Sig = Sig
  toOuts :: Sig -> SE (SigOuts Sig)
toOuts = Sig -> SE Sig
Sig -> SE (SigOuts Sig)
forall a. a -> SE a
forall (m :: * -> *) a. Monad m => a -> m a
return

instance Outs (Sig, Sig) where
  type SigOuts (Sig, Sig) = (Sig, Sig)
  toOuts :: (Sig, Sig) -> SE (SigOuts (Sig, Sig))
toOuts = (Sig, Sig) -> SE (Sig, Sig)
(Sig, Sig) -> SE (SigOuts (Sig, Sig))
forall a. a -> SE a
forall (m :: * -> *) a. Monad m => a -> m a
return

instance Outs (Sig, Sig, Sig, Sig) where
  type SigOuts (Sig, Sig, Sig, Sig) = (Sig, Sig, Sig, Sig)
  toOuts :: (Sig, Sig, Sig, Sig) -> SE (SigOuts (Sig, Sig, Sig, Sig))
toOuts = (Sig, Sig, Sig, Sig) -> SE (Sig, Sig, Sig, Sig)
(Sig, Sig, Sig, Sig) -> SE (SigOuts (Sig, Sig, Sig, Sig))
forall a. a -> SE a
forall (m :: * -> *) a. Monad m => a -> m a
return

instance Outs (SE Sig) where
  type SigOuts (SE Sig) = Sig
  toOuts :: SE Sig -> SE (SigOuts (SE Sig))
toOuts = SE Sig -> SE Sig
SE Sig -> SE (SigOuts (SE Sig))
forall a. a -> a
id

instance Outs (SE (Sig, Sig)) where
  type SigOuts (SE (Sig, Sig)) = (Sig, Sig)
  toOuts :: SE (Sig, Sig) -> SE (SigOuts (SE (Sig, Sig)))
toOuts = SE (Sig, Sig) -> SE (Sig, Sig)
SE (Sig, Sig) -> SE (SigOuts (SE (Sig, Sig)))
forall a. a -> a
id

instance Outs (SE (Sig, Sig, Sig, Sig)) where
  type SigOuts (SE (Sig, Sig, Sig, Sig)) = (Sig, Sig, Sig, Sig)
  toOuts :: SE (Sig, Sig, Sig, Sig) -> SE (SigOuts (SE (Sig, Sig, Sig, Sig)))
toOuts = SE (Sig, Sig, Sig, Sig) -> SE (Sig, Sig, Sig, Sig)
SE (Sig, Sig, Sig, Sig) -> SE (SigOuts (SE (Sig, Sig, Sig, Sig)))
forall a. a -> a
id