{-# OPTIONS -fplugin=Rattus.Plugin #-}


-- | The bare-bones Rattus language. To program with streams and
-- events, you can use "Rattus.Stream" and "Rattus.Events"; to program with
-- Yampa-style signal functions, you can use "Rattus.Yampa".

module Rattus (
  -- * Rattus language primitives
  module Rattus.Primitives,
  -- * Strict data types
  module Rattus.Strict,
  -- * Annotation
  Rattus(..),
  -- * Applicative operators
  (|#|),
  (|##),
  (<#>),
  (<##),
  -- * box for stable types
  box'
  )
  where

import Rattus.Plugin
import Rattus.Strict
import Rattus.Primitives

-- all functions in this module are in Rattus 
{-# ANN module Rattus #-}


-- | Applicative operator for 'O'.
{-# INLINE (<#>) #-}
(<#>) :: O (a -> b) -> O a -> O b
O (a -> b)
f <#> :: O (a -> b) -> O a -> O b
<#> O a
x = b -> O b
forall a. a -> O a
delay (O (a -> b) -> a -> b
forall a. O a -> a
adv O (a -> b)
f (O a -> a
forall a. O a -> a
adv O a
x))

-- | Variant of '<#>' where the argument is of a stable type..
{-# INLINE (<##) #-}
(<##) :: Stable a => O (a -> b) -> a -> O b
O (a -> b)
f <## :: O (a -> b) -> a -> O b
<## a
x = b -> O b
forall a. a -> O a
delay (O (a -> b) -> a -> b
forall a. O a -> a
adv O (a -> b)
f a
x)

-- | Applicative operator for 'Box'.
{-# INLINE (|#|) #-}
(|#|) :: Box (a -> b) -> Box a -> Box b
Box (a -> b)
f |#| :: Box (a -> b) -> Box a -> Box b
|#| Box a
x = b -> Box b
forall a. a -> Box a
box (Box (a -> b) -> a -> b
forall a. Box a -> a
unbox Box (a -> b)
f (Box a -> a
forall a. Box a -> a
unbox Box a
x))

-- | Variant of '|#|' where the argument is of a stable type..
{-# INLINE (|##) #-}
(|##) :: Stable a => Box (a -> b) -> a -> Box b
Box (a -> b)
f |## :: Box (a -> b) -> a -> Box b
|## a
x = b -> Box b
forall a. a -> Box a
box (Box (a -> b) -> a -> b
forall a. Box a -> a
unbox Box (a -> b)
f a
x)


-- | Variant of 'box' for stable types that can be safely used nested
-- in recursive definitions or in another box.
box' ::  Stable a => a -> Box a
box' :: a -> Box a
box' a
x = a -> Box a
forall a. a -> Box a
box a
x