packages feed

copilot-libraries 0.2 → 0.3

raw patch · 3 files changed

+23/−8 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

- Copilot.Library.Statistics: mean :: (Typed a, Fractional a) => Int -> Stream a -> Stream a
+ Copilot.Library.Statistics: mean :: (Typed a, Eq a, Fractional a) => Int -> Stream a -> Stream a
- Copilot.Library.Statistics: sum :: (Typed a, Num a) => Int -> Stream a -> Stream a
+ Copilot.Library.Statistics: sum :: (Typed a, Num a, Eq a) => Int -> Stream a -> Stream a

Files

copilot-libraries.cabal view
@@ -1,9 +1,20 @@ cabal-version:       >=1.10 name:                copilot-libraries-version:             0.2+version:             0.3 synopsis:            A Haskell-embedded DSL for monitoring hard real-time                      distributed systems.-description:         Libraries for the Copilot language+description:         +  Libraries for the Copilot language.+  . +  Copilot is a stream (i.e., infinite lists) domain-specific language (DSL) in+  Haskell that compiles into embedded C.  Copilot contains an interpreter,+  multiple back-end compilers, and other verification tools.  A tutorial, bug+  reports, and todos are available at+  <https://github.com/niswegmann/copilot-discussion>.  +  .  +  Examples are available at+  <https://github.com/leepike/Copilot/tree/master/Examples>.+ license:             BSD3 license-file:        LICENSE author:              Lee Pike, Robin Morisset, Alwyn Goodloe, Sebastian Niller,
src/Copilot/Library/Statistics.hs view
@@ -12,7 +12,7 @@ import Copilot.Library.Utils  -- | Summation.-sum :: ( Typed a, Num a ) => Int -> Stream a -> Stream a+sum :: ( Typed a, Num a, Eq a ) => Int -> Stream a -> Stream a sum n s = nfoldl1 n (+) s  -- | Maximum value.@@ -27,7 +27,7 @@  -- | Mean value.  @n@ must not overflow -- for word size @a@ for streams over which computation is peformed.-mean :: ( Typed a, Fractional a ) => Int -> Stream a -> Stream a+mean :: ( Typed a, Eq a, Fractional a ) => Int -> Stream a -> Stream a mean n s = ( sum n s ) / ( fromIntegral n )  -- | Mean value over the current set of streams passed in.
src/Copilot/Library/Voting.hs view
@@ -28,14 +28,18 @@ majority []     = badUsage "majority: empty list not allowed" majority (x:xs) = majority' xs x 1 +-- Alternate syntax of local bindings. majority' :: (P.Eq a, Typed a)    => [Stream a] -> Stream a -> Stream Word32 -> Stream a majority' []     can _   = can majority' (x:xs) can cnt =-  local (cnt == 0) $ \ zero -> -    local (if zero then x else can) $ \ can' ->-      local (if zero || x == can then cnt+1 else cnt-1) $ \ cnt' ->-        majority' xs can' cnt'+  local (cnt == 0) inZero+  where +  inZero zero    = local (if zero then x else can) inCan+    where       +    inCan can'   = local (if zero || x == can then cnt+1 else cnt-1) inCnt+      where +      inCnt cnt' = majority' xs can' cnt'  --------------------------------------------------------------------------------