[Haskell-cafe] Animas/Yampa - Using Zip as a Routing Function in a Parallel Switch with Feedback

M. George Hansen technopolitica at gmail.com
Tue Sep 20 00:46:32 CEST 2011


> process
>    :: [Activity]
>    -> SF [InputEvent] SystemOutput
> process activities
>    = proc inputEvents -> do
>        rec
>            let senses = map (\state -> (inputEvents, state)) states
>            states <- par route activities -< senses
>        returnA -< states
>
> route
>    :: [Sense]
>    -> [sf]
>    -> [(Sense, sf)]
> -- route a sfs = fmap (\sf -> (head a, sf)) sfs
> route = zip

For those who are interested, I found a "solution" (more of a hack, really):

route a  sfs = zip (take num a) sfs
    where
        num = length sfs

In other words, constraining the size of the input list to that of the
signal functions list was the answer. This isn't an ideal solution
though since it silently throws away any "extra" input that might be
introduced by buggy callers, and I still don't understand the problem
with my original code.

-- 
  M. George Hansen
  technopolitica at gmail.com



More information about the Haskell-Cafe mailing list