This is neat, methinks.
A couple of questions/points:
- Is the
|| any (== s') rs
part ofcanReachExcluding
necessary? - In the same definition, the part
rs = reach1From s au \\ ex
takes time linear in the size ofex
. Using a set (or hash) instead of a list forex
would probably improve your running time significantly in practice. But of course, that'd likely be at the expense of the clarity of your beautiful program. - You are of course right that your program checks "states excluded in other branches". What you are "really" implementing is depth-first search (DFS) on the graph defined by the automaton, and so you might want to look for a more efficient (functional) implementation of DFS. In that case, you could either look at the Haskell Library implementation, or maybe just this quick-and-dirty approach quick-and-dirty approach.
This is neat, methinks.
A couple of questions/points:
- Is the
|| any (== s') rs
part ofcanReachExcluding
necessary? - In the same definition, the part
rs = reach1From s au \\ ex
takes time linear in the size ofex
. Using a set (or hash) instead of a list forex
would probably improve your running time significantly in practice. But of course, that'd likely be at the expense of the clarity of your beautiful program. - You are of course right that your program checks "states excluded in other branches". What you are "really" implementing is depth-first search (DFS) on the graph defined by the automaton, and so you might want to look for a more efficient (functional) implementation of DFS. In that case, you could either look at the Haskell Library implementation, or maybe just this quick-and-dirty approach.
This is neat, methinks.
A couple of questions/points:
- Is the
|| any (== s') rs
part ofcanReachExcluding
necessary? - In the same definition, the part
rs = reach1From s au \\ ex
takes time linear in the size ofex
. Using a set (or hash) instead of a list forex
would probably improve your running time significantly in practice. But of course, that'd likely be at the expense of the clarity of your beautiful program. - You are of course right that your program checks "states excluded in other branches". What you are "really" implementing is depth-first search (DFS) on the graph defined by the automaton, and so you might want to look for a more efficient (functional) implementation of DFS. In that case, you could either look at the Haskell Library implementation, or maybe just this quick-and-dirty approach.
This is neat, methinks.
A couple of questions/points:
- Is the
|| any (== s') rs
part ofcanReachExcluding
necessary? - In the same definition, the part
rs = reach1From s au \\ ex
takes time linear in the size ofex
. Using a set (or hash) instead of a list forex
would probably improve your running time significantly in practice. But of course, that'd likely be at the expense of the clarity of your beautiful program. - You are of course right that your program checks "states excluded in other branches". What you are "really" implementing is depth-first search (DFS) on the graph defined by the automaton, and so you might want to look for a more efficient (functional) implementation of DFS. In that case, you could either look at the Haskell Library implementation, or maybe just this quick-and-dirty approach.
lang-hs