[Haskell-cafe] ANN: atom-0.1.3

miaubiz miaubiz at gmail.com
Sun Jan 17 07:16:38 EST 2010




Tom Hawkins-2 wrote:
> 
> period 20 $ atom "checkSomeStuff" $ do
>   cond ok
>   assert "A" a
>   assert "B" b
>   cover  "C" c
> 

I am trying to generate a square wave.  Here's the code:

    square <- bool "square" False

    period 2 $ atom "square high" $ phase 0 $ do
        square <== true
        assert "square is low" $ not_ $ value square

    period 2 $ atom "square low" $ phase 1 $ do
        square <== false
        assert "square is high" $ value square


The tests fail every cycle because after each rule one of them is wrong.

What would be the right way to formulate this code? Use cond on the rules?

    period 2 $ atom "square high" $ phase 0 $ do
        cond $ not_ $ value square
        square <== true
        cover "lowSquare" true
        assert "square is low" $ not_ $ value square

    period 2 $ atom "square low" $ phase 1 $ do
        cond $ value square
        square <== false
        cover "highSquare" true
        assert "square is high" $ value square


as an aside, in Unit.hs:
         covered = [ words line !! 1 | line <- lines log, isPrefixOf
"covered:" line ]

because covered is the second word of the line from the log, the name of
cover must be a single word. assertions and atoms can contain spaces as far
as I can tell.

br, miau
-- 
View this message in context: http://old.nabble.com/ANN%3A-atom-0.1.3-tp26624813p27198213.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.



More information about the Haskell-Cafe mailing list