-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Step functions, staircase functions or piecewise constant functions -- @package step-function @version 0.1.1.0 -- | 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 (Eq x, Eq y) => Eq (Transition x y) instance (Show x, Show y) => Show (Transition x y) instance (Eq x, Eq y) => Eq (StepFunction x y) instance (Show x, Show y) => Show (StepFunction x y) instance (Ord x, Eq y) => Ord (Transition x y) instance Functor (StepFunction x) instance Functor (Transition x)