Browse files

Casting examples.

  • Loading branch information...
1 parent ccfa185 commit 554fc479457ed37d8499c89ba402a6e8987b3e44 @leepike committed Nov 5, 2011
Showing with 27 additions and 0 deletions.
  1. +27 −0 Examples/Cast.hs
View
27 Examples/Cast.hs
@@ -0,0 +1,27 @@
+--------------------------------------------------------------------------------
+-- Copyright © 2011 National Institute of Aerospace / Galois, Inc.
+--------------------------------------------------------------------------------
+
+{-# LANGUAGE RebindableSyntax #-}
+
+module Main where
+
+import Language.Copilot hiding (even, odd)
+
+b :: Stream Bool
+b = [True] ++ not b
+
+i :: Stream Int8
+i = cast b
+
+x :: Stream Word16
+x = [0] ++ x + 1
+
+y :: Stream Int32
+y = 1 + cast x
+
+spec :: Spec
+spec = trigger "trigger" true [arg y, arg i]
+
+main :: IO ()
+main = interpret 10 [] spec

0 comments on commit 554fc47

Please sign in to comment.