packages feed

copilot 3.0 → 3.0.1

raw patch · 5 files changed

+84/−56 lines, 5 filesdep ~copilot-c99dep ~copilot-coredep ~copilot-languagesetup-changedPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: copilot-c99, copilot-core, copilot-language

API changes (from Hackage documentation)

Files

+ Examples/Counter.hs view
@@ -0,0 +1,28 @@+{-# LANGUAGE RebindableSyntax #-}++module Latch where++import Language.Copilot+import Copilot.Compile.C99++import Prelude hiding ((++), (==), mod)++-- A resettable counter+counter :: Stream Bool -> Stream Bool -> Stream Int32+counter inc reset = cnt+  where+    cnt = if reset then 0+          else if inc then z + 1+               else z+    z = [0] ++ cnt++-- Counter that resets when it reaches 256+bytecounter :: Stream Int32+bytecounter = counter true reset where+  reset = counter true false == 256++spec :: Spec+spec = trigger "counter" true [arg $ bytecounter]++main :: IO ()+main = reify spec >>= compile "latch"
Examples/Heater.hs view
@@ -1,10 +1,10 @@ ----------------------------------------------------------------------------------- Copyright © 2019 National Institute of Aerospace / Galois, Inc.+-- Copyright 2019 National Institute of Aerospace / Galois, Inc. --------------------------------------------------------------------------------  -- This is a simple example with basic usage. It implements a simple home -- heating system: It heats when temp gets too low, and stops when it is high--- enough. It read temperature as an byte (range -50C to 100C) and translates+-- enough. It read temperature as a byte (range -50C to 100C) and translates -- this to Celcius.  module Heater where@@ -15,20 +15,20 @@ import Prelude hiding ((>), (<), div)  -- External temperature as a byte, range of -50C to 100C-temp :: Stream Int8+temp :: Stream Word8 temp = extern "temperature" Nothing  -- Calculate temperature in Celcius.--- We need to cast the Int8 to a Float. Note that it is an unsafeCast, as there--- is no direct relation between Int8 and Float.+-- We need to cast the Word8 to a Float. Note that it is an unsafeCast, as there+-- is no direct relation between Word8 and Float. ctemp :: Stream Float-ctemp = ((unsafeCast temp) / 150.0) - 50.0+ctemp = (unsafeCast temp) * (150.0 / 255.0) - 50.0  spec = do-  -- Triggers that fire when the ctemp is too low or too hight,+  -- Triggers that fire when the ctemp is too low or too high,   -- pass the current ctemp as an argument.   trigger "heaton"  (ctemp < 18.0) [arg ctemp]-  trigger "heafoff" (ctemp > 21.0) [arg ctemp]+  trigger "heatoff" (ctemp > 21.0) [arg ctemp]  -- Compile the spec main = reify spec >>= compile "heater"
README.md view
@@ -7,7 +7,7 @@ user to write programs in a simple but powerful way using a stream-based approach. -Programs can be interpreted for testing, or translated C99 code to be+Programs can be interpreted for testing, or translated into C99 code to be incorporated in a project, or as a standalone application. The C99 backend output is constant in memory and time, making it suitable for systems with hard realtime requirements.@@ -21,17 +21,21 @@   The Copilot library is cabalized. Assuming you have cabal, the GHC   compiler installed (the   [Haskell Platform](http://hackage.haskell.org/platform/) is the easiest way-  to obtain these), and an Internet connection, it should merely be a matter of running:+  to obtain these), and an Internet connection, it should merely be a matter of+running: -      cabal install copilot+   ```bash+   cabal install copilot+   ```  * Building from source from the GitHub repositories (typically, one would only   go this route to develop Copilot):--      git clone https://github.com/Copilot-Language/Copilot.git-      cd Copilot-      git submodule update --init --remote-      make+   ```bash+   git clone https://github.com/Copilot-Language/Copilot.git+   cd Copilot+   git submodule update --init --remote+   make+   ```  Note there is a TravisCI build (linked to at the top of this README) if you have trouble building/installing.@@ -43,37 +47,38 @@ directory](https://github.com/Copilot-Language/Copilot/tree/master/Examples) of the main repository. -    -- This is a simple example with basic usage. It implements a simple home-    -- heating system: It heats when temp gets too low, and stops when it is high-    -- enough. It read temperature as an byte (range -50C to 100C) and translates-    -- this to Celcius.--    module Heater where+```haskell+-- This is a simple example with basic usage. It implements a simple home+-- heating system: It heats when temp gets too low, and stops when it is high+-- enough. It read temperature as a byte (range -50C to 100C) and translates+-- this to Celcius. -    import Language.Copilot-    import Copilot.Compile.C99+module Heater where -    import Prelude hiding ((>), (<), div)+import Language.Copilot+import Copilot.Compile.C99 -    -- External temperature as a byte, range of -50C to 100C-    temp :: Stream Int8-    temp = extern "temperature" Nothing+import Prelude hiding ((>), (<), div) -    -- Calculate temperature in Celcius.-    -- We need to cast the Int8 to a Float. Note that it is an unsafeCast, as there-    -- is no direct relation between Int8 and Float.-    ctemp :: Stream Float-    ctemp = ((unsafeCast temp) / 150.0) - 50.0+-- External temperature as a byte, range of -50C to 100C+temp :: Stream Word8+temp = extern "temperature" Nothing -    spec = do-      -- Triggers that fire when the ctemp is too low or too hight,-      -- pass the current ctemp as an argument.-      trigger "heaton"  (ctemp < 18.0) [arg ctemp]-      trigger "heafoff" (ctemp > 21.0) [arg ctemp]+-- Calculate temperature in Celcius.+-- We need to cast the Word8 to a Float. Note that it is an unsafeCast, as there+-- is no direct relation between Word8 and Float.+ctemp :: Stream Float+ctemp = (unsafeCast temp) * (150.0 / 255.0) - 50.0 -    -- Compile the spec-    main = reify spec >>= compile "heater"+spec = do+  -- Triggers that fire when the ctemp is too low or too high,+  -- pass the current ctemp as an argument.+  trigger "heaton"  (ctemp < 18.0) [arg ctemp]+  trigger "heatoff" (ctemp > 21.0) [arg ctemp] +-- Compile the spec+main = reify spec >>= compile "heater"+```  ## Contributions Feel free to open new issues and send pull requests.@@ -115,6 +120,9 @@ ## Acknowledgements We are grateful for NASA Contract NNL08AD13T to Galois, Inc. and the National Institute of Aerospace, which partially supported this work.++Additionally NASA Langley contracts 80LARC17C0004 and NNL09AA00A supported+further development of Copilot.   ## License
Setup.hs view
@@ -1,11 +1,2 @@ import Distribution.Simple-import System.Exit (exitWith, ExitCode(..))--main :: IO ()-main = defaultMainWithHooks simpleUserHooks{ postInst = msg }-  where -  msg _ _ _ _ = do-    putStrLn "Execute \"<Your install location>/.cabal/bin/copilot-regression\" to run some very simple tests to ensure your installation built correctly."-    putStrLn "To QuickCheck the Atom backend, execute \"<Your install location>/.cabal/bin/copilot-c99-qc .\""-    exitWith ExitSuccess-+main = defaultMain
copilot.cabal view
@@ -1,5 +1,5 @@ name:                copilot-version:             3.0+version:             3.0.1 cabal-version:       >= 1.10 license:             BSD3 license-file:        LICENSE@@ -26,6 +26,7 @@   Examples/Heater.hs   Examples/Array.hs   Examples/Struct.hs+  Examples/Counter.hs  source-repository head     type:       git@@ -44,11 +45,11 @@                      , directory            >= 1.3  && < 1.4                      , filepath             >= 1.4  && < 1.5 -                     , copilot-core         >= 3.0  && < 3.1-                     , copilot-theorem      >= 3.0  && < 3.1-                     , copilot-language     >= 3.0  && < 3.1-                     , copilot-libraries    >= 3.0  && < 3.1-                     , copilot-c99          >= 3.0  && < 3.1+                     , copilot-core         >= 3.0.1  && < 3.1+                     , copilot-theorem      >= 3.0    && < 3.1+                     , copilot-language     >= 3.0.1  && < 3.1+                     , copilot-libraries    >= 3.0    && < 3.1+                     , copilot-c99          >= 3.0.1  && < 3.1       exposed-modules: Language.Copilot, Language.Copilot.Main