measurable

A simple shallowly-embedded DSL for dealing with measures.
Log | Files | Refs | README | LICENSE

commit c2cad7d41c1000eb85ae5414dfc46f55dde521aa
parent 5481d0f68053ba386c59244228d69503d85fc3b9
Author: Jared Tobin <jared@jtobin.ca>
Date:   Fri, 18 Oct 2013 11:30:58 +1300

Add applicative instance.

Diffstat:
Msrc/Measurable.hs | 10+++++++---
1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/Measurable.hs b/src/Measurable.hs @@ -48,13 +48,17 @@ import Numeric.Integration.TanhSinh newtype Measure a = Measure { measure :: (a -> Double) -> Double } -instance Functor Measure where - fmap = push - instance Fractional a => Monoid (Measure a) where mempty = identityMeasure mappend = convolute +instance Functor Measure where + fmap = push + +instance Applicative Measure where + pure = return + (<*>) = ap + instance Monad Measure where return x = Measure (\f -> f x) mu >>= f = Measure $ \d ->