Re: [Haskell-cafe] Atom - help.

Calling foreign functions that return values is problematic for the
compiler -- I haven't invested enough time to come up with a good
solution.
The work around is to assign the result to an external variable. The
drawback is the result will not be available until the rule executing
the action has completed.
results <- bool' "result" -- Global, external variable to capture result.
action (\ [a, b, c] -> printf "result = function(%s, %s %s)" a b c) [a, b, c]
-Tom
On Sat, Jun 13, 2009 at 5:03 AM, Radamés Ajna
hi there,
I've been working with haskell and atom dsl, however I'm new to haskell.. John Van Enk inspired me with programming arduino->atmegas , with haskell, So here is my problem. With an action , action :: ([String] -> String) -> [UE] -> Atom () , it's possible make calls to some precoded C functions like,
setLED v = action (\[x] -> "setLED(" ++ x ++ ")") [v'] where v' = ue . value $ v
where setLed is a precode function.
I want call a precoded C function that returns some value, but action always give me Atom () , that's I would like to do but I don't know how ..
Atom (V Int8) < ---- "int read()"
thanks... related links http://hackage.haskell.org/package/atom-0.0.5 http://blog.sw17ch.com/wordpress/?p=111 http://leepike.wordpress.com/2009/05/05/an-atomic-fibonacci-server-exploring...
Radamés _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

would the way you implemented random in Unit.hs work here? an external variable whose name is the function that returns input. compass :: Atom (E Int16) compass = int16' "readCompass()" >>= (return . value) something <- int16' "something" period 1 $ atom "navigate" $ do heading <- compass something <== heading br, miaubiz Tom Hawkins-2 wrote:
The work around is to assign the result to an external variable. The drawback is the result will not be available until the rule executing the action has completed.
results <- bool' "result" -- Global, external variable to capture result. action (\ [a, b, c] -> printf "result = function(%s, %s %s)" a b c) [a, b, c]
-- View this message in context: http://old.nabble.com/Atom---help.-tp24010994p26535883.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

On Fri, Nov 27, 2009 at 6:52 AM, miaubiz
would the way you implemented random in Unit.hs work here? an external variable whose name is the function that returns input.
Yes, but you have to be a little careful. If in the same rule you reference 'heading' multiple times, or create another instance using 'compare', it will still only call 'readCompare()' once during the execution of rule 'navigate'. It's not a problem if 'readCompass()' has no side-effects. But if it does, you probably won't get the results you expect.
compass :: Atom (E Int16) compass = int16' "readCompass()" >>= (return . value)
something <- int16' "something" period 1 $ atom "navigate" $ do heading <- compass something <== heading
br, miaubiz
Tom Hawkins-2 wrote:
The work around is to assign the result to an external variable. The drawback is the result will not be available until the rule executing the action has completed.
results <- bool' "result" -- Global, external variable to capture result. action (\ [a, b, c] -> printf "result = function(%s, %s %s)" a b c) [a, b, c]
-- View this message in context: http://old.nabble.com/Atom---help.-tp24010994p26535883.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
participants (2)
-
miaubiz
-
Tom Hawkins