New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
simulate
&c. should be Stream a -> Stream b
?
#1255
Comments
I dunno... in principle, simulate is isomorphic to: :: (Stream a -> Stream b) -> ([a] ->[b]) i.e., why don't you make driveIO :: (Signal dom i -> Signal dom o) -> i -> IO ((o -> IO i) -> IO ()) and use |
On Fri, 10 Apr 2020, Christiaan Baaij wrote:
I dunno... in principle, simulate is isomorphic to:
:: (Stream a -> Stream b) -> ([a] ->[b])
i.e., why don't you make driveIO :
driveIO :: (Signal dom i -> Signal dom o) -> i -> IO ((o -> IO i) -> IO ())
and use Clash.Signal.Internal ?
Doesn't that mean that I would have to implement a whole family of
`driveIO` functions, one for each variant of `simulate`? I know
of at least `simulate`, `simulateB` and `simulate_lazy`.
In other words, I would like to "outsource" all these decisions about
simulation details to my callers.
|
So I agree that Now, if we really want them to return a module Clash.Prelude where
simulate :: ... -> ([a] -> [b]) module Clash.Prelude_1_4 where
simulate :: ... -> (Stream a -> Stream b) i.e. if you want to have the new API, you will have to import the new Prelude. Now... this is just an initial sketch... as I'm unsure how this affect sanely importing code written against |
On Sat, 11 Apr 2020, Christiaan Baaij wrote:
module Clash.Prelude_1_4 where
simulate :: ... -> (Stream a -> Stream b)
i.e. if you want to have the new API, you will have to import the new Prelude.
How about new functions in Clash.Prelude (simulateS &c.) and marking the
list ones as deprecated?
|
What names would you suggest for these new functions? |
My issue with new names + deprecation is that you lose the nicer (shorter) names to deprecated functions; or worse, that you change them on the release following the deprecation, e.g. Clash 1.2
Clash 1.4
Clash 1.6
Clash 1.8
Clash 1.10
i.e. it takes 4 releases to get |
I guess a 3rd option would be to export the new Stream-based |
I can't really comment on this issue because I am not familiar with the kind of compatibility guarantees you hope to give. If it were up to me, I'd just change the type of |
I want people to be able to use the latest version of Clash, that has all the bug fixes, without them having to change their code. This way, things like blog posts and other "stale" code doesn't go out of date. |
Thinking about this a bit more, I am now starting to think that maybe
would in fact be the right idea, because even if |
…ating on list functions (clash-lang/clash-compiler#1255)
…ating on list functions (clash-lang/clash-compiler#1255)
Just in case anyone is interested, here's the version I'm settling on:
|
@christiaanb In this particular instance you could introduce a type class instead: simulate :: StreamLike f => ... -> (f a -> f b) And put the deprecation warning on the instance for list (if that's even possible). That would reduce the turn-around time to two releases, at the expensive of an ugly type signature in one release. |
Still, it wouldn't work around the problem of old code snippets.. I guess we could drop |
Thinking about this some more... Even if it returned a Instead, could you expose a primitive that one could use to simulate into lists, or streams, or IO, or anything else? I am thinking of an interface like the following:
Then, present-day What do you think? |
I guess the right library type for this would be
|
We can copy: https://git.smart-cactus.org/ben/clash-testbench/-/blob/master/src/Clash/Testbench/StreamSignal.hs#L17-52 for the implementation of |
@gergoerdi I've started the work at: #1261 |
@gergoerdi Are the:
signalAutomaton ::
forall dom a b.
(Signal dom a -> Signal dom b) ->
Automaton (->) a b and:
signalAutomaton ::
forall dom a b.
KnownDomain dom =>
(HiddenClockResetEnable dom => Signal dom a -> Signal dom b) ->
Automaton (->) a b functions in #1261 sufficient for your needs? |
@gergoerdi That is to say: could you test them whether they have space leaks for your use-case? |
As of a478454 I can confirm that my Brainfuck computer doesn't show any signs of space leak with the following implementation of
I will later try to also do some performance measurements, but I don't have a setup for that (https://github.com/gergoerdi/clash-bounce-bench doesn't use Not to look a gift horse too much in the mouth, but I was hoping that with full access to Clash |
Full source:
|
I have no idea how to implement |
Well my comment was based on the idea that unlike a library like what I'm writing, you can do any needed violence to |
gergoerdi commentedApr 10, 2020
The various non-
N
family ofsimulate
functions are supposed to be applied on infinite lists, and in response return infinite lists. Would it make sense to change their type to consume and returnStream
s?I'm asking because I'd like to write something like this:
and this crucially depends on
outs
never becoming[]
.The text was updated successfully, but these errors were encountered: