Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- mean :: ContainsWeight s => s -> Double
- meanInRange :: ContainsWeight s => s -> RangeInclusive -> Double
- getWeight :: (ContainsWeight s, MonadError Text m) => s -> Int -> m (Weight s)
- unsafeGetWeight :: ContainsWeight s => s -> Int -> Weight s
- getWeights :: ContainsWeight s => s -> [Weight s]
- toWeighted :: (IsBareSequence s, IsWeightedSequence s', Weight s' ~ w, Element s ~ Element s', MonadError Text m) => s -> [w] -> m s'
- unsafeToWeighted :: (IsBareSequence s, IsWeightedSequence s', Weight s' ~ w, Element s ~ Element s') => s -> [w] -> s'
Documentation
mean :: ContainsWeight s => s -> Double Source #
Calculate mean weight for given s
.
sequWeighted = Sequence ['a', 'a', 'b', 'a'] someMarking [0.1, 0.2, 0.3, 0.4]
mean sequWeighted == 0.45
meanInRange :: ContainsWeight s => s -> RangeInclusive -> Double Source #
Calculate mean weight for given s
in range RangeInclusive
.
sequWeighted = Sequence ['a', 'a', 'b', 'a'] someMarkings [0.1, 0.2, 0.3, 0.4] meanInRange sequWeighted (1, 2) == 0.25
getWeight :: (ContainsWeight s, MonadError Text m) => s -> Int -> m (Weight s) Source #
Get weight of element of s
at given position.
unsafeGetWeight :: ContainsWeight s => s -> Int -> Weight s Source #
getWeights :: ContainsWeight s => s -> [Weight s] Source #
Get Weight
s of all elements in s
.
toWeighted :: (IsBareSequence s, IsWeightedSequence s', Weight s' ~ w, Element s ~ Element s', MonadError Text m) => s -> [w] -> m s' Source #
Converts IsBareSequence
s
to IsWeightedSequence
s'
that is weighted using provided list
of Weight
s. If length of Weight
s list is different from length of s
, an
error is thrown.
sequBare = Sequence ['a', 'a', 'b', 'a'] mempty mempty :: BareSequence Char toMarked sequ [0.1, 0.2, 0.3, 0.4] :: WeightedSequence Double Char
unsafeToWeighted :: (IsBareSequence s, IsWeightedSequence s', Weight s' ~ w, Element s ~ Element s') => s -> [w] -> s' Source #