Re: [Haskell-cafe] Poll plea: State of GUI graphics libraries in Haskell
I don't think I would quite say haskell-game is quite relevant. For that matter, the implementation on GitHub is not very good. It's too complicated to scale and too specialized. I've been starting a fresh implementation, since I learned a lot about what I really want to do writing that, but it is not public yet. That said, I think our efforts on haskell-game are definitely complementary with efforts to improve GUI programming with Haskell, and we should collaborate where it makes sense. On Fri, Oct 4, 2013 at 11:19 AM, Alp Mestanogullari alpmes...@gmail.comwrote: Hi guys, I have been willing to have a nice GUI DSEL with good aesthetics for a while. I think the hardest part wouldn't be the API, but really what library we use underneath so that it's cross-platform and easy to install for everyone. But I would love for something like that to happen and am very interested in this. Note that people from #haskell-game are experimenting a bit (I think it's mostly Jake McArthur's work for now), see the brainstorming (ideas) and graphics (partial impl) repositories at [1]. [1]: https://github.com/haskell-game On Thu, Oct 3, 2013 at 12:28 AM, Conal Elliott co...@conal.net wrote: Interesting. How are the aesthetics? Can you point me to screen shots? It'd be a lot of work, but one cool project would be to create *beautiful* GUI elements using OpenGL programmable shaders. Given the speed of GPUs, we could afford to put a lot into visual details. A complementary project is designing a semantically precise and elegant (denotative/genuinely functional to use Peter Landin's terms) GUI DSEL that would be simpler and more powerful than the conventional OO-inspired libraries we have so much trouble getting to work in Haskell. I've thought about this sort of thing on and off for a very long time and would be happy to be involved if others are interested also. Together, these two efforts would yield an approach to GUIs that is beautiful inside and out. -- Conal On Wed, Oct 2, 2013 at 1:21 PM, Paul Liu nine...@gmail.com wrote: No. GLFW does not give you any UI elements, just basic windowing and input handling. Euterpea has a UI layer on top of GLFW that provides text boxes and sliders, etc, entirely written in Haskell. On Wed, Oct 2, 2013 at 8:40 AM, Conal Elliott co...@conal.net wrote: Hi Paul. Is there a way to use GLFW with GUI elements other than OpenGL display windows, e.g., text boxes and sliders? -- Conal On Tue, Oct 1, 2013 at 11:23 PM, Paul Liu nine...@gmail.com wrote: Thanks. I've just built GHC HEAD on Mac OS X Lion, and tested by installing libraries with --enable-shared and loading a GLFW program into GHCi. Using ghci -fno-ghci-sandbox, everything works great including closing and restarting GL window multiple times. Can't wait for the official release of GHC 7.8! On Tue, Oct 1, 2013 at 12:09 PM, Carter Schonwald carter.schonw...@gmail.com wrote: thats the linker bug. the glfw stuff has been tested on ghc HEAD / 7.7 by folks on #haskell-game in recent memory. GHCI + foreign libs should work fine now (modulo thread local storage related thing). the historical element doesn't matter any more. To the best of my knowledge, all such issues should be gone. Anyone who cares about making sure GHCI+ gui libs play nice, PLEASE test with HEAD. the better this issue is properly tested (which i believe it has been), the more we can actually prevent it from happening. This requires people to test with HEAD GHCi now, rather than doing archaeology. anyone who cares, please play with GHCI in HEAD. If your lib doesn't work with ghci, please report a bug. It would be a new bug because it wont' be the previous reasons it hasnt' worked. tl;dr to the best of my knowledge this issue is resolved in HEAD. Test HEAD. Help us make sure it stays resolved by testing HEAD. thanks -Carter On Tue, Oct 1, 2013 at 1:20 PM, Paul Liu nine...@gmail.com wrote: I reported a problem with statically linked GLFW library on Mac OS X Lion in this thread: http://www.haskell.org/pipermail/haskell-cafe/2012-January/097355.html I do not know why this is broken on Mac OS X Lion, but not on Linux or Windows. There was an EnableGUI hack for GHC 7.2 (and previous versions) and OS X version before Lion, but it no longer works. So I'm not sure if it is OS X Lion, or GLFW, or GHC, or a combination of them that caused this problem. Regards, Paul Liu On Tue, Oct 1, 2013 at 7:04 AM, Carter Schonwald carter.schonw...@gmail.com wrote: Hey simon, the two issues that have recurrently bit ghci interaction with foreign GUI libs are 1) the ghci linker. This is fixed in head by now having ghci use the system linker 2) some GUI libs require thread local state, and ghci has a flag for that
Re: [Haskell-cafe] Identity of indiscernibles (Was: Alternative name for return)
I don't know what the denotation for this would be, but I can't think of any reasonable ones for which I can write (==) to respect the denotation. For example, is set A, then set B equal to set B, then set A? Maybe you could argue that they aren't operationally equivalent, but can you guarantee that such reordering are *never* operationally equivalent? How about an action that take an input from stdin and then outputs the result of some computation based on it? How do you compare two such actions? I disagree with Jerzy on the purity of IO, but I don't think this line of argument is bound to be very fruitful. Jerzy, taking a similar example to that last one, would you say functions are impure just because I can't write a general (==) for them? I don't see what bountiful numbers of operations has to do with purity. - Jake On Aug 8, 2013 7:21 AM, Tom Ellis tom-lists-haskell-cafe-2...@jaguarpaw.co.uk wrote: On Thu, Aug 08, 2013 at 11:38:08AM +0200, Jerzy Karczmarczuk wrote: Tom Ellis: If I were writing a Haskell compiler I could certainly define 'IO' to be a datatype that would allow me to compare 'putStr c' to itself. The comparison could not be of operational equivalence, but it would still be possible to compare values in IO in a reasonable sense. Would you add to all this: getLine == getLine etc.? Good luck! I suspect that you would have to establish also the equality relation between functions and between infinite streams. And you would end as Giordano Bruno and Jeanne d'Arc. But for different reasons. Not at all. One could simply implement IO as a free monad, to take one example. Tom ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Identity of indiscernibles
Ah! It seems that my wording was ambiguous. All I was trying to say is that there is nothing you can do with an IO action which will cause an otherwise pure expression to exhibit side effects during evaluation, *not* that an IO action is observable in pure code or that they are arbitrarily manipulable. On Aug 8, 2013 9:39 AM, Jerzy Karczmarczuk jerzy.karczmarc...@unicaen.fr wrote: I am sorry for having mixed-up arguments (but who throws the first stone?...) Jerzy seemed to suggest that the impurity of IO was somehow related to it not supporting very many operations. No, not really. I added First, it is not true that you can do with, say, (printStr Ho! ) whatever you want. In fact, you can do almost nothing with it. You can transport it as such, and you can use it as the argument of (=). after the message of Jake McA. *You can do whatever you want with them* with no harmful effects in any Haskell expression. This was an additional layer of bikeshedding, not exactly about purity. Or, just a bit: the ONLY real operation on an action, i.e. (=) produces side-effects... Other don't, but -- Again, here my point is that calling pure an entity which is opaque and inert, is meaningless (or redundant if you wish...), this was all. Jerzy K. PS. Tom Ellis: One could simply implement IO as a free monad Interesting. I wonder how. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Alternative name for return
But IO actions *are* pure values. What side effects do they have? None! You can do whatever you want with them with no harmful effects in any Haskell expression. They only special thing about them is that they have a run function that is not itself provided in Haskell. The run function is actually not legal to expose in pure Haskell. Even if it were exposed, *that function* would be the impure thing, not the IO actions you apply it to. (This is why GHC has unsafePerformIO and not UnsafeIO). - Jake On Aug 6, 2013 5:29 AM, J. Stutterheim j.stutterh...@me.com wrote: That argument makes sense, although I find it a bit counter-intuitive still. If I saw the function `pure` for the first time, my first impression (however wrong it may be) would be that it takes a pure value (regardless of context) and does something with it. Applying `pure` to an IO operation goes against that intuition. Looking at the type of `return :: a - m a, there are several slightly more intuitive (to me) options in this discussion already: lift: the value `a` is lifted into the monad `m` pack: the value `a` is packed into the monad `m` wrap: the value `a` is wrapped in the monad `m` inject: the value `a` is injected into the monad `m` promote: the value `a` is promoted to a monad `m a` On 6 Aug 2013, at 10:16, Tobias Dammers tdamm...@gmail.com wrote: It is a pure value in the context of the outer monad (the one you wrap it in). I'd say pure is still appropriate. On Aug 6, 2013 10:14 AM, Tom Ellis tom-lists-haskell-cafe-2...@jaguarpaw.co.uk wrote: On Tue, Aug 06, 2013 at 10:03:04AM +0200, J. Stutterheim wrote: `putStrLn Hi` is not a pure value... Why not? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Contravariant applicatives, monads and arrows (was ANN: rematch, an library for composable assertions with human readable failure messages)
The type looks similar to the denotation for sets, but implementing a covariant interface for it would not be straightforward and may also be inefficient. On Apr 16, 2013 11:17 AM, Alejandro Serrano Mena trup...@gmail.com wrote: Hi, First of all, let me say that this work on matchers is really useful :) Following Roman advice, I'm trying to find a more principled approach that could be useful for this library. It seems that Match could easily be converted to Either and thus made into Functor, Applicative, Alternative and Monad. That would allow to write things like: User $ runMatch (isNot isEmpty) name * runMatch (hasItem (is '@')) email However, I'm also thinking about the correct way to combine matchers to get bigger matchers. Basically, if I have matchers on every field of a record, can I get a matcher for the entire one? My first idea was to make Matcher a functor. However, what I come was a contravariant functor: given (a - b) and Matcher b, I can easily construct a Matcher a by running the one in b over this function. So we have: contramap :: (a - b) - Matcher b - Matcher a My first question is: is there any structure similar to applicative functors or monads which work on these kind of contravariant functors? This also brought into my mind to see Matcher a just as functions a - Match and derive its properties from there. This may give better results that the above mentioned idea of looking it as a - Either String a, because in this latter case we have a in covariant and contravariant positions and it's difficult to get anything. On the other hand, it seems very easy, from a Matcher a and a Matcher b, to get a Matcher (a,b). This reminds me a bit about arrows, but without output parameters. Does it make sense? I've always been reluctant to arrows because I don't fully understand them, but maybe this is a good moment to learn. Do any of this make sense? I would really like to contribute to this great library! :) 2013/4/16 Tom Crayford tcrayf...@gmail.com: Roman, Thanks for the feedback! I'd originally left the QuickCheck and HUnit implementations in this library for convenience, thinking that there aren't going to be many people who care about the transitive dep. But you care, so I'm happy moving them out of core. I'll release a 0.2 with both the HUnit and the QuickCheck runners in separate libraries soonish. Thanks for the haddock tip and the implementation tips. Re the Control namespace, these matchers aren't exclusively a testing tool. I've been using the core api for other purposes as well (primarily for validating forms in user interfaces in conjunction with digestive-functors). I couldn't figure anything better to put it in apart from Control (I definitely don't want it in Test, even though that's going to be what most people use it for). I guess it could be in `Data`, but that doesn't sound much better to me. I'm not amazingly strong at building more principled interfaces right now, so I guess that's something I'll improve on. Are there any concrete suggestions you have there? I'd *like* these to have an `Alternative` instance, but making `Applicative`/`Functor` instances is beyond me right now (I guess I'd have to change the core API for that to work out). Tom ... ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Advice on type families and non-injectivity?
I have a trick that loses a little convenience, but may still be more convenient than data families. {-# LANGUAGE TypeFamilies #-} import Data.Tagged type family F a foo :: Tagged a (F a) foo = Tagged undefined bar :: Tagged a (F a) bar = foo This allows you to use the same newtype wrapper consistently, regardless of what the type instance actually is; one of the inconveniences of data families is the need to use different constructors for different types. On Sun, Jan 13, 2013 at 2:10 PM, Conal Elliott co...@conal.net wrote: I sometimes run into trouble with lack of injectivity for type families. I'm trying to understand what's at the heart of these difficulties and whether I can avoid them. Also, whether some of the obstacles could be overcome with simple improvements to GHC. Here's a simple example: {-# LANGUAGE TypeFamilies #-} type family F a foo :: F a foo = undefined bar :: F a bar = foo The error message: Couldn't match type `F a' with `F a1' NB: `F' is a type function, and may not be injective In the expression: foo In an equation for `bar': bar = foo A terser (but perhaps subtler) example producing the same error: baz :: F a baz = baz Replacing `a` with a monotype (e.g., `Bool`) eliminates the error. Does the difficulty here have to do with trying to *infer* the type and then compare with the given one? Or is there an issue even with type *checking* in such cases? Other insights welcome, as well as suggested work-arounds. I know about (injective) data families but don't want to lose the convenience of type synonym families. Thanks, -- Conal ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Navigating 'Strategic' programming babel
I won't compare and contrast all these, but I want to point out that there is a nicer version of uniplate in the lens package. On Dec 17, 2012 5:31 AM, Ravi Sahni ganeshsahn...@gmail.com wrote: Clearly Haskell has great possibilities in the field of language-processing. And the nuisances associated with little actual computation buried under much data-structure navigation are well addressed by 'strategic-programming' systems. But now comes the rub -- there seem to be a lot of very similar systems. Any guidance on which/what/how to choose? My own current sketchy-patchy knowledge is as below. I would appreciate links/pointers to more substansive literature. First there was Meertens and his folks working on generic haskell Did that later become template haskell? That branched out into strafunski, stratego/xt. SYB is ___ not sure here: some literature suggests that its identical to strafunski. Some suggests that it is strafunski done more within the haskell language rather than in libraries. Then there's uniplate. How does it compare to SYB? Or is that a confused comparison? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Problem with benchmarking FFI calls with Criterion
I once had a problem like this. It turned out that my laptop was stepping the cpu clock rate down whenever it got warm. Disabling that feature in my BIOS fixed it. Your problem might be similar. On Nov 27, 2012 7:23 AM, Janek S. fremenz...@poczta.onet.pl wrote: I tested the same code on my second machine - Debian Squeeze (kernel 2.6.32) with GHC 7.4.1 - and the results are extremely surprising. At first I was unable to reproduce the problem and got consistent runtimes of about 107us: benchmarking FFI/C binding mean: 107.3837 us, lb 107.2013 us, ub 107.5862 us, ci 0.950 std dev: 983.6046 ns, lb 822.6750 ns, ub 1.292724 us, ci 0.950 benchmarking FFI/C binding mean: 108.1152 us, lb 107.9457 us, ub 108.3052 us, ci 0.950 std dev: 916.2469 ns, lb 793.1004 ns, ub 1.122127 us, ci 0.950 I started experimenting with the vector size and after bumping its size to 32K elements I started getting this: benchmarking FFI/C binding mean: 38.50100 us, lb 36.71525 us, ub 46.87665 us, ci 0.950 std dev: 16.93131 us, lb 1.033678 us, ub 40.23900 us, ci 0.950 found 6 outliers among 100 samples (6.0%) 3 (3.0%) low mild 3 (3.0%) high severe variance introduced by outliers: 98.921% variance is severely inflated by outliers benchmarking FFI/C binding mean: 209.9733 us, lb 209.5316 us, ub 210.4680 us, ci 0.950 std dev: 2.401398 us, lb 2.052981 us, ub 2.889688 us, ci 0.950 First result is always about 39us (2,5 faster, despite longer signal!) while the remaining benchmarks take almost two times longer. Janek Dnia niedziela, 25 listopada 2012, Janek S. napisał: Well, it seems that this only happens on my machine. I will try to test this code on different computer and see if I can reproduce it. I don't think using existing vector is a good idea - it would make the code impure. Janek Dnia sobota, 24 listopada 2012, Branimir Maksimovic napisał: I don't see such behavior neither.ubuntu 12.10, ghc 7.4.2. Perhaps this has to do with how malloc allocates /cachebehavior. If you try not to allocate array rather use existing one perhaps there would be no inconsistency?It looks to me that's about CPU cache performance. Branimir I'm using GHC 7.4.2 on x86_64 openSUSE Linux, kernel 2.6.37.6. Janek Dnia piątek, 23 listopada 2012, Edward Z. Yang napisał: Running the sample code on GHC 7.4.2, I don't see the one fast, rest slow behavior. What version of GHC are you running? Edward Excerpts from Janek S.'s message of Fri Nov 23 13:42:03 -0500 2012: What happens if you do the benchmark without unsafePerformIO involved? I removed unsafePerformIO, changed copy to have type Vector Double - IO (Vector Double) and modified benchmarks like this: bench C binding $ whnfIO (copy signal) I see no difference - one benchmark runs fast, remaining ones run slow. Janek Excerpts from Janek S.'s message of Fri Nov 23 10:44:15 -0500 2012: I am using Criterion library to benchmark C code called via FFI bindings and I've ran into a problem that looks like a bug. The first benchmark that uses FFI runs correctly, but subsequent benchmarks run much longer. I created demo code (about 50 lines, available at github: https://gist.github.com/4135698 ) in which C function copies a vector of doubles. I benchmark that function a couple of times. First run results in avarage time of about 17us, subsequent runs take about 45us. In my real code additional time was about 15us and it seemed to be a constant factor, not relative to correct run time. The surprising thing is that if my C function only allocates memory and does no copying: double* c_copy( double* inArr, int arrLen ) { double* outArr = malloc( arrLen * sizeof( double ) ); return outArr; } then all is well - all runs take similar amount of time. I also noticed that sometimes in my demo code all runs take about 45us, but this does not seem to happen in my real code - first run is always shorter. Does anyone have an idea what is going on? Janek ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Optimal line length for haskell
I stick to 80 columns fairly rigidly. This is not only so that it fits into narrow windows, but also so that any two subexpressions in the same expression tend to be close together on my screen, which makes it easier for me to reason about it. If only it was easy for me to read and write code on a Hilbert curve... :) I don't think long lines indicate a design problem; it's solely a formatting thing. On Mon, Oct 29, 2012 at 7:50 AM, Rustom Mody rustompm...@gmail.com wrote: There was a recent discussion on the python list regarding maximum line length. It occured to me that beautiful haskell programs tend to be plump (ie have long lines) compared to other languages whose programs are 'skinnier'. My thoughts on this are at http://blog.languager.org/2012/10/layout-imperative-in-functional.html. Are there more striking examples than the lexer from the standard prelude? [Or any other thoughts/opinions :-) ] Thanks, Rusi ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Building all possible element combinations from N lists.
I golfed a bit. :) sequence = filterM (const [False ..]) On Thu, Oct 25, 2012 at 6:11 PM, dokondr doko...@gmail.com wrote: On Fri, Oct 26, 2012 Alex Stangl wrote: combos [] = [[]] combos ([]:ls) = combos ls combos ((h:t):ls) = map (h:) (combos ls) ++ combos (t:ls) Excellent, thanks! ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Why Kleisli composition is not in the Monad signature?
On Mon, Oct 15, 2012 at 11:29 PM, Dan Doel dan.d...@gmail.com wrote: I'm uncertain where this, compositional means written as the composition of functions, thing started. But it is not what I, and I'm sure any others mean by the term, compositional. You're right. It's a rather recent, as far as I can tell, overloading of the word that I inadvertently picked up. The meaning of this overloading, at least as I understand and intended it, is that it forms a category. I will try to avoid this use of the word in the future. For three, I can't for the life of me think of how anyone would write (=) as a primitive operation _except_ for writing (=) and then '(f = g) x = f x = g'. The function cannot be inspected to get the result except by applying it. This is a good point. I'd be down with putting join in the class, but that tends to not be terribly important for most cases, either. Join is not the most important, but I do think it's often easier to define than bind. I often find myself implementing bind by explicitly using join. - Jake ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Why Kleisli composition is not in the Monad signature?
On Mon, Oct 15, 2012 at 7:59 AM, Ertugrul Söylemez e...@ertes.de wrote: Try to express do x - getLine y - getLine print (x, y) using only Kleisli composition (without cheating). In my opinion, this is not as nice as the do-notation version, but at least it's compositional: print = ($ getLine) . (,) = const getLine $ () I do think there is value in favoring Kleisli composition for a lot of code. Unfortunately, however, it doesn't tend to work out so nicely for IO. - Jake ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Why Kleisli composition is not in the Monad signature?
On Mon, Oct 15, 2012 at 11:33 AM, Jake McArthur jake.mcart...@gmail.com wrote: On Mon, Oct 15, 2012 at 7:59 AM, Ertugrul Söylemez e...@ertes.de wrote: Try to express do x - getLine y - getLine print (x, y) using only Kleisli composition (without cheating). My previous answer didn't do the Kleisli style much justice. It could look a bit nicer with more Arrow-style combinators: f = g = runKleisli $ Kleisli f Kleisli g print = const getLine = const getLine $ () ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Image processing using Repa
You do not have to use computeIntoP. You can just use computeP followed by toForeignPtr (i don't remember the exact name for that and am on my phone so it would be awkward to look up). So Repa can create the buffer for you. Coincidentally, I didn't realize computeIntoP even existed, and I want it for what I'm doing! On Oct 10, 2012 7:55 AM, Janek S. fremenz...@poczta.onet.pl wrote: I'm playing a bit with Repa library and its DevIL bindings. I tried to modify one of the examples from tutorial on HaskellWiki. I want to load an image, rotate it and save it to disk. I managed to write something like this: import Foreign.Ptr import System.Environment import Data.Array.Repa as R hiding ((++)) import qualified Data.Array.Repa.Repr.ForeignPtr as RFP import Data.Array.Repa.IO.DevIL main = do [f] - getArgs (RGB v) - runIL $ readImage f RFP.computeIntoP (RFP.toForeignPtr v) (rot180 v) runIL $ writeImage (flip-++f) (RGB v) return () rot180 g = backpermute e flop g where e@(Z :. x :. y :. _) = extent g flop (Z :. i :. j :. k) = (Z :. x - i - 1 :. y - j - 1 :. k) This is obviously wrong, because the foreign pointer used as a data source is at the same time used as destination, so the data gets overwritten before it is used. Does this mean that I have to allocate foreign memory buffers on my own? If so, than it feels kind of painfull to go through the hassle of allocating foreign pointers, converting between many different representations and so on. Am I doing something wrong and if not is there a more painless way of working with images and repa in Haskell? Jan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Monads
On Sep 30, 2012 10:56 AM, Albert Y. C. Lai tre...@vex.net wrote: On 12-09-29 09:57 PM, Vasili I. Galchin wrote: I would an examples of monads that are pure, i.e. no side-effects. What does side effect mean, to you? Definition? When discussing monads, at least, a side effect is an effect that is triggered by merely evaluating an expression. A monad is an interface that decouples effects from evaluation. Because some people say State has no side effect, and some other people say State has side effects. The two groups use different definitions. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Fwd: [Haskell] ANNOUNCE: MFlow-0.1.5
Actually, I meant users that spawn multiple tabs from a single root session. You mentioned that you have some special support for the back button. What happens if I open a couple new tabs in which I may or may not go forward and backward. Do they all share the same state? Different states (how?)? Partially shared states? On Tue, Sep 18, 2012 at 12:33 PM, Alberto G. Corona agocor...@gmail.com wrote: Oh, I´m stupid. You mean web pages with multiple tabs I have not tested it. but each tab can be handled easily by a different server process.. or it can be handled in a single server process, like in a menu. For example, this code present different options, and the process renders different things depending on the response. The last option is a link to a different process, while the others( wlinks) are links that return back to the same process. The operator | is the applicative operator. a breakline is prepended to each link: data Ops= Ints | Strings | Actions | Ajax | Opt deriving(Typeable,Read, Show) mainf= do r - ask $ wlink Ints (bold increase an Int) | br ++ wlink Strings (bold increase a String) | br ++ wlink Actions (bold Example of a string widget with an action) | br ++ wlink Ajax (bold Simple AJAX example) | br ++ wlink Opt (bold select options) ++ (br +++ linkShop) -- this is an ordinary XHtml link case r of Ints- clickn 0 Strings - clicks 1 Actions - actions 1 Ajax- ajaxsample Opt - options mainf where linkShop= toHtml $ hotlink shop shopping . Alberto 2012/9/18 Alberto G. Corona agocor...@gmail.com: Hi Jake I don´t know what you mean with multiple tabs. The user management is simple, anonymous clients are identified with a cookie. if the user is logged (MFlow has widgets for logging-validation) the user is the identifier. The state of a process is associated to the client identifier and to the path invoked in the url requested. I don´t know if this answer your question Alberto 2012/9/18 Jake McArthur jake.mcart...@gmail.com: This sounds really cool. How do you handle users having multiple tabs? On Tue, Sep 18, 2012 at 11:26 AM, Alberto G. Corona agocor...@gmail.com wrote: Hi haskellers and specially the web developers. http://hackage.haskell.org/package/MFlow-0.1.5.3 MFlow is a is a Web framework with some unique, and I mean unique, characteristics that I find exciting: - It is a Web application server that start and restart on-demand stateful web server processes (not request.-response) This means that all the page navigation can be coded in a single procedure. This increases readability of the programmer code. I woul call it a anti-node.js. Buit usual request-response (stateless) server processes are also allowed - When the process is invoqued as result of an URL request, the Web app server not only restart the process but also recover its execution state. The enclosing Workflow monad provides the thread state persistence. There are state timeouts and process timeouts defined by the programmer. Processes with no persistent state (transient) are possible. -The user interface is made of widgets. They are formlets with added formatting, attributes, validations, modifiers and callbacks, that are composable, so the pieces are reusable and return type safe responses to the calling process. Even the links are part of widgets and return back type safe inputs at compile time to the calling server process. Tho glue these components, ordinary applicative combinators and other extra combinators are used. - The widgets and the communication don´t make assumptions about the architecture, so it can be adapted to non-web environments. This versions has interface for WAI-warp, Hack, Text.XHtml (xhtml) , and Haskell Server Pages. -The widget rendering can be converted to ByteStrings automatically with special combinators. A mix of widgets with different formats can be combined in the same source file. For example Text.Html and HSP (Haskell server pages) -These widgets can be cached, to avoid widget rendering on every interaction. -To handle the back button, and because the processes are stateful, they can run backwards until the response match. This is transparent for the programmer, thanks to the embedded FlowM monad. -All the code is in pure Haskell. No deployment, special scripts, formats etc are necessary. -Besides automatic state persistence, TCache provides transactions and user data persistence, that can be configured for SQL databases. Default persistence in files permit very rapid prototyping. Just code and run it with runghc. -Has AJAX support All of this sounds very complicated, but really it is simple!. Most of these things are transparent. The resulting code is quite
Re: [Haskell-cafe] mutable arrays of tuples
In fact, unboxed arrays of tuples are represented in vector as tuples of unboxed arrays. On Aug 9, 2012 4:35 AM, Ketil Malde ke...@malde.org wrote: David Feuer david.fe...@gmail.com writes: So I was thinking about a mutable array of tuples, but to avoid allocating tuples to modify their fields, I guess I really want an immutable array of tuples of STRefs. Just how much less efficient is this than a plain mutable array? might it even make sense to use parallel mutable arrays? The thought of that is disgusting to me, but at least one of the arrays could likely be made unboxed... Maybe you could use a tuple of (unboxed) arrays instead? Or if you use Vector instead of Array, I think tuples are member of Unbox (as long as the tuple elements are), and can be used directly in unboxed vectors. -k -- If I haven't seen further, it is by standing in the footprints of giants ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Knight Capital debacle and software correctness
I feel like this thread is kind of surreal. Knight Capital's mistake was to use imperative programming styles? An entire industry is suffering because they haven't universally applied category theory to software engineering and live systems? Am I just a victim of a small troll/joke? - Jake On Sat, Aug 4, 2012 at 12:46 PM, Jay Sulzberger j...@panix.com wrote: On Sat, 4 Aug 2012, Vasili I. Galchin vigalc...@gmail.com wrote: Hello Haskell Group, I work in mainstream software industry. I am going to make an assumption except for Jane Street Capital all/most Wall Street software is written in an imperative language. Assuming this why is Wall Street not awaken to the dangers. As I write, Knight Capital may not survive the weekend. Regards, Vasili I believe this particular mild error was in part due to a failure to grasp and apply category theory. There are several systems here: 1. The design of the code. 2. The coding of the code. 3. The testing of the code. 4. The live running of the code. 5. The watcher systems which watch the live running. If the newspaper reports are to be believed, the watcher systems, all of them, failed. Or there was not even one watcher system observing/correcting/halting at the time of running. Category theory suggests that all of these systems are worthy of study, and that these systems have inter-relations, which are just as worthy of study. oo--JS. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] vector operations
Have you already verified that stream fusion won't just do this for you? On May 23, 2012 12:35 AM, Evan Laforge qdun...@gmail.com wrote: So I wanted to find the first index in a vector whose running sum is greater than a given number. The straightforward way is to create the running sum and then search: Vector.findIndex (=target) (Vector.scanl' (+) 0 vector) But vectors are strict so it could do extra work, and what if I don't want to generate garbage? I could do it with a fold, but it would have to have the ability to abort early. Of course I could write such a fold myself using indexing: import qualified Data.Vector.Generic as Vector fold_abort :: (Vector.Vector v a) = (accum - a - Maybe accum) - accum - v a - accum fold_abort f accum vec = go 0 accum where go i accum = maybe accum (go (i+1)) $ f accum = vec Vector.!? i find_before :: (Vector.Vector v a, Num a, Ord a) = a - v a - Int find_before n = fst . fold_abort go (0, 0) where go (i, total) a | total + a = n = Nothing | otherwise = Just (i+1, total+a) So it's bigger and clunkier, but I would think it would be much more efficient (provided using Data.Vector.Generic won't inhibit inlining and unboxing). But I'm a bit surprised there isn't already something like fold_abort... or is there? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Template Haskell vs Rewrite Rules?
I once experimented with something similar. This is a preprocessor. This was a long time ago, and I don't use it. https://patch-tag.com/r/jmcarthur/overloaded-whitespace/snapshot/current/content/pretty/Main.hs On Thu, Apr 19, 2012 at 8:40 AM, Ismael Figueroa Palet ifiguer...@gmail.com wrote: Hi Michael! Thanks (again) for your answer. I'm not quite confident using TH yet, but it seems in your code you must define an 'app' function, and then use [overloadedApp|... |] as a quasiquoteator to inject the overloaded app, right? Thanks for the zeroth reference too, one question remains for me: what are the constrasts/differences between TH and RewriteRules? :-) 2012/4/19 Michael Sloan mgsl...@gmail.com You're in luck! This is something I've wanted to implement before in the past, and your email reminded me. While pretty awful, it could be used for doing some interesting value-interception instrumentation in Haskell. Recently I've been messing with TH a lot, so this initial implementation was rather straightforward. https://github.com/mgsloan/overload-app/blob/master/src/Language/Haskell/TH/OverloadApp.hs Usage: https://github.com/mgsloan/overload-app/blob/master/examples/Example1.hs Note: Relatively untested implementation, let me know if you find any problems! It only does this transformation to direct function application, unfortunately. In order to properly overload apply for infix operators, you'll need to be able to resolve fixities at compile time. This could be done by using the code in http://hackage.haskell.org/trac/haskell-prime/wiki/FixityResolution and using the fixity information yielded by TH's reify. Someone aught to have done this before, but I haven't seen it. Handling the applications involved in do-notation, comprehensions, enumerations, and anything else that's such direct syntax sugar would also be a bit of work (but could be very useful for other TH quasiquoting stuff!). You might also be interested in this: http://hackage.haskell.org/package/zeroth-2009.6.23.3 Hope that helps! -Michael Sloan On Wed, Apr 18, 2012 at 9:49 AM, Ismael Figueroa Palet ifiguer...@gmail.com wrote: I'm working on getting annotated versions of all instances of a function of a typeclass, and was wondering what are the relation/differences between Template Haskell and the Rewrite Rules section. Of course this is specific to GHC. Another question, in Racket, primitive function application is denoted #%app. And using macros I can re-export #%app to be a different function f, so a program: (g a) is rewritten into (f g a) is there a way to do the same thing using TH or Rewrite Rules? Thanks -- Ismael ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Ismael ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] adding the elements of two lists
This is interesting because it seems to be a counterexample to the claim that you can lift any Num through an Applicative (ZipList, in this case). It seems like maybe that only works in general for monoids instead of rings? On Mar 25, 2012 8:43 PM, Chris Smith cdsm...@gmail.com wrote: Jerzy Karczmarczuk jerzy.karczmarc...@unicaen.fr wrote: Le 26/03/2012 01:51, Chris Smith a écrit : instance (Num a) = Num [a] where xs + ys = zipWith (+) xs ys You can do this in the sense that it's legal Haskell... but it is a bad idea [...] It MIGHT be a ring or not. The real problem is that one should not confuse structural and algebraic (in the classical sense) properties of your objects. Of course there are rings for which it's possible to represent the elements as lists. Nevertheless, there is definitely not one that defines (+) = zipWith (+), as did the one I was responding to. By the time you get a ring structure back by some *other* set of rules, particularly for multiplication, the result will so clearly not be anything like a general Num instance for lists that it's silly to even be having this discussion. -- Chris Smith ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] adding the elements of two lists
Well, ZipList's pure is indeed repeat, but there is nothing about ZipList restricting it to infinite lists. As long as pure is repeat, I'm pretty sure any other value can still be finite without violating Applicative's laws. On Mar 26, 2012 1:02 PM, wren ng thornton w...@freegeek.org wrote: On 3/26/12 8:16 AM, Jake McArthur wrote: This is interesting because it seems to be a counterexample to the claim that you can lift any Num through an Applicative (ZipList, in this case). It seems like maybe that only works in general for monoids instead of rings? I'm not so sure about that. The Applicative structure of ZipLists is specifically defined for infinite lists (cf., pure = repeat). And in the case of infinite lists the (+) = zipWith(+) definition works just fine, since we don't have to worry about truncation. I wasn't aware that Num was supposed to be liftable over any Applicative, but this doesn't seem like a counterexample... -- Live well, ~wren __**_ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/**mailman/listinfo/haskell-cafehttp://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] In an imperative language, commands fulling memory cells is easy, but gives the false impression that S/W engineering is easy.
This mailing list is not Twitter. Please stop sending emails without meaningful content. On Mar 17, 2012 12:42 PM, KC kc1...@gmail.com wrote: -- -- Regards, KC ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] puzzling polymorphism behavior (7.0.3 windows)
Just a little more interesting information: This is why impure languages like OCaml have the value restriction. Haskell doesn't need it because it is pure, but of course unsafePerformIO thwarts that. On Mar 15, 2012 1:34 PM, Tillmann Rendel ren...@informatik.uni-marburg.de wrote: Hi, this is one of the reasons why unsafePerformIO is not type-safe. Lets see what's going on by figuring out the types of the various definitions. cell = unsafePerformIO $ newIORef [] newIORef returns a cell which can hold values of the same type as its arguments. The type of the empty list is [a], because an empty list could be a list of arbitrary elements. So the overall type of cell is: cell :: IORef [a] cell returns a cell which can hold lists of arbitrary elements. push i = modifyIORef cell (++ [i]) Lets say i is of some type b. Then cell needs to hold lists of the type b. So in this use of cell, the type variable is instantiated to b, and the overall type of push is: push :: b - IO () So push can accept arbitrary values, and appends them to the list hold by cell. (Note that ghc reports the type as (a - IO ()), but that really means the same thing as (b - IO ()). main = do push 3 Here, since you call push with 3, b is chosen to be Int. After this line, the cell holds the list [3]. push x Here, since you call push with x, b is chosen to be String. After this line, the cell holds the list [3, x], which is not well-typed. You tricked Haskell to produce an ill-typed list by using unsafePerformIO. readIORef cell = return Here, it is not clear how you want to instantiate the type variable a in the type of cell. So lets assume that we want to return a value of type c, and instantiate a with c. So even though at this point, the list contains an Int and a String, we can (try to) extract whatever type we want from the list. Therefore, the overall type of main is: main :: IO [c] *Main main [(),()] Now once more, it is not clear how you want to instantiate c, so, by default, () is chosen. That default is only active in ghci, by the way. main will extract the Int 3 and the String x from the list, but treat them as if they were of type (). Here you get lucky: Since there's only one value of type (), ghci can show () without looking at it too deeply, so even though this program is not type-safe in a sense, it works fine in practice. But try forcing ghci to consider a more interesting type instead of (): *Main main :: IO [Int] [3,738467421] The string x is reinterpreted as a number and shown as such. You can try other types instead of Int until your ghci crashes because you access some memory you shouldn't have looked at or try to execute some random part of your memory as code. So to summarize, your code exhibits the (well-known) fact that unsafePerformIO is not type-safe, because it can be used to implement a polymorphic reference, which is a Bad Thing. Tillmann __**_ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/**mailman/listinfo/haskell-cafehttp://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] types and number of evaluation steps
My understanding was that the reason is that CSE can cause things to be shared that take up a lot of space when normally they would be garbage collected sooner. On Feb 18, 2012 11:57 AM, Roman Cheplyaka r...@ro-che.info wrote: It doesn't matter. Laziness would be affected if, for instance, something is not evaluated without CSE and is evaluated with it. In your example either all or none of 'a' and 'b' get evaluated, depending on whether the top-level expression is evaluated. * Victor Gorokgov m...@rkit.pp.ru [2012-02-18 18:23:19+0400] example = a + b + a + b exampleCSE = x + x where x = a + b With CSE we are introducing new thunk: x. 18.02.2012 17:38, Roman Cheplyaka пишет: * Holger Siegelholgersiege...@yahoo.de [2012-02-18 12:52:08+0100] You cannot. Common subexpression elimination is done by GHC very conservatively, because it can not only affect impure programs: it can also affects strictness/lazyness and worsen memory usage of pure code. Like the HaskellWiki says: If you care about CSE, do it by hand. How can it affect strictness or laziness? -- Roman I. Cheplyaka :: http://ro-che.info/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Memory usage with TVar?
First, see this question about space usage on Stack Overflow: http://stackoverflow.com/questions/3254758/memory-footprint-of-haskell-data-types Next, apply this knowledge not only to Ints, but also to tuples and lists. There's your memory usage. - Jake On Wed, Feb 1, 2012 at 10:29 AM, Johan Brinch brin...@gmail.com wrote: Here's the example program: https://gist.github.com/1cbe113d2c79e2fc9d2b When I run the program (which maintains a list inside an STM TVar), I get the following statistics: ./Test +RTS -s 176,041,728 bytes allocated in the heap 386,794,976 bytes copied during GC 69,180,224 bytes maximum residency (7 sample(s)) 42,651,080 bytes maximum slop 179 MB total memory in use (0 MB lost due to fragmentation) Tot time (elapsed) Avg pause Max pause Gen 0 336 colls, 0 par 0.44s 0.44s 0.0013s 0.0033s Gen 1 7 colls, 0 par 0.39s 0.40s 0.0570s 0.1968s INIT time 0.00s ( 0.00s elapsed) MUT time 0.23s ( 0.23s elapsed) GC time 0.83s ( 0.84s elapsed) EXIT time 0.00s ( 0.00s elapsed) Total time 1.06s ( 1.07s elapsed) %GC time 77.9% (78.3% elapsed) Alloc rate 749,153,093 bytes per MUT second Productivity 22.1% of total user, 22.0% of total elapsed How come this program uses 179 MB of memory? I'm on a 64-bit machine where 2'000'000 integers uses 32 MB. Where does the overhead come from? -- Johan Brinch ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Monads, do and strictness
On Mon, Jan 23, 2012 at 10:45 AM, David Barbour dmbarb...@gmail.com wrote: the repeated failures of attempting to model stream processing with infinite lists, I'm curious about what failures you're talking about. - Jake ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Generating Code
On Dec 9, 2011 4:48 PM, Stephen Tetley stephen.tet...@gmail.com wrote: For the specific problem of OpenGL - as the package already exists I'm not sure a generative approach would actually pay its way I strongly disagree. OpenGLRaw is in pretty bad shape right now. It's not up to date with the OpenGL spec and is very difficult to maintain. A generator is exactly what is needed. - Jake ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Lists concatenation being O(n)
On Thu, Oct 13, 2011 at 3:32 PM, Yves Parès limestr...@gmail.com wrote: The number of new cons cells created in due course is Θ(length xs). These cons cells would not have been created if we printed length xs and printed length ys separately. Okay, so the major problem comes from memory management. Well, it comes from extra allocations. Since most values are immutable, most Haskell work is in the form of allocations. - Jake ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Trouble using State Monad.
On Oct 9, 2011 11:17 PM, David Barbour dmbarb...@gmail.com wrote: If you really want the input type to be part of the Filter type definition, you'll need to use arrows instead of monads. I wouldn't say that. You just need an extra type parameter. That doesn't mean it can't be a monad. In fact, wrapping ReaderT around the existing representation gives us exactly the monad we probably want. That said, I think it is likely to be more useful in this context either as it is or as an arrow. I just want to point out that it can still be a monad even if it is an arrow. - Jake ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] instance Enum Double considered not entirely great?
On Thu, Sep 22, 2011 at 7:02 PM, Richard O'Keefe o...@cs.otago.ac.nz wrote: On 21/09/2011, at 11:42 PM, Jake McArthur wrote: With fixed point numbers, it makes sense to have an Enum instance. What is the use case? I'm not quite sure how to answer this. I'm speaking in a fairly general sense. But that does not mean you want to pretend they are integers, and having an Enum instance is basically about pretending to be integers. Even if you are trying to fit your explanation of Enum to the existing behavior, I disagree because ([0.0, 0.1 .. 1.0] :: Double) is inconsistent with that explanation. I think the only reasonable characterization of Enum's current behavior is that it provides some way to take same-sized steps through a range of values, and that's about all it promises. There are at least two defensible understandings of what a fixed point number means. One is appropriate for finance, which is that the numbers are exact rational numbers of the form m/b^n for integer m, n and integer b 1. [...] The other understanding is appropriate for engineering (think of ADCs and DACs) and is that the numbers are approximate. That seems to be what you have in mind. I have both in mind, although it's actually the former style of fixed point arithmetic that I'm more interested in (and I disagree that there is such a distinction between finance and engineering... precision is very important in engineering). The former is not as difficult as you have characterized it, and my fixed-point package provides an interface similar to (although still different from) what you described. Care is taken to make the precision clear in the types and documentation. There isn't currently much choice for rounding methods for division, but this is something I intend to correct in the future. Evan also pointed out some bugs and other lacking functionality which I intend to address this weekend. Fixed point arithmetic is really only useful as an approximation when you have a statically bounded range of values to work in; otherwise, you might as well just use floating point arithmetic anyway. Let's face it, Enum badly needs some revision. [...] Agreed. As things c I think your email got cut off here. - Jake ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] instance Enum Double considered not entirely great?
On Tue, Sep 20, 2011 at 11:29 PM, Richard O'Keefe o...@cs.otago.ac.nz wrote: On 21/09/2011, at 2:59 AM, Chris Smith wrote: On Mon, 2011-09-19 at 22:09 -0700, Evan Laforge wrote: Then I tried switching to a fixed point format, and discovered my mistake. Enum is supposed to enumerate every value between the two points, and the result is memory exhaustion. % ghci Prelude [1.0..2.0]::[Double] [1.0,2.0] (..) for Doubles is using (+1), not nextAfter, and is NOT enumerating every value between 1.0 and 2.0 import Ratio Prelude Ratio [1%2..7%2] :: [Ratio Int] [1 % 2,3 % 2,5 % 2,7 % 2] (..) for (Ratio a) is using (+1), and is NOT enumerating the infinitely many values between 1.5 and 3.5. Why should your fixed point format behave any differently? Evan's claim was that Double and Ratio are doing the incorrect thing; the evidence you gave may support your point, but it supports his as well. My claim now, and I think Evan agrees although I am not sure, is that Double and Ratio shouldn't be instances of Enum at all, since enumerating (a simulation of) the reals and enumerating the rationals in order is nonsensical. I also find that toEnum . fromEnum /= id annoying; anything that relies on it, like EnumSet/EnumMap [1], goes down the toilet. Other things I think are reasonable to expect are also broken; for example, toEnum . succ . fromEnum /= succ (granted, it is reasonable to expect this to be broken considering that toEnum . fromEnum is broken). With fixed point numbers, it makes sense to have an Enum instance. Enumeration is reasonable because most applications for fixed point arithmetic do *not* want to pretend that they are real numbers; you almost always want to be aware of the current precision and whether you might overflow or need more precision. This situation is no different from Word or Int. toEnum and fromEnum are also inverses. No expectations are violated here unless you have already gotten used to the broken Float, Double, and Rational instances. - Jake [1] http://www.haskell.org/haskellwiki/EnumSet_EnumMap ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Proposal: Subcomputations in arrow notation
I think this proposal makes so much sense that I'm surprised it didn't already work this way. - Jake ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] instance Enum Double considered not entirely great?
On Tue, Sep 20, 2011 at 10:59 AM, Chris Smith cdsm...@gmail.com wrote: I certainly hope not. Instead, perhaps the issue should be brought up with the fixed-point number library you're using, and they could fix their Enum instance to be more helpful. I'm the author of the library in question. I intentionally chose the semantics for Enum as it is, although I'm not sure I'm prepared to say that Enum should have this behavior in general. Regardless, enumerating all values makes more sense to me, and we still have enumFromThen and enumFromThenTo, so no power is lost anyway. Float and Double are the only types I know of that don't enumerate all values by default in enumFrom and enumFromTo. - Jake ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] instance Enum Double considered not entirely great?
On Tue, Sep 20, 2011 at 10:59 AM, Chris Smith cdsm...@gmail.com wrote: The better way to look at this is that the notion of `succ` and `pred` is dependent on the type, much like `mappend` has no particular meaning until a Monoid instance is given for the type. It's fairly well established, though undocumented, that Num types ought to have succ = (+1) and pred = (subtract 1), so if your fixed point type doesn't do that, I'd suggest it is the problematic part of this. I forgot to address this in my last email. I disagree that it is well established for succ = (+1) and pred = subtract 1 for Num instances. In fact, for types that are also instances of Bounded where the Num instances have overflow this is required to be *not* true. Not realizing this is a often a source of performance problems or even bugs in Haskell programs. - Jake ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] instance Enum Double considered not entirely great?
On Tue, Sep 20, 2011 at 3:48 PM, Chris Smith cdsm...@gmail.com wrote: But it would be the *wrong* thing to use as a desugaring for list range notation. List ranges are very unlikely to be useful or even meaningful for most such enumerations (what is [ Red, Green .. LightPurple]?); and conversely, as we've seen in this thread, list ranges *are* useful in situations where they are not a suitable way of enumerating all values of a type. This makes me wonder if maybe the reason this discussion is happening at all is that we don't have a well-defined meaning for what Enum *is*. At this point, it seems like the only answer is that it's whatever the instance says it is, which I find unsatisfying. What exactly does Enum enumerate? To me, the list syntax sugar looks like I'm specifying bounds, so it makes sense to include all values within those bounds (and honestly, having instances for Float, Double, and Rational sounds like a mistake, given this), but clearly that is not what it means to everybody. What does it mean to you? What makes the current behavior more useful than the proposed behavior? You say we've seen that this behavior is useful in this thread, but I'm not sure what it is we have seen. - Jake ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Slightly tangential topic about functional programming (specifically, Lambda-Calculus)
I highly recommend that you check out #haskell on freenode. In my opinion its the best channel on freenode, and there are always tons of helpful people and a lot of stimulating conversation. Hope to see you there! ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] OpenGL vs OpenGLRaw
Translation from c is much more straightforward with openglraw compared with OpenGL. Also, many of the design decisions behind OpenGL are arbitrary or limiting, and some features aren't even exposed in its interface. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Why not Darcs?
On Thu, Apr 21, 2011 at 6:32 PM, Maciej Marcin Piechotka uzytkown...@gmail.com wrote: Assume following changes 1. Feature X - file x.hs 2. Feature Y - file y.hs and x.hs 3. Feature Z - file z.hs and x.hs 4. Fix to feature Y (changes x.hs) 5. Fix to feature X (changes x.hs) Now before pushing I would like to have 3 nice commits. In git I can rewrite history by single command: # git rebase -i origin/master and edit the file to look like pick 1 fixup 5 pick 2 fixup 4 pick 3 Manually/automatically check everything is ok. % darcs unrec -a -p 'Fix to feature X' Finished unrecording. % darcs amend -a -p 'Feature X' Thu Apr 21 19:11:54 CDT 2011 Jake McArthur jake.mcart...@gmail.com * Feature X Shall I amend this patch? [yN...], or ? for more options: y Finished amending patch: Thu Apr 21 19:14:41 CDT 2011 Jake McArthur jake.mcart...@gmail.com * Feature X % darcs unrec -a -p 'Fix to feature Y' Finished unrecording. % darcs amend -a -p 'Feature Y' Thu Apr 21 19:12:12 CDT 2011 Jake McArthur jake.mcart...@gmail.com * Feature Y Shall I amend this patch? [yN...], or ? for more options: y Finished amending patch: Thu Apr 21 19:14:50 CDT 2011 Jake McArthur jake.mcart...@gmail.com * Feature Y - Jake ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Why not Darcs?
On Thu, Apr 21, 2011 at 7:31 PM, Maciej Marcin Piechotka uzytkown...@gmail.com wrote: Last time I checked it disallowed my as 5 depended on 4 which depended on 3 which depended on 2 which depended on 1 as all changed x.hs Merely changing the same file is not sufficient for that. In order for Darcs to say patch A depends on patch B they must change the same lines. That said, rebase has its uses. It's due in an upcoming version of Darcs, actually. - Jake ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Haskell from SML - referrential Transparency?!
You can think of IO actions as values (which don't change) representing imperative programs to execute (which may have different results each time you execute them). So, `fa fb fc` represents the exact same value as `fa fb fc`, but if you execute that value multiple times you may get different results. Here are a couple safe ways to execute IO actions: * From your `main` function * In GHCi (if the value you give it is an action, it *executes* it, otherwise it *prints* it) - Jake ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] WANTED: Compensated Haskell Hacker for Language Project
I share your dream of being able to write high-level code for soft real time software, so while I'm not interested in working on your project directly at this time, it's still in my best interest for it to be successful. My only question is this: what does your language offer that others do not with respect to soft real time systems? The language you describe in the linked forum thread looks neat, but I think I'm missing the reasoning behind its design. Why is this design beneficial for soft real time compared to other high level languages? - Jake ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] STM, newArray, and a stack overflow?
On 03/23/2011 10:34 AM, Ketil Malde wrote: It works (calling the same function) from GHCi, but breaks when compiled. Also when compiling with -O0. Confirmed for GHC 7.0.2. Works fine in GHCi, but compiling it (in my case, with -O) and running the executable causes a stack overflow unless I run it with +RTS -K16m, and even then it spends 90% of its time in GC. This looks like it is probably a bug, to me. Maybe it should be reported in GHC's Trac? - Jake ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Custom monad using ST
Try `return x = MyST (return x)`. It's (.) that throws it off. - Jake ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] How large is the Haskell community ?
On 02/12/2011 02:22 PM, Christopher Done wrote: IRC channel has 600~ users in at any one time. At this moment it has 720! And this seems to be roughly the norm recently. - Jake McArthur ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Byte Histogram
On 02/03/2011 03:10 PM, Andrew Coppin wrote: (Unless you're seriously going to suggest that GHC's native code generator is any match for the might of a half-decent C compiler...) I don't know enough about the native code generator to make a claim like that, but we're not comparing the native code generator against a C compiler; we're comparing it against a C code generator whose output is fed through a C compiler. These are very different things, and I think it gives the native code generator an edge. My own observations from immediately before the C backend was deprecated was that the native code generator averaged slightly better performing code. - Jake ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Guy Steele's Praise For Haskell @ Strange Loop Keynote
So everybody doesn't have to go watch it, here is a shortened version of what Steele said in the video: Although Fortress is originally designed as an object-oriented framework in which to build an array-style scientific programming language, [...] as we've experimented with it and tried to get the parallelism going we found ourselves pushed more and more in the direction of using immutable data structures and a functional style of programming. [...] If I'd known seven years ago what I know now, I would have started with Haskell and pushed it a tenth of the way toward Fortran instead of starting with Fortran and pushing it nine tenths of the way toward Haskell. I think I might use this in some slides soon. :) Thanks for pointing it out! - Jake ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Type System vs Test Driven Development
On 01/05/2011 03:44 AM, Jonathan Geddes wrote: When I write Haskell code, I write functions (and monadic actions) that are either a) so trivial that writing any kind of unit/property test seems silly, or are b) composed of other trivial functions using equally-trivial combinators. There are two ways of constructing a software design. One way is to make it so simple that there are obviously no deficiencies. And the other way is to make it so complicated that there are no obvious deficiencies. -- C.A.R. Hoare If you actually manage to do the former, I'd say you don't need to test those parts in isolation. That said, I disagree with you overall. The Haskell type system is simply not rich enough to guarantee everything you might need. Even if it was, it would take a lot of work to encode all your invariants, probably more work than writing tests would have been (although there are obvious advantages to the former as far as having a high level of assurance that your code is correct). Haskell has some awesome testing tool, and I highly recommend getting acquainted with them. In particular, you should definitely learn how to use QuickCheck, which allows you to easily check high-level properties about your code; this is beyond what most traditional unit tests could hope to achieve. I tend to use QuickCheck, SmallCheck, *and* LazySmallCheck in my test suites, as I feel that they complement each other well. HUnit is probably the main one for traditional unit tests. I admit I have never used it, and I'm not sure whether I'm missing out on anything. There are also some pretty nice test frameworks out there to help you manage all your tests, although they could probably use a little more work overall. - Jake ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Polymorphic function over pairs of maybes.
Maybe something like this would work for you (requires the TypeFamilies extension). class FromMaybe a where type Maybe' a fromMaybe :: a - Maybe' a - a instance FromMaybe Int where type Maybe' Int = Maybe Int fromMaybe = Data.Maybe.fromMaybe instance FromMaybe String where type Maybe' String = Maybe String fromMaybe = Data.Maybe.fromMaybe instance (FromMaybe a, FromMaybe b) = FromMaybe (a, b) where type Maybe' (a, b) = (Maybe' a, Maybe' b) fromMaybe (x, y) (a, b) = (fromMaybe x a, fromMaybe y b) - Jake McArthur ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Offer to mirror Hackage
I am no decision maker regarding Hackage, but I would like to echo my support for this offer. Hackage is a vital part of my workflow, and I'm sure I'm not the only one. Its importance to the Haskell community has grown quickly and is continuing to do so. Each time it goes down, the impact is larger than before. We should have a mirror in place for situations like these. - Jake ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] DPH and GHC 7.0.1
On 11/19/2010 05:24 PM, Gregory Propf wrote: I was hoping to play around with Data.Parallel.Haskell (dph) but noticed that it seems to have been exiled from ghc 7.0.1 which I just installed. It also doesn't seem to be in cabal. Anybody know how to use dph with 7.0.1 or has it been abandoned or something? It's not abandoned. The library components have been separated from GHC. I'm sure the intent is to put it on Hackage. - Jake ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Haskell Weekly News: Issue 159 - November 17, 2010
On 11/17/2010 09:56 PM, Daniel Santa Cruz wrote: Curious about the most active members of the #haskell IRC channel? Out of around 28K utterances in the channel this week, 24% of them where spoken by the top 5 most active members. Not suprisingly, the dear lambdabot is at the top of the list. lambdabot 2094 kmc 1263 jmcarthur 1221 Eduard_Munteanu 1142 EvanR-work 1007 Hmm... Should I be embarrassed? - Jake ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Layered maps
What you describe sounds like a perfect job for a trie, so that's what I think you should look into. - Jake ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Layered maps
On 10/08/2010 04:23 PM, Alex Rozenshteyn wrote: Does there exist a library which allows me to have maps whose elements are maps whose elements ... with a convenient syntax. It sounds like you might be looking for a trie of some sort. Would something like the TrieMap package suit your needs? It's hard to guess based only on the question as posed. - Jake ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Ultra-newbie Question
On 09/18/2010 02:51 AM, Christopher Tauss wrote: I am trying to write a function that takes a list and returns the last n elements. This may just be for the sake of learning, in which case this is fine, but usually, needing to do this would be a sign that you are using lists improperly (since this is a O(n) time operation). Let's call the function n_lastn and, given a list [1,2,3,4,5], I would like n_lastn 3 = [3,4,5] n_lastn n = reverse . take n . reverse - Jake ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Google AI Challenge: Planet Wars - Accepting Haskell Submissions
Just wanted to let everybody know that there is an AI contest [1] that started today. Everybody has about two months to create bots that compete against each other 1-on-1 in a game based on Galcon [2]. A couple issues to mention for full disclosure: There is some sponsorship by Google, but unfortunately they aren't running the hardware, so the site is getting pretty hammered right now. We (it's all open source and open for contributions) are working to get it optimized to better handle the load. Also, the version of GHC on the server is very old (6.8.2) and isn't likely to get updated. I'm working to allow binary submissions though. If that goes through, you guys will be able to submit 64-bit Linux binaries rather than Haskell code to be compiled on the server. Just letting everybody know so the Haskell community can represent! - Jake [1] http://ai-contest.com [2] http://galcon.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] MonadLib usage
On 07/18/2010 08:27 AM, Ivan Lazar Miljenovic wrote: When discussing a similar issue with Manuel Chakravarty, he convinced me that cunning newtype deriving is actually rather bad in practice and shouldn't be used as there's a lack of proofs or some such (I can't remember the arguments, but I remember being convinced by them :p). Did these arguments apply to all newtype deriving or only to some subset of it? I don't know if cunning newtype deriving is a special kind of newtype deriving (multiparameter?) or if it's just being thrown around. - Jake ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] trees and pointers
On 07/15/2010 02:30 AM, Stephen Tetley wrote: 2010/7/15 Jake McArthurjake.mcart...@gmail.com: On 07/14/2010 05:01 PM, Victor Gorokhov wrote: You can implement pure pointers on top of Data.Map with O(log n) time Or on top of Data.IntMap with O(1) time. ;) Unlikely... From the docs, lookup is O(min(n,W)) Exactly. O(min(n,32)) or O(min(n,64)) - Jake ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] trees and pointers
On 07/15/2010 05:33 PM, Victor Gorokhov wrote: Thanks for an example! Probably, one can think about using Arrays instead of Map or IntMap in order to achieve 'true' O(1) in pure. But I suppose that there are some trouble with array expanding. Or somebody would already make it. Pure arrays have O(n) modification time. Excluding DiffArray under certain usage patterns of course, but DiffArray is slow for unknown reasons besides algorithmic complexity. From the docs, lookup is O(min(n,W)) Actually worse than O(log n). Perhaps I am misunderstanding you, but O(min(n,W)) is either better than or the same as O(log n), depending on how you look at things, but I don't see any way that the former could be *worse* than the latter. - Jake ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] trees and pointers
On 07/14/2010 05:01 PM, Victor Gorokhov wrote: You can implement pure pointers on top of Data.Map with O(log n) time Or on top of Data.IntMap with O(1) time. ;) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] [C Binding] Turning the mutable to immutable?
On 07/05/2010 04:48 PM, Yves Parès wrote: 3) Is there another library on hackage that handles images in a functional way? (I mean not /all in IO/) Check out graphics-drawingcombinators. - Jake ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Construction of short vectors
On Sun, Jun 27, 2010 at 4:44 PM, Alexey Khudyakov alexey.sklad...@gmail.com wrote: Dependent types would be nice but there isn't anything usable out there. Newtype wrapper parametrized by type level number works fine so far. If you interested sources are available here: http://bitbucket.org/Shimuuar/nvector http://bitbucket.org/Shimuuar/type-numbers I haven't looked to see how complete your code is, but feel free to take over the vector-static [1] project if you wish to use some existing code. I haven't taken the time yet to say so on the Hackage page, but it's not currently being maintained. - Jake [1] http://hackage.haskell.org/package/vector-static ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Fwd: [Haskell-cafe] Rewriting a famous library and using the same name: pros and cons
Sorry, I hit Reply instead of Reply To All. -- Forwarded message -- From: Jake McArthur jake.mcart...@gmail.com Date: Tue, Jun 8, 2010 at 6:16 PM Subject: Re: [Haskell-cafe] Rewriting a famous library and using the same name: pros and cons To: Don Stewart d...@galois.com Making a new name for an existing package subverts the intended meaning of major revision numbers. Libraries that break as a result of a major revision should have had more specific dependencies, and tutorials that go out of date should also have specified the version number of the package for which they were intended. It's a package maintainer's responsibility to respect version number conventions. I don't believe it is a package maintainer's responsibility to account for blatant misuse of it. - Jake ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Proposal: Sum type branches as extended types (as Type!Constructor)
On 06/03/2010 10:14 AM, Gabriel Riba wrote: No need for runtime errors or exception control hd :: List!Cons a - a hd (Cons x _) = x This is already doable using GADTs: data Z data S n data List a n where Nil :: List a Z Cons :: a - List a n - List a (S n) hd :: List a (S n) - a hd (Cons x _) = x tl :: List a (S n) - List a n tl (Cons _ xs) = xs - Jake ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] [reactive] A pong and integrate
On 05/23/2010 02:17 PM, Peter Verswyvelen wrote: IMO: For AAA game programming? Definitely not. Why not? I suppose it may depend on your definition of AAA, since there doesn't seem to be any consensus on it. I have seen it mean various combinations of the following, but rarely, if ever, all of them: * Big development budget * Big marketing budget * High quality * Large number of sales and/or high revenue * High hardware requirements * Released by one of a small group of accepted AAA publishers While I think it's very unlikely that the last one will happen any time soon, I don't see any reason that Haskell and/or FRP (or as I now prefer to call my research in the area, Denotative Continuous-Time Programming, or DCTP) inherently can't be a major part of the development of a game that fits any of the definitions in the list. I suppose DCTP is not itself *ready* for somebody to risk a business investment on it, although it may be in the future, but Haskell as a whole would not be all that risky, in my opinion. - Jake ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Hackage accounts and real names
On Tue, Apr 6, 2010 at 6:08 AM, Serguey Zefirov sergu...@gmail.com wrote: http://lambda-the-ultimate.org is one lovely community that has that restriction: http://lambda-the-ultimate.org/policies#Policies I quote the policy in full here: Many of us here post with our real, full names. Anonymity and the use of pseudonyms is discouraged. We recognize that there can be legitimate reasons for wishing to post under a pseudonym. If you do not register using your real name, then if possible, please include identifying information in your user profile, such as your real name or a link to a personal home page or blog. Using a pseudonym by which you are known elsewhere can also help. This is a request, not a restriction. - Jake ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Hackage accounts and real names
On 04/05/2010 11:32 PM, Ivan Miljenovic wrote: 4) The people who support the policy don't see why anyone has a problem with it. I have seen no logical explanation of *why* anybody supports this policy. I've only seen vague hand-wavy statements like people who use real names are more reliable. Really? Where's the proof? I bet there's a fairly large number of badly maintained projects on Hackage, and I bet it has little or no correlation with the accuracy of the maintainers' listed names. Even if it's true, what harm is there in allowing less reliable maintainers to upload packages? So we end up with a few extra packages that nobody uses. So what? - Jake ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Hackage accounts and real names
On 04/04/2010 06:35 PM, Ivan Miljenovic wrote: I would wonder _why_ anyone would refuse to do so. Are they that ashamed of their own software that they wouldn't want to be associated with it, or is there some legal reason that they don't want to be associated with it? This seems to be orthogonal to the discussion at hand. Why are people not *allowed* to use pseudonyms on Hackage, for whatever reason they wish to do so? - Jake ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] vector stream fusion, inlining and compilation time
Here's a transcript from a conversation I had with Conal on IRC. tl;dr: conal cross-module inlining is only possible because ghc stashes a definition in a .hi, iuuc. i'm suggesting that the stashed definition either (a) never include further inlinings, or (b) be augmented by such a definition. Full transcript: 11:23:10 conal jmcarthur: i'm wondering what to do about INLINE pragmas for vector-space and other libraries. i love optimizability and clean/elegant/terse code. and i don't know how to resolve that tension. 11:23:21 jmcarthur conal: yeah, me either. it's annoying 11:23:41 jmcarthur conal: a compiler feature to do it more succinctly would be nice, if we can come up with one 11:23:52 conal jmcarthur: i'm thinking exactly the same 11:24:04 conal jmcarthur: a ghc flag that does what you did manually 11:24:41 jmcarthur conal: yeah, but we still need to do better than inlining *all* functions. we need to be able to tell it we want it to inline all functions satisfying some predicate or something 11:25:07 jmcarthur like, there's no point in forcing to inline functions having absolutely nothing to do with vector, for example 11:25:18 conal jmcarthur: i wonder. ghc already has some heuristics. do we really want anything different/unusual? 11:25:26 jmcarthur then again, combinators that don't inline and get used in a vector function later might still be annoying 11:26:08 conal jmcarthur: maybe some kind of demand-driven mechanism 11:26:21 jmcarthur conal: that's what i was thinking would be best 11:26:28 conal jmcarthur: ie pull inlining rather than push them. or some combo. 11:27:21 conal jmcarthur: i don't think this issue is specific to either vector fusion or to the vector-space package. 11:27:28 jmcarthur conal: actually, this is about rewrite rules more than inlining 11:27:40 jmcarthur conal: maybe if we focus on the rewrite rules we can think of something nicer 11:27:46 conal jmcarthur: ah, yeah. 11:28:32 conal jmcarthur: have you talked with they ghc guys about this issue? i wonder what practice they'd advise for use with the current ghc 11:28:54 jmcarthur i have not 11:29:47 conal jmcarthur: how did the inlining/rewriting concern arise for vector fusion and the vector-space package? 11:30:16 jmcarthur conal: i assume you read the email i linked to? 11:30:27 jmcarthur this one: http://www.haskell.org/pipermail/haskell-cafe/2010-March/074153.html 11:30:34 conal jmcarthur: yes. i'l reread now. 11:31:03 jmcarthur conal: in general, you have to add INLINE pragmas in such cases if you want to be sure your code fuses. A general-purpose mechanism for handling situations like this automatically would be great but we haven't found a good one so far. 11:31:14 jmcarthur i think the most relevant line 11:31:49 conal jmcarthur: thx. and the difficulty (with current ghc) is specifically cross-module, right? 11:32:00 jmcarthur conal: that is my understanding 11:32:10 jmcarthur but perhaps it is more complex 11:32:49 conal jmcarthur: if so, i wonder if ghc could be fixed to inline between modules according to the same heuristics as within a module. 11:34:36 jmcarthur conal: maybe. 11:35:34 conal jmcarthur: part of my discomfort is that i don't know whether the INLINE directives are more helpful or more harmful under all uses. if they were generally helpful, i imagine ghc would do it. 11:56:56 jmcarthur me too 11:57:46 conal jmcarthur: i just found that haskell-cafe thread and added a reply. 11:58:31 conal jmcarthur: hoping that don, roman, etc will have some ideas in addressing that discomfort. 12:09:58 jmcarthur conal: apparently the real trick is that GHC will not inline functions in a function that is annotated INLINE, meaning that rewrite rules can fire on the outermost rule before firing on inner ones 12:10:30 jmcarthur conal: i think it would be nice if we could come up with a way for rewrite rules to affect GHC's inliner 12:10:44 conal jmcarthur: yeah. maybe INLINE ought to be decomposed into two sub-meanings. 12:10:45 jmcarthur then it would only happen when necessary 12:11:17 jmcarthur well, the fact that it forces that function to be inlined is also good though 12:11:33 jmcarthur which is apparently important across module boundaries 12:11:45 conal jmcarthur: maybe ghc could *never* inline functions into an inline body. and then do some caching to avoid redundant work. 12:12:00 jmcarthur perhaps. still leaves the cross-module inlining issue though 12:12:32 jmcarthur i suspect this is also architectural 12:12:44 jmcarthur ghc doesn't know if it will inline a function across a module boundary in advance 12:12:52 jmcarthur therefore it goes ahead and inlines into it 12:13:04 jmcarthur *inlines other functions into it 12:13:31 conal jmcarthur: i don't understand how module boundaries come into play 12:14:40 jmcarthur conal: my suspicion is that because ghc builds modules separately it can't know whether a function will be inlined in another module, so if it's not marked INLINE it feels free to
Re: [Haskell-cafe] vector stream fusion, inlining and compilation time
I've run into an issue with inlining that I'm not sure how to work around. I am instantiating some pre-existing type classes with Vector-based types. There already exist generic functions in modules I do not control that use this type class, and they are not tagged with the INLINE pragma. I am doubtful, but I figure it is worth at least asking: is there some practical workaround for this kind of situation that anybody knows about? - Jake ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: ANN: bindings-SDL 1.0.2, the domain specific language for FFI description
Maurício CA wrote: I believe I forgot to write a section with that information, as well as others one would like to know from start. I wrote a new section trying to fix that in 'how to use it' topic. http://bitbucket.org/mauricio/bindings-dsl/wiki/HowToUseIt Very nice. I think that is clear enough. I'm not sure I have already got to a point where documentation is clear and complete enough but not too long and boring. If you also thing some parts of documentation were not helpful, or if more is missing, please let me know. Quite the contrary, with that one exception, I found the documentation to be among some of the best I have used. I especially like the numerous examples you included. - Jake ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANN: bindings-SDL 1.0.2, the domain specific language for FFI description
I did not notice when this was released, but I saw it on Hackage yesterday and, with it, wrote some of the easiest bindings to a fairly complex C API I've written in a while. This package is excellent! Thank you for sharing it. My only complaint is that the macros get confused if you use a Haskell type that has a single quote in it. - Jake ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: ANN: bindings-SDL 1.0.2, the domain specific language for FFI description
Maurício CA wrote: My only complaint is that the macros get confused if you use a Haskell type that has a single quote in it. Can you give me an example? It turns out that I read the documentation incorrectly, but here is what I was trying to do. I had two structs, one of which used the other as a field type. I was using the generated identifier of the first as the type for the second, so it had the form c'STRUCT_NAME. So the field macro looked like this: #field foo , c'STRUCT_NAME It did not like this, complaining about the single quote. I have since noticed the STRUCT_NAME notation in the documentation. Perhaps the actual bug is that this notation was not pointed out in prose? - Jake ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Calling all Haskellers in Huntsville, Alabama, or surrounding areas!
Shae Errisson, myself, Greg Bacon, and some other locals who I think might not have as big a presence online are starting a user's group in Huntsville, AL. Please join the Google group / mailing list [1] if you are interested! [1] http://groups.google.com/group/alabamahaskell - Jake McArthur ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] What does :*: mean again?
Nothing by itself. It's just a definable constructor of some sort. - Jake ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] newtype deriving Alternative
Martijn van Steenbergen wrote: It doesn't work for this one: newtype Split a = Split { runSplit :: [Either a (Char, Split a) ]} But my handwritten instance remains identical. The instance has the form [], not the form [Either _ (Char, Split _)]. Since they don't match exactly, it won't give you an instance automagically. It could have been the case that you intended some other instance besides []'s. All generalized newtype deriving does is derive instances for newtypes that wrap exactly what the instance is defined over. - Jake ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] GPipe example and screenshot
Tobias Bexelius wrote: I've put a simple GPipe example (including a screenshot) on the haskellwiki now, showing off an animated spinning box. Nice to see Data.Vec.LinAlg.Transform3D! That will be a big help. I'm having fun with GPipe. Thanks for the library! - Jake ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] dsl and gui toolkit
If you could throw it on Hackage or a public repo you will get more exposure. :) - Jake ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Designing a DSL?
Günther Schmidt wrote: And that I find to be the really tricky part, how do I *design* a DSL? My favorite approach is something like as described in these: http://lukepalmer.wordpress.com/2008/07/18/semantic-design/ http://conal.net/papers/type-class-morphisms/ It takes a little bit of time to come up with great abstractions, but when you finally do it's an amazing feeling. - Jake ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] (no subject)
staafmeister wrote: Yes I know but there are a lot of problems requiring O(1) array updates so then you are stuck with IO again Or use ST. Or use IntMap (which is O(log n), but n is going to max out on the integer size for your architecture, so it's really just O(32) or O(64), which is really just constant time). And, realistically, very few problems actually require indexed access on a large scale like this. [parsing stuff] As far as parsing is concerned, maybe you should look at Parsec. I know it sounds like overkill, but it's easy enough to use that it's quite lightweight in practice. Your example scenario: inputData :: Parser InputData inputData = many1 digit * newline * many (testCase * newline) where testCase = many1 digit * newline * sepBy edge (char ' ') edge = liftA2 (,) (many nonspace * char ' ') (read $ digits) - Jake ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Planning for a website
Colin Paul Adams wrote: One problem will be to get GHC ported to DragonFly BSD, but that can wait until I have a test version of the site working on Linux. I would love to see this. It's the biggest thing blocking me from trying Dragonfly more seriously. WASH attracts me, with it's guarantee of valid generated pages, but it isn't clear to me that it's actively maintained (last date I can see on the web pages is 2006). You should look into HSP. It also provides those guarantees, is maintained, and provides a nice template-style syntax which you can use inline with your Haskell code. Also check out the Formlets library. HappStack is obviously currently maintained, and since it seems to have a blogging module in development, that is attractive. I recommend this. - Jake ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Planning for a website
I forgot to also mention this somewhat recent announcement for a pedantically type safe HTML library: http://www.haskell.org/pipermail/haskell-cafe/2009-August/064907.html - Jake ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] containers and maps
John Lato wrote: This looks to be essentially the same as the 'map' function in ListLike, and suffers from the same problem. It won't have the performance characteristics of the native map functions. Using e.g. ByteStrings, you're recreating a ByteString by snoc'ing elements. Oh, I see now what you are after. You're right. This wouldn't play nice when creating ByteStrings (which is probably why there is no instance for Reducer Char ByteString). This might work with UVector (I intend to try it this evening); I don't know how well the fusion framework will hold up in class dictionaries. Do report back, as I am curious as well. Still, the monoids package is very powerful (and I'd completely forgotten it). Perhaps there's another approach that would work? Yay, something to mull over! :) - Jake ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] containers and maps
The monoids package offers something similar to this: mapReduce :: (Generator c, Reducer e m) = (Elem c - e) - c - m If we take (Elem c) to be (item), (e) to be (item'), (c) to be (full), and (m) to be (full'), it's basically the same thing, and offers the same advantages as the ones you listed, as far as I can tell. - Jake ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] containers and maps
Jake McArthur wrote: The monoids package offers something similar to this: mapReduce :: (Generator c, Reducer e m) = (Elem c - e) - c - m If we take (Elem c) to be (item), (e) to be (item'), (c) to be (full), and (m) to be (full'), it's basically the same thing, and offers the same advantages as the ones you listed, as far as I can tell. Your example about uvector inspired me to try writing out the necessary instances for uvector: instance UA a = Monoid (UArr a) where mempty = emptyU mappend = appendU instance UA a = Reducer a (UArr a) where unit = singletonU snoc = snocU cons = consU instance UA a = Generator (UArr a) where type Elem (UArr a) = a mapTo f = foldlU (\a - snoc a . f) - Jake ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] unsafeDestructiveAssign?
Job Vranish wrote: What I am trying to do is hyper unusual and I really do need an unsafeHorribleThings to do it. Normally when I really, honestly think this, I'm wrong anyway. - Jake ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] A mistake in haskellwiki
Don Stewart wrote: leaveye.guo: Hi haskellers: There is a mistake in http://www.haskell.org/haskellwiki/State_Monad It post two functions like this : evalState :: State s a - s - a evalState act = fst $ runState act execState :: State s a - s - s execState act = snd $ runState act Both the '$' operators should be '.'. Anyone would correct it ? Well, it's a wiki ... :-) Which requires registration and has not been open for registration for some time now. - Jake ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] n00b question: defining datatype
Iain Barnett wrote: data Task = Task { title :: String, completed :: Bool, subtasks :: [Task] } This one looks the best to me. Remember, you can just use an empty list if the task has no subtasks. - Jake ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] n00b question: defining datatype
Actually, how about this? import Data.Tree newtype Task = Task (Tree (String, Bool)) Now you already have that tree structure you wanted. - Jake ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Why is there no Zippable class? Would this work?
I think there are some basic equivalents in the TypeCompose and category-extras packages, for the record, but a standalone version wouldn't hurt either! - Jake ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] RE: Haskell as a first language?
Michael Vanier wrote: Haskell is a wonderful language (my favorite language by far) but it is pretty difficult for a beginner. In fact, it is pretty difficult for anyone to learn in my experience, because it has so many advanced concepts that simply don't exist in other languages, and trying to absorb them all at once will likely be overwhelming. I disagree, based on seeing my wife learn some Haskell with basically no previous experience programming. It was thrilling to see her learn some concepts almost instantly that it actually took me a while to understand because I had preconceived notions of how programming should work. When I talk about how other programming languages do things she thinks it's stupid. For example, I mentioned that you can actually change the values of variables in most other programming languages, and often have to, and she asked how anything understandable gets written that way. I also noticed that when I kept emphasizing that you can pass functions as parameters to other functions she was getting bored; it seemed that it simply would not have made sense any other way. I see no reason why learning more concepts on top of this foundation should be all that hard for her. - Jake ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Which one is right?
Linker wrote: Hugs [0,0.1..1] [0.0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0] Prelude [0,0.1..1] [0.0,0.1,0.2,0.30004,0.4,0.5,0.6,0.7,0.7999,0.8999,0.] Just floating point errors. In this case, you may be able to get away with something like this: Prelude map ((/10) . fromIntegral) [0..10] [0.0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0] - Jake ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Installing agda through cabal
Paulo J. Matos wrote: As you can see, I had just finished installing alex 2.3.1, so why does cabal still request alex =2.0.1 3? Probably you don't have alex in your PATH. - Jake ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Confusion on the third monad law when using lambda abstractions
Hans van Thiel wrote: The only place I've ever seen Kleisli composition, or its flip, used is in demonstrating the monad laws. Yet it is so elegant and, even having its own name, it must have some practical use. Do you, or anybody else, have some pointers? I only just started finding places to use it myself, admittedly, but I now think it has common use and it fairly easy to spot. I'll take it slow, if not for you, as you seem to have a grasp on what these operators are already, then for other readers. Consider a function of this form: foo x = a $ b $ c $ d $ e $ f x The obvious thing to do here is to simply drop the `x` from both sides by using `(.)` instead of `($)`: == foo x = a . b . c . d . e . f $ x == foo = a . b . c . d . e . f Now, consider this: bar x = a = b = c = d = e = f x If you compare that to the original version of `foo` above, you see that it is similar. In fact, looking at the types for `($)` and `(=)`: ($) ::(a - b) - ( a - b) (=) :: Monad m = (a - m b) - (m a - m b) So, `(=)` is just like `($)` except for the information carried along by the monad. Anyway, the obvious thing to do is to drop the `x` from both sides of the definition for `bar`. To do that with `foo` earlier, we had to substitute `($)` with `(.)`. What we are looking for is an equivalent operator for monads: (.) ::(b c) - (a - b) - (a - c) (=) :: Monad m = (b - m c) - (a - m b) - (a - m c) So we now can do this: == bar x = a = b = c = d = e = f $ x == bar = a = b = c = d = e = f And we're done. Generally, you can transform anything of the form: baz x1 = a = b = ... = z x1 into: baz = a = b = ... = z If you aren't already using `(=)` much more than `(=)` or do-notation then you will have a harder time finding opportunities to use `(=)` because only `(=)` has the same flow as function application, which allows your mind to play the appropriate association games. I suppose you could also replace `(=)` with `()`, but this would likely require more mental adjustment than replacing `(=)` with `(=)`. - Jake ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Confusion on the third monad law when using lambda abstractions
Jake McArthur wrote: Generally, you can transform anything of the form: baz x1 = a = b = ... = z x1 into: baz = a = b = ... = z I was just looking through the source for the recently announced Hyena library and decided to give a more concrete example from a real-world project. Consider this function from the project's Data.Enumerator module[1]: compose enum1 enum2 f initSeed = enum1 f1 (Right initSeed) = k where f1 (Right seed) bs = ... k (Right seed) = ... First, I would flip the `(=)` into a `(=)` (and I will ignore the `where` portion of the function from now on): compose enum1 enum2 f initSeed = k = enum1 f1 (Right initSeed) Next, transform the `(=)` into a `(=)`: compose enum1 enum2 f initSeed = k = enum1 f1 $ Right initSeed We can move the `($)` to the right by using `(.)`: compose enum1 enum2 f initSeed = k = enum1 f1 . Right $ initSeed Finally, we can drop the `initSeed` from both sides: compose enum1 enum2 f = k = enum1 f1 . Right I didn't test that my transformation preserved the semantics of the function or even that the type is still the same, but even if it's wrong it should give you the idea. - Jake [1] http://github.com/tibbe/hyena/blob/9655e9e6473af1e069d22d3ee75537ad3b88a732/Data/Enumerator.hs#L117 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Confusion on the third monad law when using lambda abstractions
Hans van Thiel wrote: Just to show I'm paying attention, there's an arrow missing, right? (.) ::(b - c) - (a - b) - (a - c) Correct. I noticed that after I sent it but I figured that it would be noticed. I also used () where I meant (=) at the bottom. They are semantically the same, of course, but () requires the Kleisli newtype. :( Many thanks, also to the others who've replied. I've wondered about (=) usage for a long time too, and this is all very illuminating. I'll work this through and put it in my monad tutorial, if I may (without implicating you guys in any way, of course, unless you insist...) You're welcome. I do not insist on anything either way. ;) - Jake ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Tree Semantics and efficiency
Rouan van Dalen wrote: It is important to store only a reference to the parent and not a copy of the entire parent for efficiency. Others have already recommended the rosezipper package, which gives you what you want, but I want to address one thing. foo = stuff bar = foo In most implementations (including GHC, which I assume you are using), `bar` will *not* be an actual copy of `foo`. In fact, GHC will not make a deep copy of a structure unless you pattern match all the way down and reconstruct it all the way back up yourself. If you use a zipper, like Data.Tree.Zipper mentioned already, moving around will not create and destroy tons of data. It will only create and destroy the spine of the tree local to the current pointer into the tree, which is not a lot of data. If you are holding on to older versions of the zipper, of course, they won't even be destroyed. - Jake ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Confusion on the third monad law when using lambda abstractions
Jon Strait wrote: I'm reading the third (bind associativity) law for monads in this form: m = (\x - k x = h) = (m = k) = h Arguably, that law would be better stated as: (h = k) = m = h = (k = m) This wouldn't be so unintuitive. - Jake ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] curious about sum
Keith Sheppard wrote: Is there any reason that sum isn't strict? I can't think of any case where that is a good thing. Prelude sum [0 .. 100] *** Exception: stack overflow As others have said, there are cases where non-strictness is what you want. And if you are using a type that is strict (the common case), GHC's optimizations will catch it. The historical reason for this is that foldl' is not Haskell 98, only foldl. - Jake ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Non Empty List?
Günther Schmidt wrote: data Container a = Single a | Many a [a] but the problem above is that the data structure would allow to construct a Many 5 [] :: Container Int. I think you meant to do either data Container a = Single a | Many a (Container a) or data Container a = Container a [a] - Jake ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe