--------------------------------------------------------------------------------
-- Copyright © 2011 National Institute of Aerospace / Galois, Inc.
--------------------------------------------------------------------------------

-- | Stream construction.

{-# LANGUAGE Safe #-}

module Copilot.Language.Operators.Temporal
  ( (++)
  , drop
  ) where

import Copilot.Core (Typed)
import Copilot.Language.Prelude
import Copilot.Language.Stream
import Prelude ()

--------------------------------------------------------------------------------

infixr 1 ++

(++) :: Typed a => [a] -> Stream a -> Stream a
++ :: [a] -> Stream a -> Stream a
(++) = ([a] -> Maybe (Stream Bool) -> Stream a -> Stream a
forall a.
Typed a =>
[a] -> Maybe (Stream Bool) -> Stream a -> Stream a
`Append` Maybe (Stream Bool)
forall a. Maybe a
Nothing)

drop :: Typed a => Int -> Stream a -> Stream a
drop :: Int -> Stream a -> Stream a
drop Int
0 Stream a
s             = Stream a
s
drop Int
_ ( Const a
j )   = a -> Stream a
forall a. Typed a => a -> Stream a
Const a
j
drop Int
i ( Drop  Int
j Stream a
s ) = Int -> Stream a -> Stream a
forall a. Typed a => Int -> Stream a -> Stream a
Drop (Int -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
i Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
j) Stream a
s
drop Int
i Stream a
s             = Int -> Stream a -> Stream a
forall a. Typed a => Int -> Stream a -> Stream a
Drop (Int -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
i)     Stream a
s