{-# LANGUAGE NoImplicitPrelude #-}
module Synthesizer.Causal.Cut where

import qualified Synthesizer.Causal.Process as Causal

import Control.Monad.Trans.State (StateT(StateT), )

import Data.Maybe.HT (toMaybe, )

import NumericPrelude.Numeric
import NumericPrelude.Base


{-# INLINE take #-}
take :: Int -> Causal.T a a
take :: forall a. Int -> T a a
take =
   forall a s b. (a -> StateT s Maybe b) -> s -> T a b
Causal.fromStateMaybe (\a
x ->
      forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
StateT (\Int
i -> forall a. Bool -> a -> Maybe a
toMaybe (Int
iforall a. Ord a => a -> a -> Bool
>Int
0) (a
x, forall a. Enum a => a -> a
pred Int
i)))