Îõ³h*%Ñ#ùØ      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVW0.2.1Safe9:;  step-functionBound operations step-function less-than, < step-functionless-than-or-equal, äD. step-functionÎStep function. Piecewise constant function, having finitely many pieces. See  +https://en.wikipedia.org/wiki/Step_function. (fromList [( k1, v1), ( k2, v2)]) v3 ::  k v) describes a piecewise constant function  f : k \to v:ý f\,x = \begin{cases} v_1, \quad x < k_1 \newline v_2, \quad k_1 \le x \le k_2 \newline v_3, \quad k_2 < x \end{cases}  or as you would write in Haskell ?f x | x < k1 = v1 | x <= k2 = v2 | otherwise = v3 Note:  Ëhttps://hackage.haskell.org/package/total-map-0.0.6/docs/Data-TotalMap.html total-map package, which provides function with finite support.9Constructor is exposed as you cannot construct non-valid .Merging You can use X instance to merge .,putSF $ liftA2 (+) (step 0 0 1) (step 1 0 1)\x -> if | x < 0 -> 0 | x < 1 -> 1 | otherwise -> 2Following property holds, i.e.  and ordinary function X instances are compatible (and  is a homomorphism).ÚliftA2 (applyFun2 f) g h ! x == liftA2 (applyFun2 f :: A -> B -> C) (g !) (h !) (x :: Int)#Recall that for ordinary functions Y f g h x = f (g x) (h x).Dense?"This dense variant is useful with  )https://en.wikipedia.org/wiki/Dense_order dense ordered domains, e.g. Rational. Integer is not dense, so you could use Data.Function.Step.Discrete variant instead.Âlet s = fromList [(Open 0, -1),(Closed 0, 0)] 1 :: SF Rational IntputSF s\x -> if | x < 0 % 1 -> -1 | x <= 0 % 1 -> 0 | otherwise -> 1import Data.Ratio ((%))map (s !) [-1, -0.5, 0, 0.5, 1] [-1,-1,0,1,1] step-functionApply . heaviside ! 21 step-functionConstant functionputSF $ constant 1\_ -> 1 step-functionStep function.* k v1 v2 = \ x -> if x < k then v1 else v2.putSF $ step 1 2 3\x -> if | x < 1 -> 2 | otherwise -> 3 step-function5Create function from list of cases and default value.7let f = fromList [(Open 1,2),(Closed 3,4),(Open 4,5)] 6putSF f\x -> if | x < 1 -> 2 | x <= 3 -> 4 | x < 4 -> 5 | otherwise -> 6map (f !) [0..10][2,4,4,4,6,6,6,6,6,6,6]  step-functionPossible values of values heaviside[-1,1]  step-function(Merge adjustent pieces with same values.Note: Á isn't normalised on construction. Values don't necessarily are Z.putSF $ normalise heaviside\x -> if | x < 0 -> -1 | otherwise -> 1putSF $ normalise $ step 0 1 1\_ -> 1Ânormalise (liftA2 (+) p (fmap negate p)) == (pure 0 :: SF Int Int)  step-functionShow  as Haskell code  step-function [ .   step-functionOrder is like  k = (k, False),  k = (k, True). step-function Piecewise \.(putSF $ step 0 "a" "b" <> step 1 "c" "d"\x -> if | x < 0 -> "ac" | x < 1 -> "bc" | otherwise -> "bd" step-function] is a constant function.     9 Safe9:;à $ step-functionÎStep function. Piecewise constant function, having finitely many pieces. See  +https://en.wikipedia.org/wiki/Step_function.Note:= this variant has discrete domain. It's enough to have only < $, without äD, as there is a next( element without any others in between.$' (fromList [(k1, v1), (k2, v2)]) v3 :: $ k v) describes a piecewise constant function  f : k \to v:ý f\,x = \begin{cases} v_1, \quad x \le k_1 \newline v_2, \quad k_1 < x \le k_2 \newline v_3, \quad k_2 < x \end{cases}  or as you would write in Haskell Áf x | x <= k1 = v1 | x <= k2 = v2 | otherwise = v3 9Constructor is exposed as you cannot construct non-valid $.& step-functionApply $. heaviside ! 21' step-functionConstant functionputSF $ constant 1\_ -> 1( step-functionStep function.(* k v1 v2 = \ x -> if x < k then v1 else v2.putSF $ step 1 2 3\x -> if | x <= 1 -> 2 | otherwise -> 3) step-function5Create function from list of cases and default value. let f = fromList [(1,2),(3,4)] 5putSF f\x -> if | x <= 1 -> 2 | x <= 3 -> 4 | otherwise -> 5map (f !) [0..10][2,2,4,4,5,5,5,5,5,5,5]* step-functionPossible values of $values heaviside[-1,1]+ step-function(Merge adjustent pieces with same values.Note: $Á isn't normalised on construction. Values don't necessarily are Z.putSF $ normalise heaviside\x -> if | x <= 0 -> -1 | otherwise -> 1putSF $ normalise $ step 0 1 1\_ -> 1Ânormalise (liftA2 (+) p (fmap negate p)) == (pure 0 :: SF Int Int), step-function-Convert from discrete variant to more "dense"-SF.putSF $ toDense $ fromList [(1,2),(3,4)] 5\x -> if | x <= 1 -> 2 | x <= 3 -> 4 | otherwise -> 5- step-functionConvert from "dense" variant. <= k pieces will be converted to < succ k-. There might be less pieces in the ressult $, than in the original.Ãlet f = SF.fromList [(SF.Open 1,2),(SF.Closed 3,4),(SF.Open 4,5)] 6 SF.putSF f\x -> if | x < 1 -> 2 | x <= 3 -> 4 | x < 4 -> 5 | otherwise -> 6!putSF $ fromDense (Just . pred) f\x -> if | x <= 0 -> 2 | x <= 3 -> 4 | otherwise -> 6. step-functionShow $ as Haskell code/ step-function [ . .6 step-function Piecewise \.(putSF $ step 0 "a" "b" <> step 1 "c" "d"\x -> if | x <= 0 -> "ac" | x <= 1 -> "bc" | otherwise -> "bd"8 step-function] is a constant function.- step-functionprevious key, if exists $%'()+&*,-./ $%'()+&*,-./&9 Safe9:;#¥ > step-functionÎStep function. Piecewise constant function, having finitely many pieces. See  +https://en.wikipedia.org/wiki/Step_function.Note:= this variant has discrete domain. It's enough to have only < $, without äD, as there is a next( element without any others in between.>' (fromList [(k1, v1), (k2, v2)]) v3 :: > k v) describes a piecewise constant function  f : k \to v:ý f\,x = \begin{cases} v_1, \quad x < k_1 \newline v_2, \quad k_1 \le x < k_2 \newline v_3, \quad k_2 \le x \end{cases}  or as you would write in Haskell ?f x | x < k1 = v1 | x < k2 = v2 | otherwise = v3 9Constructor is exposed as you cannot construct non-valid >.@ step-functionApply >. heaviside ! 21A step-functionConstant functionputSF $ constant 1\_ -> 1B step-functionStep function.B* k v1 v2 = \ x -> if x < k then v1 else v2.putSF $ step 1 2 3\x -> if | x < 1 -> 2 | otherwise -> 3C step-function5Create function from list of cases and default value. putSF $ fromList [(1,2),(3,4)] 5\x -> if | x < 1 -> 2 | x < 3 -> 4 | otherwise -> 5(map (fromList [(1,2),(3,4)] 5 !) [0..10][2,4,4,5,5,5,5,5,5,5,5]D step-functionPossible values of >values heaviside[-1,1]E step-function(Merge adjustent pieces with same values.Note: >Á isn't normalised on construction. Values don't necessarily are Z.putSF $ normalise heaviside\x -> if | x < 0 -> -1 | otherwise -> 1putSF $ normalise $ step 0 1 1\_ -> 1Ânormalise (liftA2 (+) p (fmap negate p)) == (pure 0 :: SF Int Int)F step-function-Convert from discrete variant to more "dense"-SF.putSF $ toDense $ fromList [(1,2),(3,4)] 5\x -> if | x < 1 -> 2 | x < 3 -> 4 | otherwise -> 5G step-functionConvert from "dense" variant. <= k pieces will be converted to < succ k-. There might be less pieces in the ressult >, than in the original.Ãlet f = SF.fromList [(SF.Open 1,2),(SF.Closed 3,4),(SF.Open 4,5)] 6 SF.putSF f\x -> if | x < 1 -> 2 | x <= 3 -> 4 | x < 4 -> 5 | otherwise -> 6!putSF $ fromDense (Just . succ) f\x -> if | x < 1 -> 2 | x < 4 -> 4 | otherwise -> 6H step-functionShow > as Haskell codeI step-function [ . HP step-function Piecewise \.(putSF $ step 0 "a" "b" <> step 1 "c" "d"\x -> if | x < 0 -> "ac" | x < 1 -> "bc" | otherwise -> "bd"R step-function] is a constant function.G step-functionnext key, if exists >?ABCE@DFGHI >?ABCE@DFGHI@9  Safe-Inferred#é >?C@BEADHIFGÞ       !"#$%&'(      )* !"#      )* !"#+,-+,./01+23+,4+,56)step-function-0.2.1-HX1zXxst9goiake6gYgvtData.Function.Step"Data.Function.Step.Discrete.Closed Data.Function.Step.Discrete.Open step-functionData.Function.Step.DiscreteBoundOpenClosedSF!constantstepfromListvalues normaliseshowSFputSF $fShow1Bound $fNFDataBound$fArbitraryBound $fOrdBound$fShowSF $fShow1SF $fShow2SF $fNFDataSF $fArbitrarySF $fMonoidSF $fSemigroupSF $fMonadSF$fApplicativeSF$fEqSF$fOrdSF $fFunctorSF $fFoldableSF$fTraversableSF $fEqBound $fShowBound$fFunctorBound$fFoldableBound$fTraversableBoundtoDense fromDensebaseGHC.Base ApplicativeliftA2ghc-prim GHC.ClassesEq System.IOputStrLn<>pure