Re: [Haskell-cafe] What is Haskell unsuitable for?
On Wed, Jun 16, 2010 at 8:51 AM, Ivan Miljenovic ivan.miljeno...@gmail.comwrote: On 16 June 2010 15:45, Roman Cheplyaka r...@ro-che.info wrote: * aditya siram aditya.si...@gmail.com [2010-06-15 19:47:37-0400] Hi all, Haskell is a great language and in a lot of ways it still hasn't found a niche, but that's part of what is great about it. But I wanted to ask people are more experienced with Haskell - what kinds of problems is it unsuited for? Have you ever regretted using it for something? Meaning if you could write the program over you would do it in another language. This topic was already discussed on this list, you might want to search the archives. Spoilsport! :p Next you'll say there's no need for anyone to ask whether they prefer vi or emacs... ;-) Of course *real* programmers use ed. It is the standard editor[1]. Michael [1] http://www.gnu.org/fun/jokes/ed.msg.html ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] What is Haskell unsuitable for?
On 16 June 2010 16:00, Michael Snoyman mich...@snoyman.com wrote: On Wed, Jun 16, 2010 at 8:51 AM, Ivan Miljenovic ivan.miljeno...@gmail.com wrote: Next you'll say there's no need for anyone to ask whether they prefer vi or emacs... ;-) Of course *real* programmers use ed. It is the standard editor[1]. Michael [1] http://www.gnu.org/fun/jokes/ed.msg.html Except that due to Haskell's pervading influence we've all become lazy... -- Ivan Lazar Miljenovic ivan.miljeno...@gmail.com IvanMiljenovic.wordpress.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Vague: Assembly line process
On Tue, Jun 15, 2010 at 9:26 PM, Bas van Dijk v.dijk@gmail.com wrote: On Tue, Jun 15, 2010 at 7:23 PM, Martin Drautzburg martin.drautzb...@web.de wrote: When I know my supplies I want to know what I can produce. When I know what I want to produce I want to know what supplies I need for that. Both kinds of questions should be answered by a singe Process thingy. Your Process thingy reminds me of a natural isomorphism: data Iso a b = Iso { ab :: a - b , ba :: b - a } I want to be able to chain processes and the whole thing should still act like a Process. These isomorphisms can be chained together using the standard Category method '.': import qualified Control.Category as C instance C.Category Iso where id = Iso id id Iso bc cb . Iso ab ba = Iso (bc . ab) (ba . cb) I couldn't help to generalize this a bit: -# LANGUAGE TypeOperators, UnicodeSyntax #-} import Control.Category import Control.Arrow import Prelude hiding (id, (.)) data Iso (⇝) a b = Iso { ab ∷ a ⇝ b , ba ∷ b ⇝ a } type IsoFunc = Iso (→) instance Category (⇝) ⇒ Category (Iso (⇝)) where id = Iso id id Iso bc cb . Iso ab ba = Iso (bc . ab) (ba . cb) An 'Iso (⇝)' also _almost_ forms an Arrow (if (⇝) forms an Arrow): instance Arrow (⇝) ⇒ Arrow (Iso (⇝)) where arr f = Iso (arr f) undefined first (Iso ab ba) = Iso (first ab) (first ba) second (Iso ab ba) = Iso (second ab) (second ba) Iso ab ba *** Iso cd dc = Iso (ab *** cd) (ba *** dc) Iso ab ba Iso ac ca = Iso (ab ac) (ba . arr fst) -- or: (ca . arr snd) But note the unfortunate 'undefined' in the definition of 'arr'. This seems to suggest that all the methods besides 'arr' need to move to a separate type class. Maybe something like: class Category (⇝) ⇒ Arrow (⇝) where arr ∷ (a → b) → (a ⇝ b) class Category (⇝) ⇒ Pass (⇝) where first ∷ (a ⇝ b) → ((a, c) ⇝ (b, c)) second ∷ (a ⇝ b) → ((c, a) ⇝ (c, b)) (***) ∷ (a ⇝ b) → (c ⇝ d) → ((a, c) ⇝ (b, d)) () ∷ (a ⇝ b) → (a ⇝ c) → (a ⇝ (b, c)) Oh well... Bas ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Haskell Indonesia
Given that I can see Indonesia (pulau batam) from my bedroom window, I'm going to say that I didn't cross any lines.. On Jun 16, 2010, at 6:17 AM, Ivan Lazar Miljenovic wrote: Max Cantor mxcan...@gmail.com writes: Its not indonesia, but the Singapore FP Users is pretty close by. [snip] Fine, if we're going to start promoting non-Indonesian Haskell groups/events, I give you AusHack: http://www.haskell.org/haskellwiki/AusHac2010 (It was about time for more promotion for this; it's starting in a months time!!!) -- Ivan Lazar Miljenovic ivan.miljeno...@gmail.com IvanMiljenovic.wordpress.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] What is Haskell unsuitable for?
On Wed, Jun 16, 2010 at 8:00 AM, Michael Snoyman mich...@snoyman.com wrote: Next you'll say there's no need for anyone to ask whether they prefer vi or emacs... ;-) Of course *real* programmers use ed. It is the standard editor[1]. *Real* programmers use butterfiles [1]. [1] http://xkcd.com/378/ David. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] What is Haskell unsuitable for?
David Virebayre dav.vire+hask...@gmail.com writes: On Wed, Jun 16, 2010 at 8:00 AM, Michael Snoyman mich...@snoyman.com wrote: Next you'll say there's no need for anyone to ask whether they prefer vi or emacs... ;-) Of course *real* programmers use ed. It is the standard editor[1]. *Real* programmers use butterfiles [1]. If your files are composed of butter, Id hate to see how you store them in an efficient manner... -- Ivan Lazar Miljenovic ivan.miljeno...@gmail.com IvanMiljenovic.wordpress.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Vague: Assembly line process
Alexander Solla wrote: ...and (probably) the most efficient production plan given the costs of his inputs. This is a problem I am going to have to solve programmatically, too. I intend on solving it by finding the input in a given category of necessary inputs with the lowest average cost per unit. I'm not concerned about hard cost allocation limits -- i.e. it's okay for the firm to buy more of an input than might be necessary for another output as long as the average unit cost is the lowest (since all the inputs will be used eventually anyway). Hard allocation complicates the problem, since you have an upper bound on what you can spend, and you want to spend it most effectively, presumably with as little waste of available cash as possibile. Bin packing. This is Linear Programming: http://en.wikipedia.org/wiki/Linear_programming Regards, Yitz ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Mining Twitter data in Haskell and Clojure
On 15/06/2010 20:43, braver wrote: On Jun 15, 6:27 am, Simon Marlowmarlo...@gmail.com wrote: On 15/06/2010 06:09, braver wrote: In fact, the tag cafe2, when run on the full dataset, gets stuck at 11 days, with RAM slowly getting into 50 GB; a previous version caused ghc 6.12.1 to segfault around day 12 -- -debug showing an assert failure in Storage.c. ghc 6.10 got stuck at 30 days for good, and when profiling crashed twice with a strange closure or a stack overflow. So allocation is a problem still. I'd be happy to help you track this down, but I don't have a machine big enough. Do you have any runs that display a problem with a smaller heap ( 16GB)? If the program is apparently hung, try connecting to it with 'gdb --pid=pid' and doing 'info thread' and 'where'. That might give me enough clues to find out where the problem is. Is this with -threaded, BTW? With residency on that scale, I'd expect the parallel GC to help quite a lot. But obviously getting it to not crash/hang is the first priority :) Simon - thanks for the tips, this is what gdb says when it's stuck at 45 GB when limited with -A5G -M40G: ... 0x004c3c21 in free_mega_group () (gdb) info thread * 1 Thread 0x2b21c1da4dc0 (LWP 10210) 0x004c3c21 in free_mega_group () (gdb) where #0 0x004c3c21 in free_mega_group () #1 0x004c3ff9 in freeChain () #2 0x004c5ab0 in GarbageCollect () #3 0x004bff96 in scheduleDoGC () #4 0x004c0b25 in scheduleWaitThread () #5 0x004bea09 in real_main () #6 0x004beb17 in hs_main () #7 0x0037d5a1d974 in __libc_start_main () from /lib64/libc.so.6 #8 0x00402ca9 in _start () Thanks. I don't see anything obviously wrong in free_mega_group() - it's part of the memory manager that returns a multi-MB block to the internal free list, and it looks down the free list to find the right place to put it, coalescing with adjacent free blocks if possible. If it is looping here, that means the free list has a cycle, which is very bad indeed. Could you try a few more things for me? - type 'display /i $pc' and then single step with 'si' for a while when it is in this state. That will tell us whether it's looping here or not. - compile with -debug and run again. That turns on a bunch of assertions. You could also try adding +RTS -DS, this turns on more sanity checking (and will slow things down a lot). If you are comfortable giving me a login on your machine then I could debug it directly, let me know. Cheers, Simon ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] The Arrow class (was: Vague: Assembly line process)
Bas van Dijk wrote: data Iso (⇝) a b = Iso { ab ∷ a ⇝ b , ba ∷ b ⇝ a } type IsoFunc = Iso (→) instance Category (⇝) ⇒ Category (Iso (⇝)) where id = Iso id id Iso bc cb . Iso ab ba = Iso (bc . ab) (ba . cb) An 'Iso (⇝)' also _almost_ forms an Arrow (if (⇝) forms an Arrow): instance Arrow (⇝) ⇒ Arrow (Iso (⇝)) where arr f = Iso (arr f) undefined first (Iso ab ba) = Iso (first ab) (first ba) second (Iso ab ba) = Iso (second ab) (second ba) Iso ab ba *** Iso cd dc = Iso (ab *** cd) (ba *** dc) Iso ab ba Iso ac ca = Iso (ab ac) (ba . arr fst) -- or: (ca . arr snd) But note the unfortunate 'undefined' in the definition of 'arr'. This seems to suggest that all the methods besides 'arr' need to move to a separate type class. I agree. The power of Arrows as they currently are is that we can enlarge the ordinary set of functions (-). But if arr would be excluded from the Arrow class, we could remove arrows, too. For example, in your Iso example, we want to consider not all morphisms, but only the isomorphisms. It would be nice to have a standard type class to express this kind of thing, and it would be nice to have arrow notation (or some variant of arrow notation) for it. However, I'm not so sure about the types of (***) etc. Currently, we have (***) :: (a ~ b) - (c ~ d) - ((a, c) ~ (b, d)) () :: (a ~ b) - (a ~ c) - (a ~ (b, c)) This seems to say that (~) has products as follows: The object part of the product bifunctor is (,), the morphism part of the product bifunctor is (***), the mediating arrow is constructed by (), and the projections are (arr fst) and (arr snd). I see two problems with this definition: The object part of the bifunctor is fixed, and the projections are given in terms of arr. Wouldn't it be better to have a definition like this: class Category (~) = Products (~) where (***) :: (a ~ b) - (c ~ d) - ((a, c) ~ (b, d)) () :: (a ~ b) - (a ~ c) - (a ~ (b, c)) fst :: (a, b) ~ a snd :: (a, b) ~ b Or even like this: class Category (~) = Products (~) where type Product a b (***) :: (a ~ b) - (c ~ d) - (Product a c ~ Product b d) () :: (a ~ b) - (a ~ c) - (a ~ Product b c) fst :: Product a b ~ a snd :: Product a b ~ b Unfortunately, I don't see how to define fst and snd for the Iso example, so I wonder whether Iso has products? Tillmann ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Different choice operations in a continuation monad
Heinrich Apfelmus wrote: Sebastian Fischer wrote: I still don't understand why it is impossible to provide `orElse` with the original type. I will think more about the reason you gave. The reason is that you have chosen the wrong type for your continuation monad; it should be newtype CMaybe a = CMaybe (forall r. (a - Maybe r) - Maybe r) Yes, with this type `orElse` has the same type as `mplus`, which is very nice. Aside Personally, I recommend to stop thinking about continuations altogether and instead use the approach I've outlined in The Operational Monad Tutorial I appreciate your operational monad tutorial both for the idea and how you explained it. But the advice stop thinking about X because Y is better feels odd to me. Before I know by myself that Y is better than X (which requires thinking about both X and Y) I don't feel comfortable following such advice. Afterwards, I don't need such advice ;) There may be more to X than just Y. IIRC, there is more to 'continuations' than 'monads'. For example, the implementation of `callCC` does not type check with your changed data type. /Aside I shall try to implement a monad that supports two choice operations (one which fulfills the distributive law and one which satisfies the cancellation property) with the operational package. Cheers, Sebastian -- Underestimating the novelty of the future is a time-honored tradition. (D.G.) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] What is Haskell unsuitable for?
- an existing solution exists which does the job and you know you're not going to patch the source ( eg OpenOffice or Linux kernel, or simple build scripts. There is already make etc ) Don't you find yourself looking at the documentation each time you want to write a loop in a Makefile ? Cause I do, and each time I think : what can't I script this in haskell or caml ?. If anyone here is looking for a graph search / GHC API / Unix filesystem / parsec exercise, and has got the time to glue all this together : DO IT ! Cheers, PE ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] What is Haskell unsuitable for?
On Wed, Jun 16, 2010 at 11:04 AM, Ivan Lazar Miljenovic ivan.miljeno...@gmail.com wrote: David Virebayre dav.vire+hask...@gmail.com writes: *Real* programmers use butterfiles [1]. If your files are composed of butter, Id hate to see how you store them in an efficient manner... Oh well, at least le ridicule ne tue pas(1)... I'm a typo specialist. (1) Being ridiculous doesn't kill :) David. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] What is Haskell unsuitable for?
I remember quite a few months ago, someone gave a presentation on Haskell and he admitted that so far all he had used it for were shell scripts. He said that his Haskell shell scripts ran faster than his shell scripts written in ? So all he had used so far, was just the imperative part of Haskell. On Wed, 16 Jun 2010 00:06:54 UTC, Marc Weber marco-owe...@gmx.de wrote: Hi Aditya Siram, - maybe shell scripting: running ghci takes longer than starting bash. Compiling is not always an option because executables are bigger than shell scripts or C executables snip Marc Weber -- Regards, Casey ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: What is Haskell unsuitable for?
On Wed, 2010-06-16 at 10:34 +0200, David Virebayre wrote: On Wed, Jun 16, 2010 at 8:00 AM, Michael Snoyman mich...@snoyman.com wrote: Next you'll say there's no need for anyone to ask whether they prefer vi or emacs... ;-) Of course *real* programmers use ed. It is the standard editor[1]. *Real* programmers use butterfiles [1]. [1] http://xkcd.com/378/ David. Emacs is also accepted IIRC - M-x butterfly Regards signature.asc Description: This is a digitally signed message part ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Vague: Assembly line process
On Tuesday, 15. June 2010 19:43:26 Steve Schafer wrote: On Tue, 15 Jun 2010 19:23:35 +0200, you wrote: When I know my supplies I want to know what I can produce. When I know what I want to produce I want to know what supplies I need for that. Both kinds of questions should be answered by a singe Process thingy. I want to be able to chain processes and the whole thing should still act like a Process. This is a type of constraint network. If you have access to _Structure and Interpretation of Computer Programs_, there is a section therein devoted to constraint networks. Will check this out. I was hoping that something simpler would suffice. I am afraid of CSPs. Today I was playing with a matrix representation. I mean the one you learn in school for linear optimization problems. Usually the matrix is written so it tells you how much of each supply you need to produce a unit of outputs. So when you know the outputs you can compute what you need as a minimum. You can invert the matrix and it'll work on the oppsite direction: when you know the inputs it'll tell you what you can produce at most. Then I thought, what if I replace the (*) and (+) operations which are applied when I multipy the matrix with a vector (i.e. a vector if inputs or outputs) by something more general. So I replaced (+) by function application and my matrix was now a matrix of functions. But then I got lost trying to find a way to invert such a matrix. FWIW: while googeling around how to invert a matrix of functions I stumbeled across the Process Specification Language. At least they defined an ontology, but there isn't much of computing stuff there. http://www.mel.nist.gov/psl/ -- Martin ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Vague: Assembly line process
On Wed, 16 Jun 2010 18:30:47 +0200, you wrote: Then I thought, what if I replace the (*) and (+) operations which are applied when I multipy the matrix with a vector (i.e. a vector if inputs or outputs) by something more general. So I replaced (+) by function application and my matrix was now a matrix of functions. But then I got lost trying to find a way to invert such a matrix. You'd have to have a general way of finding the inverse of a function, which doesn't exist (many functions aren't invertible at all, for example). -Steve ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Announce: hs2dot 0.1.1 - generate graphviz code by analyzing Haskell source code files
It's a small tool that lets you automatically generate graphviz/dot code that visualize the relations between data types, types and type classes. This sounds very familiar to my SourceGraph package that's already on Hackage... I hope that some friendly competition can spur both of us to deliver even better tooling :) You, however, also add the type signatures to your graph; I have the sneaking suspicion that this could get too noisy if you also try to visualise functions in a large module. Visualizing every aspect is probably never a good idea. At the moment I'm sketching on alternative visualizations where only relations between modules show up or where the data constructors for data types aren't visualized. On a related note: has anyone yet tried to visualize the flow of the IO monad in an application? -- Oscar ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] The Arrow class (was: Vague: Assembly line process)
On Wed, Jun 16, 2010 at 6:55 AM, Tillmann Rendel ren...@mathematik.uni-marburg.de wrote: Bas van Dijk wrote: data Iso (⇝) a b = Iso { ab ∷ a ⇝ b , ba ∷ b ⇝ a } type IsoFunc = Iso (→) instance Category (⇝) ⇒ Category (Iso (⇝)) where id = Iso id id Iso bc cb . Iso ab ba = Iso (bc . ab) (ba . cb) An 'Iso (⇝)' also _almost_ forms an Arrow (if (⇝) forms an Arrow): instance Arrow (⇝) ⇒ Arrow (Iso (⇝)) where arr f = Iso (arr f) undefined first (Iso ab ba) = Iso (first ab) (first ba) second (Iso ab ba) = Iso (second ab) (second ba) Iso ab ba *** Iso cd dc = Iso (ab *** cd) (ba *** dc) Iso ab ba Iso ac ca = Iso (ab ac) (ba . arr fst) -- or: (ca . arr snd) But note the unfortunate 'undefined' in the definition of 'arr'. This comes up every couple of years, I think the first attempt at formulating Iso wrongly as an arrow was in the There and Back Again paper. http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.60.7278 It comes up now and again, because the types seem to _almost_ fit. =) The reason is that an arrow is a closed pre-Cartesian category with a little bit of extra structure. Isomorphisms and embedding-projection pairs are a bit too constrained to meet even the requirements of a pre-Cartesian category, however. This seems to suggest that all the methods besides 'arr' need to move to a separate type class. You may be interesting in following the construction of a more formal set of categories that build up the functionality of arrow incrementally in category-extras. An arrow can be viewed as a closed pre-cartesian category with an embedding of Hask. Iso on the other hand is much weaker. The category is isomorphisms, or slightly weaker, the category of embedding-projection pairs doesn't have all the properties you might expect at first glance. You an define it as a Symmetric Monoidal category over (,) using a Bifunctor for (,) over Iso: http://hackage.haskell.org/packages/archive/category-extras/0.53.5/doc/html/Control-Functor.html the assocative laws from: http://hackage.haskell.org/packages/archive/category-extras/0.52.1/doc/html/Control-Category-Associative.html The definitions of Braided and Symmetric from: http://hackage.haskell.org/packages/archive/category-extras/0.52.1/doc/html/Control-Category-Braided.html and the Monoidal class from: http://hackage.haskell.org/packages/archive/category-extras/0.52.1/doc/html/Control-Category-Monoidal.html This gives you a weak product-like construction. But as you noted, fst and snd cannot be defined, so you cannot define Cartesian http://hackage.haskell.org/packages/archive/category-extras/0.53.5/doc/html/Control-Category-Cartesian.html let alone a CCC http://hackage.haskell.org/packages/archive/category-extras/0.53.5/doc/html/Control-Category-Cartesian-Closed.html or Arrow. =( Wouldn't it be better to have a definition like this: class Category (~) = Products (~) where (***) :: (a ~ b) - (c ~ d) - ((a, c) ~ (b, d)) () :: (a ~ b) - (a ~ c) - (a ~ (b, c)) fst :: (a, b) ~ a snd :: (a, b) ~ b You've stumbled across the concept of a Cartesian category (or at least, technically 'pre-Cartesian', though the type of product also needs to be a parameter or the dual of a category with sums won't be a category with products. http://hackage.haskell.org/packages/archive/category-extras/0.52.1/doc/html/Control-Category-Cartesian.html Or even like this: class Category (~) = Products (~) where type Product a b (***) :: (a ~ b) - (c ~ d) - (Product a c ~ Product b d) () :: (a ~ b) - (a ~ c) - (a ~ Product b c) fst :: Product a b ~ a snd :: Product a b ~ b This was the formulation I had originally used in category-extras for categories. I swapped to MPTCs due to implementation defects in type families at the time, and intend to swap back at some point in the future. Unfortunately, I don't see how to define fst and snd for the Iso example, so I wonder whether Iso has products? It does not. =) -Edward Kmett ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Different choice operations in a continuation monad
Sebastian Fischer wrote: Heinrich Apfelmus wrote: The reason is that you have chosen the wrong type for your continuation monad; it should be newtype CMaybe a = CMaybe (forall r. (a - Maybe r) - Maybe r) Yes, with this type `orElse` has the same type as `mplus`, which is very nice. Aside Personally, I recommend to stop thinking about continuations altogether and instead use the approach I've outlined in The Operational Monad Tutorial I appreciate your operational monad tutorial both for the idea and how you explained it. But the advice stop thinking about X because Y is better feels odd to me. Before I know by myself that Y is better than X (which requires thinking about both X and Y) I don't feel comfortable following such advice. Afterwards, I don't need such advice ;) Very true. :) My flimsy personally was an attempt to declare my recommendation optional. I failed to say the right thing even then, for I don't mean to stop thinking about continuations in general, just to discourage them as foundation for implementing other monads. There may be more to X than just Y. IIRC, there is more to 'continuations' than 'monads'. For example, the implementation of `callCC` does not type check with your changed data type. Ah, indeed, callCC in the operational setting is much trickier than I thought. However, it also seems to be the reason why your original approach does not work so well! Basically, your choice of implementation newtype CMaybe r a = CMaybe ((a - Maybe r) - Maybe r) supplies a default semantics for callCC . But this means that when implementing orElse , you also have to consider its interaction with callCC , even when you actually don't want to expose or implement a callCC function. As for the interaction: what should ((callCC ($ 0) mzero) `orElse` return 2) = return . (+3) be? If the scope of callCC should not extend past orElse , then this evaluates to return 5 . But this choice of scope dictates the type that Holger mentioned. If the the scope of callCC should extend beyond the orElse , so that the whole thing evaluates to mzero , orElse will have the type of mplus . But then, I think that your implementation type CMaybe needs to be more sophisticated because orElse now needs to detect whether the argument contains a call to callCC or not in order to distinguish ((callCC ($ 0) mzero) `orElse` return 2) = return . (+3) == mzero from (mzero `orElse` return 2) = return . (+3) == return 5 In short, the interaction between orElse and callCC is tricky, and it would be unfortunate to be forced to consider it due to a premature choice of implementation type. This can't happen with the operational approach, because that one merely implements the free monad over a set of operations. I shall try to implement a monad that supports two choice operations (one which fulfills the distributive law and one which satisfies the cancellation property) with the operational package. The main task will probably be to figure out the interaction between mplus and orElse , i.e. to consider what stuff like a `orElse` (b `mplus` c) should evaluate to. Regards, Heinrich Apfelmus -- http://apfelmus.nfshost.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] HaskellWiki and Wikipedia
Hi all. There are some notions which are not described in HaskellWiki but described in Wikipedia, e.g. catamorphism. When clicking on a link [[catamorphism]] that leads to create a new page it would be nice to show link to a corresponding Wikipedia page. Also search in Wikipedia on the search results page. -- Best regards, Roman Beslik. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] HaskellWiki and Wikipedia
I have an article describing catamorphisms in some detail that is available online at http://knol.google.com/k/catamorphisms I hereby give whatever rights I need to give to whomever I need to give them to so that it might be used as a basis for a HaskellWiki entry. I realize that this is addressing the symptom, not the cause, but I'm all for recruiting others to do legwork. ;) Sent from my iPhone On Jun 16, 2010, at 2:35 PM, Roman Beslik ber...@ukr.net wrote: Hi all. There are some notions which are not described in HaskellWiki but described in Wikipedia, e.g. catamorphism. When clicking on a link [[catamorphism]] that leads to create a new page it would be nice to show link to a corresponding Wikipedia page. Also search in Wikipedia on the search results page. -- Best regards, Roman Beslik. ___ 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] Re: Different choice operations in a continuation monad
On Wed, Jun 16, 2010 at 9:11 AM, Sebastian Fischer s...@informatik.uni-kiel.de wrote: Heinrich Apfelmus wrote: Sebastian Fischer wrote: I still don't understand why it is impossible to provide `orElse` with the original type. I will think more about the reason you gave. The reason is that you have chosen the wrong type for your continuation monad; it should be newtype CMaybe a = CMaybe (forall r. (a - Maybe r) - Maybe r) Yes, with this type `orElse` has the same type as `mplus`, which is very nice. This type is the same as Codensity Maybe using category-extras which is a 'bit bigger than Maybe'. (To see why, figure out how Codensity Reader is isomorphic to State!) This is the wiggle room you're using to get the distributive operator. Another encoding of Maybe is through Yoneda Endo newtype YEMaybe a = YEMaybe (forall r. (a - r) - r - r) and it is isomorphic to the original Maybe type, with its same limitations. A definition that is equivalent to this is in my monad-ran package, along with definitions CPS/right-kan-extension-based definitions for other common monads, including the MTL, IO, ST s, and STM. -Edward Kmett ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] HaskellWiki and Wikipedia
Edward Kmett ekm...@gmail.com writes: I realize that this is addressing the symptom, not the cause I'm not so sure Wikipedia is a good source of information for this. I've tried to read some of their articles on e.g. type systems or generic programming, but they tend to be confused by other languages and their communities using these terms to mean different things. So I think it is better to build on the HaskellWiki where the words can mean what we want them to. -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
Re: [Haskell-cafe] Announce: hs2dot 0.1.1 - generate graphviz code by analyzing Haskell source code files
Oscar Finnsson oscar.finns...@gmail.com writes: On a related note: has anyone yet tried to visualize the flow of the IO monad in an application? You mean a control flow graph? -- Ivan Lazar Miljenovic ivan.miljeno...@gmail.com IvanMiljenovic.wordpress.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Announce: hs2dot 0.1.1 - generate graphviz code by analyzing Haskell source code files
On a related note: has anyone yet tried to visualize the flow of the IO monad in an application? You mean a control flow graph? Exactly. In (most) other programming languages it would be impossible for a tool to automatically know which flow to concentrate on/visualize but in Haskell it should be at least theoretically possible to inspect a package/module and trace the IO monad (beginning in main for an executable) in the code and visualize it as a control flow graph. I think it would probably be a great tool that would help one to inspect the architecture. -- Oscar ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] HaskellWiki and Wikipedia
On Wed, Jun 16, 2010 at 11:35 AM, Roman Beslik ber...@ukr.net wrote: Hi all. There are some notions which are not described in HaskellWiki but described in Wikipedia, e.g. catamorphism. When clicking on a link [[catamorphism]] that leads to create a new page it would be nice to show link to a corresponding Wikipedia page. Also search in Wikipedia on the search results page. Both use the mediawiki engine. I know at one point mediawiki supported a notion of interwiki links. Perhaps this feature still exists and would give a way for us to more naturally link to wikipedia articles? http://www.mediawiki.org/wiki/Help:Links#Interwiki_links Jason http://www.mediawiki.org/wiki/Help:Links#Interwiki_links ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Using the ContT monads for early exits of IO ?
Hello Günther, I use ContT monads for early exit often, because that's one of the things they encode naturally. But I don't do this with callCC. I prefer monadLib over mtl/transformers, which has a specific function for that: abort :: (AbortM m i) = i - m a where AbortM is a class for monads, whose computations are abortable. All ContT monads are instances. This is also a nice way to break out of 'forever'. Using an error monad (like Maybe) may be more natural of course. Greets, Ertugrul Günther Schmidt gue.schm...@web.de wrote: Hi everyone, I'm about to write a rather lengthy piece of IO code. Depending on the results of some of the IO actions I'd like the computation to stop right there and then. Now I know in general how to write this but I'm wondering if this is one of those occasions where I should make use of the Cont monad to make an early exit. Günther -- nightmare = unsafePerformIO (getWrongWife = sex) http://blog.ertes.de/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Mining Twitter data in Haskell and Clojure
WIth @dafis's help, there's a version tagged cafe3 on the master branch which is better performing with ByteString. I also went ahead and interned ByteString as Int, converting the structure to IntMap everywhere. That's reflected on the new intern branch at tag cafe4. Still it can't do the full 35 days for all users. It comes close, however, to 30 days under ghc 6.12 with the IntMap -- just where 6.10 was with Map ByteString. Some profiling is in prof/ subdirectory, with the tag responsible and RTS profiling option in the file name; .prof are -P, and the rest are -hX. When I downsize the sample data to 1 million users, the whole run, with -P profiling, is done in 7.5 minutes. Something happens when tripling that amount. For instance, making -A10G may cause sefgault, after a fast run up to 10 days, then seeming stalling, and a dump of days up to 28 before the segfault. -A5G comes closest, to 30 days, when coupled with -H1G. It's not clear to me how to work -A and -H together. I'll work with Simon to investigate the runtime, but would welcome any ideas on further speeding up cafe4. -- Alexy ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe