haskell-cafe@haskell.org
[Top] [All Lists]

Re: [Haskell-cafe] ANN: atom-0.1.3

Subject: Re: [Haskell-cafe] ANN: atom-0.1.3
From: miaubiz
Date: Sun, 17 Jan 2010 04:16:38 -0800 PST


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.

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@xxxxxxxxxxx
http://www.haskell.org/mailman/listinfo/haskell-cafe

<Prev in Thread] Current Thread [Next in Thread>