Hi Tim,
Glad to see you're trying Automat out.
I'm not sure what you mean by "forks in the road". If your FSM is defined
as (a/or [1 3] [1 2 3]), then you can do any of the following:
(reduce #(a/advance fsm %1 %2) nil [1 2 3])
(a/advance-stream fsm nil [1 2 3] ::rejected)
(let [adv (partial a/advance fsm)]
(-> nil (adv 1) (adv 2) (adv 3)))
Does that answer your first two questions? If not, you'll have to clarify
what you're asking.
Automat doesn't allow you to name your states, because that breaks your
ability to freely compose automata. If you want to differentiate between
two different paths, you can use actions:
(view (a/or [:sent :acknowledged :accepted] [:sent :rejected (a/$
:not-accepted)]))
I can go into more depth on this, but the README gives a fairly complete
explanation of how actions can be used.
Hope that helps,
Zach
On Tuesday, August 26, 2014 11:42:24 AM UTC-7, frye wrote:
>
> I'm trying to use Automat to map out transitions that are either of the
> paths below.
>
> - There can be many claims sent to an external service. Each claim,
> after being sent, can be :acknowledged or :rejected.
> - If a claim is :acknowledged, it can then either be :accepted or
> :rejected.
> - There will be many such claims
>
> [:sent :acknowledged :accepted]
> [:sent :acknowledged :rejected]
> [:sent :rejected]
>
>
> I'm trying to figure out how to use Automat to handle this use case.
>
> - The only way to advance through your FSM, seems to be to call
> fsm/advance (or fsm/advance-stream). How do we deal with forks in the road?
> - Looking at the documentation
> <https://github.com/ztellman/automat#a-short-example> and tests
>
> <https://github.com/ztellman/automat/blob/master/test/automat/fsm_test.clj>,
> it's not clear to me if I can pass multiple tokens (or claims) through 1
> FSM. Are we meant to use 1 FSM per token (claim in this case)?
> - The semantics for Automat have you declare transitions, instead of
> states. States are implicit numbers between the transitions. Pallet-fsm
> <https://github.com/pallet/pallet-fsm> seems to follow the state
> declaration pattern, but hasn't been updated in a few years. Can I name
> the
> states and transitions between them?
> - There always seems to be one output state, even if they come from 2
> different transitions. So the below 2 FSMs are equivalent. However, they
> both go to the same end state. Is there a way to define different output
> states?
>
> => (require '[automat.viz :refer (view)])
> => (require '[automat.core :as a])
>
> => (view (a/or [:sent :acknowledged :accepted] [:sent :acknowledged
> :rejected] [:sent :rejected]))
> => (view [:sent (a/or [:acknowledged (a/or :accepted :rejected)]
> [:rejected])])
>
>
>
> Tim Washington
> Interruptsoftware.com <http://interruptsoftware.com>
>
>
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.