-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Step functions, staircase functions or piecewise constant functions -- -- Step functions, staircase functions or piecewise constant functions. -- Implemented as a default value and a series of transitions. Supports -- merging two step functions using a supplied merging function. @package step-function @version 0.1.1.1 -- | Functions for dealing with step functions. module Data.StepFunction -- | A Transition, for a certain value on the x axis, there is a new y -- value. data Transition x y Transition :: x -> y -> Bool -> Transition x y -- | The x value where the transition happens. [x_val] :: Transition x y -> x -- | The new y value. [y_val] :: Transition x y -> y -- | If True, y_val is for all x >= x_val, otherwise for all x > -- x_val. [left_closed] :: Transition x y -> Bool -- | A StepFunction is implemented as a default value and a sorted list of -- Transitions. data StepFunction x y -- | Smart constructor sorts and simplifies the list of transitions. mkStepFunction :: (Ord x, Eq y) => y -> [Transition x y] -> StepFunction x y -- | Get the y value for a given x. valAt :: Ord x => x -> StepFunction x y -> y -- | The transitions. transitions :: StepFunction x y -> [Transition x y] -- | Merge two step function, such that the following should be true: -- --
--   valAt x (merge f sf1 sf2) == f (valAt x sf1) (valAt x sf2)
--   
-- -- The resulting step function will be simplified, transitions that don't -- change the y value will be eliminated, and transitions that happen on -- the same x position will be eliminated. merge :: (Ord x, Eq c) => (a -> b -> c) -> StepFunction x a -> StepFunction x b -> StepFunction x c instance (GHC.Show.Show x, GHC.Show.Show y) => GHC.Show.Show (Data.StepFunction.StepFunction x y) instance (GHC.Classes.Eq x, GHC.Classes.Eq y) => GHC.Classes.Eq (Data.StepFunction.StepFunction x y) instance (GHC.Show.Show y, GHC.Show.Show x) => GHC.Show.Show (Data.StepFunction.Transition x y) instance (GHC.Classes.Eq y, GHC.Classes.Eq x) => GHC.Classes.Eq (Data.StepFunction.Transition x y) instance GHC.Base.Functor (Data.StepFunction.Transition x) instance GHC.Base.Functor (Data.StepFunction.StepFunction x) instance (GHC.Classes.Ord x, GHC.Classes.Eq y) => GHC.Classes.Ord (Data.StepFunction.Transition x y)