tag:blogger.com,1999:blog-7094652.post1950548425868040354..comments2024-03-23T14:36:09.980+00:00Comments on Neil Mitchell's Blog (Haskell etc): Finite Resources in ShakeNeil Mitchellhttp://www.blogger.com/profile/13084722756124486154noreply@blogger.comBlogger5125tag:blogger.com,1999:blog-7094652.post-79568741533394770102013-03-04T22:46:31.890+00:002013-03-04T22:46:31.890+00:00In many other circumstances, StateT would be exact...In many other circumstances, StateT would be exactly the right solution. I had to modify the core of Shake to allow an IO function in the Rules monad, so it wasn't trivial (which is part of the reason that adding it to the library is useful).Neil Mitchellhttps://www.blogger.com/profile/13084722756124486154noreply@blogger.comtag:blogger.com,1999:blog-7094652.post-34344346309398677482013-03-04T22:43:00.655+00:002013-03-04T22:43:00.655+00:00Thanks for the clarification. I didn't take th...Thanks for the clarification. I didn't take the time to read the function signature clearly. It is much clearer now.<br /><br />(My understanding of haskell is still far from good, this is why I mentioned StateT, but I can see the problem.)Anonymoushttps://www.blogger.com/profile/17919373353084134648noreply@blogger.comtag:blogger.com,1999:blog-7094652.post-43299219226405715862013-03-03T22:42:28.147+00:002013-03-03T22:42:28.147+00:00I notice the documentation for newCache isn't ...I notice the documentation for newCache isn't great, so I'll clarify your question there as well, and add an example.Neil Mitchellhttps://www.blogger.com/profile/13084722756124486154noreply@blogger.comtag:blogger.com,1999:blog-7094652.post-77294865405342127452013-03-03T22:41:00.996+00:002013-03-03T22:41:00.996+00:00Cédric: Each call to newCache/newCacheIO creates a...Cédric: Each call to newCache/newCacheIO creates a brand new cache distinct from all previous ones. So you call 'cache <- newCache' exactly once, then reuse the resulting 'cache' function many times. If you call the functions twice, they use different caches.<br /><br />This feature is implemented entirely using IO and MVars, so no StateT/monad-transformer stuff. <br />I'm not sure you could do this in Shake using StateT since Shake locks down the Action and Rules types. You'd need to put it inside the core of Shake.Neil Mitchellhttps://www.blogger.com/profile/13084722756124486154noreply@blogger.comtag:blogger.com,1999:blog-7094652.post-66978464137150260332013-03-03T15:59:10.630+00:002013-03-03T15:59:10.630+00:00Maybe a little off topic but thanks for the newCac...Maybe a little off topic but thanks for the newCache function. I was thinking that I needed this functionality just yesterday and here it is :) [meaning I don't need to learn about StateT and monad transformer right now]<br /><br />I suppose that newCache and newCacheIO use the same cache?Anonymoushttps://www.blogger.com/profile/17919373353084134648noreply@blogger.com