-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | A Haskell-embedded DSL for monitoring hard real-time
--   distributed systems.
--   
--   The concrete syntax for Copilot.
--   
--   Copilot is a stream (i.e., infinite lists) domain-specific language
--   (DSL) in Haskell that compiles into embedded C. Copilot contains an
--   interpreter, multiple back-end compilers, and other verification
--   tools.
--   
--   A tutorial, examples, and other information are available at
--   <a>https://copilot-language.github.io</a>.
@package copilot-language
@version 3.19.1


-- | Reexports <tt>Prelude</tt> from package "base" hiding identifiers
--   redefined by Copilot.
module Copilot.Language.Prelude
data () => Int
data () => Word
class () => Eq a
class (Real a, Enum a) => Integral a
quot :: Integral a => a -> a -> a
rem :: Integral a => a -> a -> a
quotRem :: Integral a => a -> a -> (a, a)
divMod :: Integral a => a -> a -> (a, a)
toInteger :: Integral a => a -> Integer
class Eq a => Ord a
compare :: Ord a => a -> a -> Ordering
class Applicative m => Monad (m :: Type -> Type)
(>>=) :: Monad m => m a -> (a -> m b) -> m b
(>>) :: Monad m => m a -> m b -> m b
return :: Monad m => a -> m a
type String = [Char]
class Monad m => MonadFail (m :: Type -> Type)
fail :: MonadFail m => String -> m a
data () => Either a b
Left :: a -> Either a b
Right :: b -> Either a b
class () => Foldable (t :: Type -> Type)
foldMap :: (Foldable t, Monoid m) => (a -> m) -> t a -> m
foldr :: Foldable t => (a -> b -> b) -> b -> t a -> b
foldl :: Foldable t => (b -> a -> b) -> b -> t a -> b
foldr1 :: Foldable t => (a -> a -> a) -> t a -> a
foldl1 :: Foldable t => (a -> a -> a) -> t a -> a
null :: Foldable t => t a -> Bool
length :: Foldable t => t a -> Int
elem :: (Foldable t, Eq a) => a -> t a -> Bool
maximum :: (Foldable t, Ord a) => t a -> a
minimum :: (Foldable t, Ord a) => t a -> a
product :: (Foldable t, Num a) => t a -> a
class (Functor t, Foldable t) => Traversable (t :: Type -> Type)
traverse :: (Traversable t, Applicative f) => (a -> f b) -> t a -> f (t b)
sequenceA :: (Traversable t, Applicative f) => t (f a) -> f (t a)
mapM :: (Traversable t, Monad m) => (a -> m b) -> t a -> m (t b)
sequence :: (Traversable t, Monad m) => t (m a) -> m (t a)
class Functor f => Applicative (f :: Type -> Type)
pure :: Applicative f => a -> f a
(<*>) :: Applicative f => f (a -> b) -> f a -> f b
liftA2 :: Applicative f => (a -> b -> c) -> f a -> f b -> f c
(*>) :: Applicative f => f a -> f b -> f b
(<*) :: Applicative f => f a -> f b -> f a
class () => Functor (f :: Type -> Type)
fmap :: Functor f => (a -> b) -> f a -> f b
(<$) :: Functor f => a -> f b -> f a
class Semigroup a => Monoid a
mempty :: Monoid a => a
mappend :: Monoid a => a -> a -> a
mconcat :: Monoid a => [a] -> a
class () => Semigroup a
(<>) :: Semigroup a => a -> a -> a
class () => Bounded a
minBound :: Bounded a => a
maxBound :: Bounded a => a
class () => Enum a
succ :: Enum a => a -> a
pred :: Enum a => a -> a
toEnum :: Enum a => Int -> a
fromEnum :: Enum a => a -> Int
enumFrom :: Enum a => a -> [a]
enumFromThen :: Enum a => a -> a -> [a]
enumFromTo :: Enum a => a -> a -> [a]
enumFromThenTo :: Enum a => a -> a -> a -> [a]
class Fractional a => Floating a
pi :: Floating a => a
exp :: Floating a => a -> a
log :: Floating a => a -> a
sqrt :: Floating a => a -> a
(**) :: Floating a => a -> a -> a
logBase :: Floating a => a -> a -> a
sin :: Floating a => a -> a
cos :: Floating a => a -> a
tan :: Floating a => a -> a
asin :: Floating a => a -> a
acos :: Floating a => a -> a
atan :: Floating a => a -> a
sinh :: Floating a => a -> a
cosh :: Floating a => a -> a
tanh :: Floating a => a -> a
asinh :: Floating a => a -> a
acosh :: Floating a => a -> a
atanh :: Floating a => a -> a
class (RealFrac a, Floating a) => RealFloat a
floatRadix :: RealFloat a => a -> Integer
floatDigits :: RealFloat a => a -> Int
floatRange :: RealFloat a => a -> (Int, Int)
decodeFloat :: RealFloat a => a -> (Integer, Int)
encodeFloat :: RealFloat a => Integer -> Int -> a
exponent :: RealFloat a => a -> Int
significand :: RealFloat a => a -> a
scaleFloat :: RealFloat a => Int -> a -> a
isNaN :: RealFloat a => a -> Bool
isInfinite :: RealFloat a => a -> Bool
isDenormalized :: RealFloat a => a -> Bool
isNegativeZero :: RealFloat a => a -> Bool
isIEEE :: RealFloat a => a -> Bool
atan2 :: RealFloat a => a -> a -> a
type FilePath = String
type IOError = IOException
class () => Num a
(+) :: Num a => a -> a -> a
(-) :: Num a => a -> a -> a
(*) :: Num a => a -> a -> a
negate :: Num a => a -> a
abs :: Num a => a -> a
signum :: Num a => a -> a
fromInteger :: Num a => Integer -> a
class () => Read a
readsPrec :: Read a => Int -> ReadS a
readList :: Read a => ReadS [a]
class Num a => Fractional a
(/) :: Fractional a => a -> a -> a
recip :: Fractional a => a -> a
fromRational :: Fractional a => Rational -> a
type Rational = Ratio Integer
class (Num a, Ord a) => Real a
toRational :: Real a => a -> Rational
class (Real a, Fractional a) => RealFrac a
properFraction :: (RealFrac a, Integral b) => a -> (b, a)
truncate :: (RealFrac a, Integral b) => a -> b
round :: (RealFrac a, Integral b) => a -> b
ceiling :: (RealFrac a, Integral b) => a -> b
floor :: (RealFrac a, Integral b) => a -> b
class () => Show a
showsPrec :: Show a => Int -> a -> ShowS
show :: Show a => a -> String
showList :: Show a => [a] -> ShowS
type ShowS = String -> String
type ReadS a = String -> [(a, String)]
data () => Bool
False :: Bool
True :: Bool
data () => Char
data () => Double
data () => Float
data () => Ordering
LT :: Ordering
EQ :: Ordering
GT :: Ordering
data () => Maybe a
Nothing :: Maybe a
Just :: a -> Maybe a
class a ~# b => (a :: k) ~ (b :: k)
data () => Integer
data () => IO a
(.) :: (b -> c) -> (a -> b) -> a -> c
($) :: forall (r :: RuntimeRep) a (b :: TYPE r). (a -> b) -> a -> b
replicate :: Int -> a -> [a]
id :: a -> a
lookup :: Eq a => a -> [(a, b)] -> Maybe b
error :: forall (r :: RuntimeRep) (a :: TYPE r). HasCallStack => [Char] -> a
either :: (a -> c) -> (b -> c) -> Either a b -> c
all :: Foldable t => (a -> Bool) -> t a -> Bool
and :: Foldable t => t Bool -> Bool
any :: Foldable t => (a -> Bool) -> t a -> Bool
concat :: Foldable t => t [a] -> [a]
concatMap :: Foldable t => (a -> [b]) -> t a -> [b]
mapM_ :: (Foldable t, Monad m) => (a -> m b) -> t a -> m ()
notElem :: (Foldable t, Eq a) => a -> t a -> Bool
or :: Foldable t => t Bool -> Bool
sequence_ :: (Foldable t, Monad m) => t (m a) -> m ()
(<$>) :: Functor f => (a -> b) -> f a -> f b
maybe :: b -> (a -> b) -> Maybe a -> b
lines :: String -> [String]
unlines :: [String] -> String
unwords :: [String] -> String
words :: String -> [String]
curry :: ((a, b) -> c) -> a -> b -> c
fst :: (a, b) -> a
snd :: (a, b) -> b
uncurry :: (a -> b -> c) -> (a, b) -> c
($!) :: forall (r :: RuntimeRep) a (b :: TYPE r). (a -> b) -> a -> b
(=<<) :: Monad m => (a -> m b) -> m a -> m b
asTypeOf :: a -> a -> a
flip :: (a -> b -> c) -> b -> a -> c
map :: (a -> b) -> [a] -> [b]
otherwise :: Bool
errorWithoutStackTrace :: forall (r :: RuntimeRep) (a :: TYPE r). [Char] -> a
undefined :: forall (r :: RuntimeRep) (a :: TYPE r). HasCallStack => a
ioError :: IOError -> IO a
userError :: String -> IOError
break :: (a -> Bool) -> [a] -> ([a], [a])
dropWhile :: (a -> Bool) -> [a] -> [a]
filter :: (a -> Bool) -> [a] -> [a]
head :: HasCallStack => [a] -> a
init :: HasCallStack => [a] -> [a]
iterate :: (a -> a) -> a -> [a]
last :: HasCallStack => [a] -> a
repeat :: a -> [a]
reverse :: [a] -> [a]
scanl :: (b -> a -> b) -> b -> [a] -> [b]
scanl1 :: (a -> a -> a) -> [a] -> [a]
scanr :: (a -> b -> b) -> b -> [a] -> [b]
scanr1 :: (a -> a -> a) -> [a] -> [a]
span :: (a -> Bool) -> [a] -> ([a], [a])
splitAt :: Int -> [a] -> ([a], [a])
tail :: HasCallStack => [a] -> [a]
takeWhile :: (a -> Bool) -> [a] -> [a]
unzip :: [(a, b)] -> ([a], [b])
unzip3 :: [(a, b, c)] -> ([a], [b], [c])
zip :: [a] -> [b] -> [(a, b)]
zip3 :: [a] -> [b] -> [c] -> [(a, b, c)]
zipWith :: (a -> b -> c) -> [a] -> [b] -> [c]
zipWith3 :: (a -> b -> c -> d) -> [a] -> [b] -> [c] -> [d]
subtract :: Num a => a -> a -> a
lex :: ReadS String
readParen :: Bool -> ReadS a -> ReadS a
(^^) :: (Fractional a, Integral b) => a -> b -> a
even :: Integral a => a -> Bool
fromIntegral :: (Integral a, Num b) => a -> b
gcd :: Integral a => a -> a -> a
lcm :: Integral a => a -> a -> a
odd :: Integral a => a -> Bool
realToFrac :: (Real a, Fractional b) => a -> b
showChar :: Char -> ShowS
showParen :: Bool -> ShowS -> ShowS
showString :: String -> ShowS
shows :: Show a => a -> ShowS
appendFile :: FilePath -> String -> IO ()
getChar :: IO Char
getContents :: IO String
getLine :: IO String
interact :: (String -> String) -> IO ()
print :: Show a => a -> IO ()
putChar :: Char -> IO ()
putStr :: String -> IO ()
putStrLn :: String -> IO ()
readFile :: FilePath -> IO String
readIO :: Read a => String -> IO a
readLn :: Read a => IO a
writeFile :: FilePath -> String -> IO ()
read :: Read a => String -> a
reads :: Read a => ReadS a
seq :: forall {r :: RuntimeRep} a (b :: TYPE r). a -> b -> b


-- | Abstract syntax for streams and operators.
module Copilot.Language.Stream

-- | A stream in Copilot is an infinite succession of values of the same
--   type.
--   
--   Streams can be built using simple primities (e.g., <a>Const</a>), by
--   applying step-wise (e.g., <a>Op1</a>) or temporal transformations
--   (e.g., <a>Append</a>, <a>Drop</a>) to streams, or by combining
--   existing streams to form new streams (e.g., <a>Op2</a>, <a>Op3</a>).
data Stream :: * -> *
[Append] :: Typed a => [a] -> Maybe (Stream Bool) -> Stream a -> Stream a
[Const] :: Typed a => a -> Stream a
[Drop] :: Typed a => Int -> Stream a -> Stream a
[Extern] :: Typed a => String -> Maybe [a] -> Stream a
[Local] :: (Typed a, Typed b) => Stream a -> (Stream a -> Stream b) -> Stream b
[Var] :: Typed a => String -> Stream a
[Op1] :: (Typed a, Typed b) => Op1 a b -> Stream a -> Stream b
[Op2] :: (Typed a, Typed b, Typed c) => Op2 a b c -> Stream a -> Stream b -> Stream c
[Op3] :: (Typed a, Typed b, Typed c, Typed d) => Op3 a b c d -> Stream a -> Stream b -> Stream c -> Stream d
[Label] :: Typed a => String -> Stream a -> Stream a

-- | Point-wise application of <tt>ceiling</tt> to a stream.
--   
--   Unlike the Haskell variant of this function, this variant takes and
--   returns two streams of the same type. Use a casting function to
--   convert the result to an intergral type of your choice.
--   
--   Note that the result can be too big (or, if negative, too small) for
--   that type (see the man page of <tt>ceil</tt> for details), so you must
--   check that the value fits in the desired integral type before casting
--   it.
--   
--   This definition clashes with one in <a>RealFrac</a> in Haskell's
--   Prelude, re-exported from <tt>Language.Copilot</tt>, so you need to
--   import this module qualified to use this function.
ceiling :: (Typed a, RealFrac a) => Stream a -> Stream a

-- | Point-wise application of <tt>floor</tt> to a stream.
--   
--   Unlike the Haskell variant of this function, this variant takes and
--   returns two streams of the same type. Use a casting function to
--   convert the result to an intergral type of your choice.
--   
--   Note that the result can be too big (or, if negative, too small) for
--   that type (see the man page of <tt>floor</tt> for details), so you
--   must check that the value fits in the desired integral type before
--   casting it.
--   
--   This definition clashes with one in <a>RealFrac</a> in Haskell's
--   Prelude, re-exported from <tt>Language.Copilot</tt>, so you need to
--   import this module qualified to use this function.
floor :: (Typed a, RealFrac a) => Stream a -> Stream a

-- | Point-wise application of <tt>atan2</tt> to the values of two streams.
--   
--   For each pair of real floating-point samples <tt>x</tt> and
--   <tt>y</tt>, one from each stream, <tt>atan2</tt> computes the angle of
--   the vector from <tt>(0, 0)</tt> to the point <tt>(x, y)</tt>.
--   
--   This definition clashes with one in <a>RealFloat</a> in Haskell's
--   Prelude, re-exported from <tt>Language.Copilot</tt>, so you need to
--   import this module qualified to use this function.
atan2 :: (Typed a, RealFloat a) => Stream a -> Stream a -> Stream a
instance GHC.Show.Show (Copilot.Language.Stream.Stream a)
instance GHC.Classes.Eq (Copilot.Language.Stream.Stream a)
instance (Copilot.Core.Type.Typed a, GHC.Classes.Eq a, GHC.Num.Num a) => GHC.Num.Num (Copilot.Language.Stream.Stream a)
instance (Copilot.Core.Type.Typed a, GHC.Classes.Eq a, GHC.Real.Fractional a) => GHC.Real.Fractional (Copilot.Language.Stream.Stream a)
instance (Copilot.Core.Type.Typed a, GHC.Classes.Eq a, GHC.Float.Floating a) => GHC.Float.Floating (Copilot.Language.Stream.Stream a)


-- | Copilot specifications consistute the main declaration of Copilot
--   modules.
--   
--   A specification normally contains the association between streams to
--   monitor and their handling functions, or streams to observe, or a
--   theorem that must be proved.
--   
--   In order to be executed, <a>Spec</a>s must be turned into Copilot Core
--   (see <tt>Reify</tt>) and either simulated or converted into C99 code
--   to be executed.
module Copilot.Language.Spec

-- | A specification is a list of declarations of triggers, observers,
--   properties and theorems.
--   
--   Specifications are normally declared in monadic style, for example:
--   
--   <pre>
--   monitor1 :: Stream Bool
--   monitor1 = [False] ++ not monitor1
--   
--   counter :: Stream Int32
--   counter = [0] ++ not counter
--   
--   spec :: Spec
--   spec = do
--     trigger "handler_1" monitor1 []
--     trigger "handler_2" (counter &gt; 10) [arg counter]
--   </pre>
type Spec = Writer [SpecItem] ()

-- | An action in a specification (e.g., a declaration) that returns a
--   value that can be used in subsequent actions.
type Spec' a = Writer [SpecItem] a

-- | Return the complete list of declarations inside a <a>Spec</a> or
--   <a>Spec'</a>.
--   
--   The word run in this function is unrelated to running the underlying
--   specifications or monitors, and is merely related to the monad defined
--   by a <a>Spec</a>
runSpec :: Spec' a -> [SpecItem]

-- | An item of a Copilot specification.
data SpecItem

-- | An observer, representing a stream that we observe during execution at
--   every sample.
data Observer
[Observer] :: Typed a => String -> Stream a -> Observer

-- | Define a new observer as part of a specification. This allows someone
--   to print the value at every iteration during interpretation. Observers
--   do not have any functionality outside the interpreter.
observer :: Typed a => String -> Stream a -> Spec

-- | Filter a list of spec items to keep only the observers.
observers :: [SpecItem] -> [Observer]

-- | A trigger, representing a function we execute when a boolean stream
--   becomes true at a sample.
data Trigger
[Trigger] :: Name -> Stream Bool -> [Arg] -> Trigger

-- | Define a new trigger as part of a specification. A trigger declares
--   which external function, or handler, will be called when a guard
--   defined by a boolean stream becomes true.
trigger :: String -> Stream Bool -> [Arg] -> Spec

-- | Filter a list of spec items to keep only the triggers.
triggers :: [SpecItem] -> [Trigger]

-- | Construct a function argument from a stream.
--   
--   <a>Arg</a>s can be used to pass arguments to handlers or trigger
--   functions, to provide additional information to monitor handlers in
--   order to address property violations. At any given point (e.g., when
--   the trigger must be called due to a violation), the arguments passed
--   using <a>arg</a> will contain the current samples of the given
--   streams.
arg :: Typed a => Stream a -> Arg

-- | Wrapper to use <a>Stream</a>s as arguments to triggers.
data Arg
[Arg] :: Typed a => Stream a -> Arg

-- | A property, representing a boolean stream that is existentially or
--   universally quantified over time.
data Property
[Property] :: String -> Stream Bool -> Property

-- | A proposition, representing the quantification of a boolean streams
--   over time.
data Prop a
[Forall] :: Stream Bool -> Prop Universal
[Exists] :: Stream Bool -> Prop Existential

-- | A proposition, representing a boolean stream that is existentially or
--   universally quantified over time, as part of a specification.
--   
--   This function returns, in the monadic context, a reference to the
--   proposition.
prop :: String -> Prop a -> Writer [SpecItem] (PropRef a)

-- | Filter a list of spec items to keep only the properties.
properties :: [SpecItem] -> [Property]

-- | A theorem, or proposition together with a proof.
--   
--   This function returns, in the monadic context, a reference to the
--   proposition.
theorem :: String -> Prop a -> Proof a -> Writer [SpecItem] (PropRef a)

-- | Filter a list of spec items to keep only the theorems.
theorems :: [SpecItem] -> [(Property, UProof)]

-- | Universal quantification of boolean streams over time.
forAll :: Stream Bool -> Prop Universal

-- | Universal quantification of boolean streams over time.

-- | <i>Deprecated: Use forAll instead.</i>
forall :: Stream Bool -> Prop Universal

-- | Existential quantification of boolean streams over time.
exists :: Stream Bool -> Prop Existential

-- | Extract the underlying stream from a quantified proposition.
extractProp :: Prop a -> Stream Bool
data () => Universal
data () => Existential


-- | Temporal stream transformations.
module Copilot.Language.Operators.Temporal

-- | Prepend a fixed number of samples to a stream.
--   
--   The elements to be appended at the beginning of the stream must be
--   limited, that is, the list must have finite length.
--   
--   Prepending elements to a stream may increase the memory requirements
--   of the generated programs (which now must hold the same number of
--   elements in memory for future processing).
(++) :: Typed a => [a] -> Stream a -> Stream a
infixr 1 ++

-- | Drop a number of samples from a stream.
--   
--   The elements must be realizable at the present time to be able to drop
--   elements. For most kinds of streams, you cannot drop elements without
--   prepending an equal or greater number of elements to them first, as it
--   could result in undefined samples.
drop :: Typed a => Int -> Stream a -> Stream a


-- | Combinators to deal with streams carrying structs.
module Copilot.Language.Operators.Struct

-- | Create a stream that carries a field of a struct in another stream.
--   
--   This function implements a projection of a field of a struct over
--   time. For example, if a struct of type <tt>T</tt> has two fields,
--   <tt>t1</tt> of type <tt>Int</tt> and <tt>t2</tt> of type
--   <tt>Word8</tt>, and <tt>s</tt> is a stream of type <tt>Stream T</tt>,
--   then <tt>s # t2</tt> has type <tt>Stream Word8</tt> and contains the
--   values of the <tt>t2</tt> field of the structs in <tt>s</tt> at any
--   point in time.
(#) :: (KnownSymbol s, Typed t, Typed a, Struct a) => Stream a -> (a -> Field s t) -> Stream t


-- | Comparison operators applied point-wise on streams.
module Copilot.Language.Operators.Ord

-- | Compare two streams point-wise for order.
--   
--   The output stream contains the value True at a point in time if the
--   element in the first stream is smaller or equal than the element in
--   the second stream at that point in time, and False otherwise.
(<=) :: (Ord a, Typed a) => Stream a -> Stream a -> Stream Bool

-- | Compare two streams point-wise for order.
--   
--   The output stream contains the value True at a point in time if the
--   element in the first stream is greater or equal than the element in
--   the second stream at that point in time, and False otherwise.
(>=) :: (Ord a, Typed a) => Stream a -> Stream a -> Stream Bool

-- | Compare two streams point-wise for order.
--   
--   The output stream contains the value True at a point in time if the
--   element in the first stream is smaller than the element in the second
--   stream at that point in time, and False otherwise.
(<) :: (Ord a, Typed a) => Stream a -> Stream a -> Stream Bool

-- | Compare two streams point-wise for order.
--   
--   The output stream contains the value True at a point in time if the
--   element in the first stream is greater than the element in the second
--   stream at that point in time, and False otherwise.
(>) :: (Ord a, Typed a) => Stream a -> Stream a -> Stream Bool


-- | Pick values from one of two streams, depending whether a condition is
--   true or false.
module Copilot.Language.Operators.Mux

-- | Convenient synonym for <a>ifThenElse</a>.
mux :: Typed a => Stream Bool -> Stream a -> Stream a -> Stream a

-- | If-then-else applied point-wise to three streams (a condition stream,
--   a then-branch stream, and an else-branch stream).
--   
--   Produce a stream that, at any point in time, if the value of the first
--   stream at that point is true, contains the value in the second stream
--   at that time, otherwise it contains the value in the third stream.
ifThenElse :: Typed a => Stream Bool -> Stream a -> Stream a -> Stream a


-- | Let expressions.
--   
--   Although Copilot is a DSL embedded in Haskell and Haskell does support
--   let expressions, we want Copilot to be able to implement sharing, to
--   detect when the same stream is being used in multiple places in a
--   specification and avoid recomputing it unnecessarily.
module Copilot.Language.Operators.Local

-- | Let expressions.
--   
--   Create a stream that results from applying a stream to a function on
--   streams. Standard usage would be similar to Haskell's let. See the
--   following example, where <tt>stream1</tt>, <tt>stream2</tt> and
--   <tt>s</tt> are all streams carrying values of some numeric type:
--   
--   <pre>
--   expression = local (stream1 + stream2) $ \s -&gt;
--                (s &gt;= 0 &amp;&amp; s &lt;= 10)
--   
--   </pre>
local :: (Typed a, Typed b) => Stream a -> (Stream a -> Stream b) -> Stream b


-- | Label a stream with additional information.
module Copilot.Language.Operators.Label

-- | This function allows you to label a stream with a tag, which can be
--   used by different backends to provide additional information either in
--   error messages or in the generated code (e.g., for traceability
--   purposes).
--   
--   Semantically, a labelled stream is just the stream inside it. The use
--   of label should not affect the observable behavior of the monitor, and
--   how it is used in the code generated is a decision specific to each
--   backend.
label :: Typed a => String -> Stream a -> Stream a


-- | Primitives to build streams connected to external variables.
module Copilot.Language.Operators.Extern

-- | Create a stream populated by an external global variable.
--   
--   The Copilot compiler does not check that the type is correct. If the
--   list given as second argument does not constrain the type of the
--   values carried by the stream, this primitive stream building function
--   will match any stream of any type, which is potentially dangerous if
--   the global variable mentioned has a different type. We rely on the
--   compiler used with the generated code to detect type errors of this
--   kind.
extern :: Typed a => String -> Maybe [a] -> Stream a

-- | Create a stream carrying values of type Bool, populated by an external
--   global variable.
externB :: String -> Maybe [Bool] -> Stream Bool

-- | Create a stream carrying values of type Word8, populated by an
--   external global variable.
externW8 :: String -> Maybe [Word8] -> Stream Word8

-- | Create a stream carrying values of type Word16, populated by an
--   external global variable.
externW16 :: String -> Maybe [Word16] -> Stream Word16

-- | Create a stream carrying values of type Word32, populated by an
--   external global variable.
externW32 :: String -> Maybe [Word32] -> Stream Word32

-- | Create a stream carrying values of type Word64, populated by an
--   external global variable.
externW64 :: String -> Maybe [Word64] -> Stream Word64

-- | Create a stream carrying values of type Int8, populated by an external
--   global variable.
externI8 :: String -> Maybe [Int8] -> Stream Int8

-- | Create a stream carrying values of type Int16, populated by an
--   external global variable.
externI16 :: String -> Maybe [Int16] -> Stream Int16

-- | Create a stream carrying values of type Int32, populated by an
--   external global variable.
externI32 :: String -> Maybe [Int32] -> Stream Int32

-- | Create a stream carrying values of type Int64, populated by an
--   external global variable.
externI64 :: String -> Maybe [Int64] -> Stream Int64

-- | Create a stream carrying values of type Float, populated by an
--   external global variable.
externF :: String -> Maybe [Float] -> Stream Float

-- | Create a stream carrying values of type Double, populated by an
--   external global variable.
externD :: String -> Maybe [Double] -> Stream Double


-- | Equality applied point-wise on streams.
module Copilot.Language.Operators.Eq

-- | Compare two streams point-wise for equality.
--   
--   The output stream contains the value True at a point in time if both
--   argument streams contain the same value at that point in time.
(==) :: (Eq a, Typed a) => Stream a -> Stream a -> Stream Bool

-- | Compare two streams point-wise for inequality.
--   
--   The output stream contains the value True at a point in time if both
--   argument streams contain different values at that point in time.
(/=) :: (Eq a, Typed a) => Stream a -> Stream a -> Stream Bool


-- | Primitives to build constant streams.
module Copilot.Language.Operators.Constant

-- | Create a constant stream that is equal to the given argument, at any
--   point in time.
constant :: Typed a => a -> Stream a

-- | Create a constant stream carrying values of type <a>Bool</a> that is
--   equal to the given argument, at any point in time.
constB :: Bool -> Stream Bool

-- | Create a constant stream carrying values of type <a>Word8</a> that is
--   equal to the given argument, at any point in time.
constW8 :: Word8 -> Stream Word8

-- | Create a constant stream carrying values of type <a>Word16</a> that is
--   equal to the given argument, at any point in time.
constW16 :: Word16 -> Stream Word16

-- | Create a constant stream carrying values of type <a>Word32</a> that is
--   equal to the given argument, at any point in time.
constW32 :: Word32 -> Stream Word32

-- | Create a constant stream carrying values of type <a>Word64</a> that is
--   equal to the given argument, at any point in time.
constW64 :: Word64 -> Stream Word64

-- | Create a constant stream carrying values of type <a>Int8</a> that is
--   equal to the given argument, at any point in time.
constI8 :: Int8 -> Stream Int8

-- | Create a constant stream carrying values of type <a>Int16</a> that is
--   equal to the given argument, at any point in time.
constI16 :: Int16 -> Stream Int16

-- | Create a constant stream carrying values of type <a>Int32</a> that is
--   equal to the given argument, at any point in time.
constI32 :: Int32 -> Stream Int32

-- | Create a constant stream carrying values of type <a>Int64</a> that is
--   equal to the given argument, at any point in time.
constI64 :: Int64 -> Stream Int64

-- | Create a constant stream carrying values of type <a>Float</a> that is
--   equal to the given argument, at any point in time.
constF :: Float -> Stream Float

-- | Create a constant stream carrying values of type <a>Double</a> that is
--   equal to the given argument, at any point in time.
constD :: Double -> Stream Double


-- | Type-safe casting operators.
module Copilot.Language.Operators.Cast

-- | Perform a safe cast from <tt>Stream a</tt> to <tt>Stream b</tt>.
cast :: (Cast a b, Typed a, Typed b) => Stream a -> Stream b

-- | Perform an unsafe cast from <tt>Stream a</tt> to <tt>Stream b</tt>.
unsafeCast :: (UnsafeCast a b, Typed a, Typed b) => Stream a -> Stream b

-- | Class to capture casting between types for which it can be performed
--   safely.
class Cast a b

-- | Class to capture casting between types for which casting may be unsafe
--   and/or result in a loss of precision or information.
class UnsafeCast a b
instance Copilot.Language.Operators.Cast.UnsafeCast GHC.Word.Word64 GHC.Word.Word32
instance Copilot.Language.Operators.Cast.UnsafeCast GHC.Word.Word64 GHC.Word.Word16
instance Copilot.Language.Operators.Cast.UnsafeCast GHC.Word.Word64 GHC.Word.Word8
instance Copilot.Language.Operators.Cast.UnsafeCast GHC.Word.Word32 GHC.Word.Word16
instance Copilot.Language.Operators.Cast.UnsafeCast GHC.Word.Word32 GHC.Word.Word8
instance Copilot.Language.Operators.Cast.UnsafeCast GHC.Word.Word16 GHC.Word.Word8
instance Copilot.Language.Operators.Cast.UnsafeCast GHC.Int.Int64 GHC.Int.Int32
instance Copilot.Language.Operators.Cast.UnsafeCast GHC.Int.Int64 GHC.Int.Int16
instance Copilot.Language.Operators.Cast.UnsafeCast GHC.Int.Int64 GHC.Int.Int8
instance Copilot.Language.Operators.Cast.UnsafeCast GHC.Int.Int32 GHC.Int.Int16
instance Copilot.Language.Operators.Cast.UnsafeCast GHC.Int.Int32 GHC.Int.Int8
instance Copilot.Language.Operators.Cast.UnsafeCast GHC.Int.Int16 GHC.Int.Int8
instance Copilot.Language.Operators.Cast.UnsafeCast GHC.Int.Int64 GHC.Types.Float
instance Copilot.Language.Operators.Cast.UnsafeCast GHC.Int.Int32 GHC.Types.Float
instance Copilot.Language.Operators.Cast.UnsafeCast GHC.Int.Int16 GHC.Types.Float
instance Copilot.Language.Operators.Cast.UnsafeCast GHC.Int.Int8 GHC.Types.Float
instance Copilot.Language.Operators.Cast.UnsafeCast GHC.Int.Int64 GHC.Types.Double
instance Copilot.Language.Operators.Cast.UnsafeCast GHC.Int.Int32 GHC.Types.Double
instance Copilot.Language.Operators.Cast.UnsafeCast GHC.Int.Int16 GHC.Types.Double
instance Copilot.Language.Operators.Cast.UnsafeCast GHC.Int.Int8 GHC.Types.Double
instance Copilot.Language.Operators.Cast.UnsafeCast GHC.Word.Word64 GHC.Types.Float
instance Copilot.Language.Operators.Cast.UnsafeCast GHC.Word.Word32 GHC.Types.Float
instance Copilot.Language.Operators.Cast.UnsafeCast GHC.Word.Word16 GHC.Types.Float
instance Copilot.Language.Operators.Cast.UnsafeCast GHC.Word.Word8 GHC.Types.Float
instance Copilot.Language.Operators.Cast.UnsafeCast GHC.Word.Word64 GHC.Types.Double
instance Copilot.Language.Operators.Cast.UnsafeCast GHC.Word.Word32 GHC.Types.Double
instance Copilot.Language.Operators.Cast.UnsafeCast GHC.Word.Word16 GHC.Types.Double
instance Copilot.Language.Operators.Cast.UnsafeCast GHC.Word.Word8 GHC.Types.Double
instance Copilot.Language.Operators.Cast.UnsafeCast GHC.Word.Word64 GHC.Int.Int64
instance Copilot.Language.Operators.Cast.UnsafeCast GHC.Word.Word32 GHC.Int.Int32
instance Copilot.Language.Operators.Cast.UnsafeCast GHC.Word.Word16 GHC.Int.Int16
instance Copilot.Language.Operators.Cast.UnsafeCast GHC.Word.Word8 GHC.Int.Int8
instance Copilot.Language.Operators.Cast.UnsafeCast GHC.Int.Int64 GHC.Word.Word64
instance Copilot.Language.Operators.Cast.UnsafeCast GHC.Int.Int32 GHC.Word.Word32
instance Copilot.Language.Operators.Cast.UnsafeCast GHC.Int.Int16 GHC.Word.Word16
instance Copilot.Language.Operators.Cast.UnsafeCast GHC.Int.Int8 GHC.Word.Word8
instance Copilot.Language.Operators.Cast.Cast GHC.Types.Bool GHC.Types.Bool
instance Copilot.Language.Operators.Cast.Cast GHC.Types.Bool GHC.Word.Word8
instance Copilot.Language.Operators.Cast.Cast GHC.Types.Bool GHC.Word.Word16
instance Copilot.Language.Operators.Cast.Cast GHC.Types.Bool GHC.Word.Word32
instance Copilot.Language.Operators.Cast.Cast GHC.Types.Bool GHC.Word.Word64
instance Copilot.Language.Operators.Cast.Cast GHC.Types.Bool GHC.Int.Int8
instance Copilot.Language.Operators.Cast.Cast GHC.Types.Bool GHC.Int.Int16
instance Copilot.Language.Operators.Cast.Cast GHC.Types.Bool GHC.Int.Int32
instance Copilot.Language.Operators.Cast.Cast GHC.Types.Bool GHC.Int.Int64
instance Copilot.Language.Operators.Cast.Cast GHC.Word.Word8 GHC.Word.Word8
instance Copilot.Language.Operators.Cast.Cast GHC.Word.Word8 GHC.Word.Word16
instance Copilot.Language.Operators.Cast.Cast GHC.Word.Word8 GHC.Word.Word32
instance Copilot.Language.Operators.Cast.Cast GHC.Word.Word8 GHC.Word.Word64
instance Copilot.Language.Operators.Cast.Cast GHC.Word.Word8 GHC.Int.Int16
instance Copilot.Language.Operators.Cast.Cast GHC.Word.Word8 GHC.Int.Int32
instance Copilot.Language.Operators.Cast.Cast GHC.Word.Word8 GHC.Int.Int64
instance Copilot.Language.Operators.Cast.Cast GHC.Word.Word16 GHC.Word.Word16
instance Copilot.Language.Operators.Cast.Cast GHC.Word.Word16 GHC.Word.Word32
instance Copilot.Language.Operators.Cast.Cast GHC.Word.Word16 GHC.Word.Word64
instance Copilot.Language.Operators.Cast.Cast GHC.Word.Word16 GHC.Int.Int32
instance Copilot.Language.Operators.Cast.Cast GHC.Word.Word16 GHC.Int.Int64
instance Copilot.Language.Operators.Cast.Cast GHC.Word.Word32 GHC.Word.Word32
instance Copilot.Language.Operators.Cast.Cast GHC.Word.Word32 GHC.Word.Word64
instance Copilot.Language.Operators.Cast.Cast GHC.Word.Word32 GHC.Int.Int64
instance Copilot.Language.Operators.Cast.Cast GHC.Word.Word64 GHC.Word.Word64
instance Copilot.Language.Operators.Cast.Cast GHC.Int.Int8 GHC.Int.Int8
instance Copilot.Language.Operators.Cast.Cast GHC.Int.Int8 GHC.Int.Int16
instance Copilot.Language.Operators.Cast.Cast GHC.Int.Int8 GHC.Int.Int32
instance Copilot.Language.Operators.Cast.Cast GHC.Int.Int8 GHC.Int.Int64
instance Copilot.Language.Operators.Cast.Cast GHC.Int.Int16 GHC.Int.Int16
instance Copilot.Language.Operators.Cast.Cast GHC.Int.Int16 GHC.Int.Int32
instance Copilot.Language.Operators.Cast.Cast GHC.Int.Int16 GHC.Int.Int64
instance Copilot.Language.Operators.Cast.Cast GHC.Int.Int32 GHC.Int.Int32
instance Copilot.Language.Operators.Cast.Cast GHC.Int.Int32 GHC.Int.Int64
instance Copilot.Language.Operators.Cast.Cast GHC.Int.Int64 GHC.Int.Int64


-- | Boolean operators applied point-wise to streams.
module Copilot.Language.Operators.Boolean

-- | Apply the and (<a>&amp;&amp;</a>) operator to two boolean streams,
--   point-wise.
(&&) :: Stream Bool -> Stream Bool -> Stream Bool
infixr 4 &&

-- | Apply the or (<a>||</a>) operator to two boolean streams, point-wise.
(||) :: Stream Bool -> Stream Bool -> Stream Bool
infixr 4 ||

-- | Negate all the values in a boolean stream.
not :: Stream Bool -> Stream Bool

-- | A stream that contains the constant value <a>True</a>.
true :: Stream Bool

-- | A stream that contains the constant value <a>False</a>.
false :: Stream Bool

-- | Apply the exclusive-or (<a>xor</a>) operator to two boolean streams,
--   point-wise.
xor :: Stream Bool -> Stream Bool -> Stream Bool

-- | Apply the implication (<a>==&gt;</a>) operator to two boolean streams,
--   point-wise.
(==>) :: Stream Bool -> Stream Bool -> Stream Bool


-- | Implement negation over quantified extensions of boolean streams.
--   
--   For details, see <a>Prop</a>.
module Copilot.Language.Operators.Propositional

-- | Negate a proposition.
not :: Negatable a b => a -> b
instance Copilot.Language.Operators.Propositional.Negatable (Copilot.Language.Spec.Prop Copilot.Theorem.Prove.Existential) (Copilot.Language.Spec.Prop Copilot.Theorem.Prove.Universal)
instance Copilot.Language.Operators.Propositional.Negatable (Copilot.Language.Spec.Prop Copilot.Theorem.Prove.Universal) (Copilot.Language.Spec.Prop Copilot.Theorem.Prove.Existential)


-- | Bitwise operators applied on streams, pointwise.
module Copilot.Language.Operators.BitWise
class Eq a => Bits a
(.&.) :: Bits a => a -> a -> a
(.|.) :: Bits a => a -> a -> a
complement :: Bits a => a -> a
(.^.) :: Bits a => a -> a -> a

-- | Shifting values of a stream to the left.
(.<<.) :: (Bits a, Typed a, Typed b, Integral b) => Stream a -> Stream b -> Stream a

-- | Shifting values of a stream to the right.
(.>>.) :: (Bits a, Typed a, Typed b, Integral b) => Stream a -> Stream b -> Stream a
instance (Copilot.Core.Type.Typed a, GHC.Bits.Bits a) => GHC.Bits.Bits (Copilot.Language.Stream.Stream a)


-- | Integral class operators applied point-wise on streams.
module Copilot.Language.Operators.Integral

-- | Apply the <a>div</a> operation to two streams, point-wise.
div :: (Typed a, Integral a) => Stream a -> Stream a -> Stream a

-- | Apply the <a>mod</a> operation to two streams, point-wise.
mod :: (Typed a, Integral a) => Stream a -> Stream a -> Stream a

-- | Apply a limited form of exponentiation (<tt>^</tt>) to two streams,
--   point-wise.
--   
--   Either the first stream must be the constant 2, or the second must be
--   a constant stream.
(^) :: (Typed a, Typed b, Num a, Bits a, Integral b) => Stream a -> Stream b -> Stream a


-- | Combinators to deal with streams carrying arrays.
module Copilot.Language.Operators.Array

-- | Create a stream that carries an element of an array in another stream.
--   
--   This function implements a projection of the element of an array at a
--   given position, over time. For example, if <tt>s</tt> is a stream of
--   type <tt>Stream (Array '5 Word8)</tt>, then <tt>s .!! 3</tt> has type
--   <tt>Stream Word8</tt> and contains the 3rd element (starting from
--   zero) of the arrays in <tt>s</tt> at any point in time.
(.!!) :: (KnownNat n, Typed t) => Stream (Array n t) -> Stream Word32 -> Stream t


-- | Transform a Copilot Language specification into a Copilot Core
--   specification.
module Copilot.Language.Reify

-- | Transform a Copilot Language specification into a Copilot Core
--   specification.
reify :: Spec' a -> IO Spec


-- | Main Copilot language export file.
--   
--   This is mainly a meta-module that re-exports most definitions in this
--   library.
module Copilot.Language
data () => Int64
data () => Int32
data () => Int16
data () => Int8
type Name = String
class (Show a, Typeable a) => Typed a

-- | Report an error due to a bug in Copilot.
impossible :: String -> String -> a

-- | Report an error due to an error detected by Copilot (e.g., user
--   error).
badUsage :: String -> a

-- | Simulate a number of steps of a given specification, printing the
--   results in a table in comma-separated value (CSV) format.
csv :: Integer -> Spec -> IO ()

-- | Simulate a number of steps of a given specification, printing the
--   results in a table in readable format.
--   
--   Compared to <a>csv</a>, this function is slower but the output may be
--   more readable.
interpret :: Integer -> Spec -> IO ()

-- | A specification is a list of declarations of triggers, observers,
--   properties and theorems.
--   
--   Specifications are normally declared in monadic style, for example:
--   
--   <pre>
--   monitor1 :: Stream Bool
--   monitor1 = [False] ++ not monitor1
--   
--   counter :: Stream Int32
--   counter = [0] ++ not counter
--   
--   spec :: Spec
--   spec = do
--     trigger "handler_1" monitor1 []
--     trigger "handler_2" (counter &gt; 10) [arg counter]
--   </pre>
type Spec = Writer [SpecItem] ()

-- | A stream in Copilot is an infinite succession of values of the same
--   type.
--   
--   Streams can be built using simple primities (e.g., <a>Const</a>), by
--   applying step-wise (e.g., <a>Op1</a>) or temporal transformations
--   (e.g., <a>Append</a>, <a>Drop</a>) to streams, or by combining
--   existing streams to form new streams (e.g., <a>Op2</a>, <a>Op3</a>).
data Stream :: * -> *

-- | Define a new observer as part of a specification. This allows someone
--   to print the value at every iteration during interpretation. Observers
--   do not have any functionality outside the interpreter.
observer :: Typed a => String -> Stream a -> Spec

-- | Define a new trigger as part of a specification. A trigger declares
--   which external function, or handler, will be called when a guard
--   defined by a boolean stream becomes true.
trigger :: String -> Stream Bool -> [Arg] -> Spec

-- | Construct a function argument from a stream.
--   
--   <a>Arg</a>s can be used to pass arguments to handlers or trigger
--   functions, to provide additional information to monitor handlers in
--   order to address property violations. At any given point (e.g., when
--   the trigger must be called due to a violation), the arguments passed
--   using <a>arg</a> will contain the current samples of the given
--   streams.
arg :: Typed a => Stream a -> Arg

-- | A proposition, representing a boolean stream that is existentially or
--   universally quantified over time, as part of a specification.
--   
--   This function returns, in the monadic context, a reference to the
--   proposition.
prop :: String -> Prop a -> Writer [SpecItem] (PropRef a)

-- | A theorem, or proposition together with a proof.
--   
--   This function returns, in the monadic context, a reference to the
--   proposition.
theorem :: String -> Prop a -> Proof a -> Writer [SpecItem] (PropRef a)

-- | Universal quantification of boolean streams over time.
forAll :: Stream Bool -> Prop Universal

-- | Universal quantification of boolean streams over time.

-- | <i>Deprecated: Use forAll instead.</i>
forall :: Stream Bool -> Prop Universal

-- | Existential quantification of boolean streams over time.
exists :: Stream Bool -> Prop Existential
