[Haskell-cafe] Re: optimization help
apfelmus at quantentunnel.de
apfelmus at quantentunnel.de
Tue Oct 17 04:49:08 EDT 2006
> I think that you misunderstood what I said. When we went from FRP to Yampa, we
> changed from using signals directly, i.e. Signal a, to using signal functions, i.e.:
>
> SF a b = Signal a -> Signal b
>
> When we did this, we made SF abstract, and we adopted the arrow framework to
> allow composing, etc. signal functions. This meant that you could not get your
> hands on Signals directly, which helped to prevent space leaks.
>
> What you describe above is a change that we made in the /implementation/ of
> signal functions (specifically, from streams to continuations), which indeed is
> an entirely different thing.
You mean that only the fact that (Signal a -> Signal b) got abstract
prevented space leaks? Can you give an example?
That the implementation with continuations avoids space leaks is clear.
The question is whether the old does when using the new primitives. In
fact, this amounts to the question whether (inject) as defined in
newtype SF' a b = SF' ([a] -> [b])
data SF a b = SF (a -> (b, SF a b))
inject :: SF a b -> SF' a b
inject (SF f) (a:as) = let (b,g) = f a in b:inject g as
preserves space and time complexity:
inject (sf `o` sf') =same space &time= (inject sf) . (inject sf')
and the same for all other operations you provide besides `o`.
Regards,
apfelmus
More information about the Haskell-Cafe
mailing list