-
Notifications
You must be signed in to change notification settings - Fork 645
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
Ordering of Effects when calling effectual programs. #1837
Comments
On 8 Jan 2015, at 14:02, Jan de Muijnck-Hughes [email protected] wrote:
Not easily - it would need the ‘SubList’ proof to be cleverer and be able to detect changes in ordering as well as merely missing elements, and we’d need some kind of automated proof search to spot this (it might not work with proof search, depending on how it was done). It would be nice, at least, if we could add some kind of explicit effect permutation operator, otherwise there’s difficulty in composing effectful programs. Now that we’ve been using Effects for a few different things, especially with resource tracking, I’m getting a better idea of what the annoyances are and what the requirements should have been if only I’d known what I was doing when I started ;). I’m playing around with a few ideas separately so we’ll see what happens… |
Oh yeah, I should have lead with: I knew somewhat about the 'restrictions' but wanted to make public a note about them, as I don't think we had done so yet. This issue was submitted on the back of effects library complaining about my error-ful code not working, and me not realising there were errors in my code. |
Has there been any progress on this issue? I see that there is still the same |
By the way, I figured out a simple (albeit somewhat naive) way to solve this problem: data SubElem : a -> List a -> Type where
Here : SubElem a (a :: as)
There : SubElem a as -> SubElem a (b :: as)
data SubList : List a -> List a -> Type where
SubNil : SubList [] xs
InList : SubElem x ys -> SubList xs ys -> SubList (x :: xs) ys I checked this with proof search and it does work as expected with no additional coercion required. The issue seems to be that this would make |
@aaronc It might be that the simple solution you suggest is okay in practice so I'd suggest giving it a go. I have a longer term plan to reimplement the effects library so that updateWith, rebuildEnv, etc can be run at compile time with known proofs. I haven't tried this yet mainly because early experiments suggested there wasn't that much performance benefit, and because I can't guarantee it'll actually work without some tradeoffs... nevertheless, we're still playing here so it's worth having a go and seeing what the consequences are. As you say, it seems likely that there are ways to speed it up in any case. |
Okay, so when I get a free moment, I'll give this refactoring a try. I'm thinking of trying to use |
Unfortunately, |
Would it be possible to optimize it or is that too complex? By the way, I just wanted to mention that I did do a like benchmark to measure the overhead of Effects when doing actual IO. Looks like it's on the order 40% over just straight monad IO, which is in my mind acceptable for most cases. I'm imagining that with either the optimization that Edwin is talking about or just using native arrays, there would be significantly less slowdown. |
It's not that it's complex, just that it would be nicer to have a more I'm not sure there'd be much benefit in using Vects over Lists here The overhead will depend on quite a lot of things - how much pure On 14/12/2015 17:13, Aaron Craelius wrote:
|
Closing this issue, as it appears to have been fixed. |
When I trying to run this game http://docs.idris-lang.org/en/latest/effects/hangman.html I faced next thing. When type of game is game : Eff () [MYSTERY (Running (S g) w), STDIO] [MYSTERY NotRunning, STDIO] code is compiled. But if I change it to game : Eff () [STDIO, MYSTERY (Running (S g) w)] [STDIO, MYSTERY NotRunning] the compiler does not like it anymore. It looks to me like it can be the same problem. Sorry if I've missed something. Source code is attached. |
The effects tutorial mentions that the specification order for a list of effects does not matter. When an effectual function is treated in isolation this is true. However, ordering does matter between effectful functions. For instance, given the following program:
The program does not compile as the list of effects used is 'out-of-order'.
Can
Effects
be fixed such that ordering does not matter across an effectual program?The text was updated successfully, but these errors were encountered: