Re: [Haskell-cafe] Problem with HXT `when`
On 13-09-21 05:13 AM, Vlatko Basic wrote: I'd like to extract A texts from row with header Caption, and have come up with this runX $ doc (deep (hasName tr) -- filter only TRs withTraceLevel 5 traceTree -- shows correct TR `when` deep ( hasName th -- filter THs with specified text getChildren hasText (==Caption) ) -- inner deep getChildren hasName td -- shouldn't here be only one TR? getChildren ) getName (getChildren getText) -- list has TDs from all three TRs Operator precedences: infixr 1 `when` infixl 9 (default) Therefore, this expression redundantly parenthesized and systematically indented to ensure that you are on the same page with the computer is: runX $ doc ( deep (hasName tr) -- begin{conditionally prints but otherwise is arr id} ( withTraceLevel 5 traceTree `when` deep ( hasName th getChildren hasText (==Caption) ) -- inner deep ) -- end{conditionally prints but otherwise is arr id} getChildren hasName td getChildren ) ( getName (getChildren getText) ) The condition on thCaption/th ends up controlling trace messages only; it is not used to limit real processing. when doesn't help even when used correctly: it doesn't ban data. guards and containing ban data, but you have to put them at the right place, i.e., parenthesize correctly. runX $ doc ( deep ( hasName tr `containing` deep ( hasName th getChildren hasText (==Caption) ) ) getChildren hasName td getChildren ) ( getName (getChildren getText) ) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Mystery of an Eq instance
On 13-09-20 07:47 AM, damodar kulkarni wrote: *Main sqrt (10.0) ==3.1622776601683795 True [...] *Main sqrt (10.0) ==3.16227766016837956435443343 True This is not even specific to Haskell. Every language that provides floating point and floating point equality does this. (To date, P(provides floating point equality | provides floating point) seems to be still 1.) In the case of Haskell, where you may have a choice: Do you want floating point ? If you say yes, then you have two problems. 1. At present, Haskell puts under Ord, and Ord under Eq. You must accept Eq to get Ord. If you reject this, you're asking the whole community to re-arrange that class hierarchy just for a few types. 2. With or without your approval, one can still defy you and define: eq x y = not_corner_case x not_corner_case y not (xy) not (xy) See, == can be derived from . ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Proposal: New syntax for Haskell
A specification language is desirable. (Test cases are special cases of specifications. Test-driven development is a revival of the waterfall process.) For specifying interactions (computer-computer or computer-human), I recommend live sequence charts of David Harel, or generally any one based on temporal logics. The problems with natural languages or sublanguages for anything from specification to implementation are: 0. You have to transit to formal languages at some point (the implementation is formal). The later you transit, the later you can use a computer to analyze and/or simulate for catching mistakes. You catch fewer mistakes, and later. 1. To re-gain the benefit of formality above, some people settle for restrictive sublanguages. Thus naturalness is lost anyway. The problems below, however, are still preserved. 2. Natural languages and sublanguages lack diagrams. For some specifications, formal diagrammatic languages are more suitable (e.g., live sequence charts). 3. Natural languages and sublanguages lack scoping and parenthesizing such as in mathematical notation and formal languages: sqrt (sin (x^2 + y) - 2) * z (forall r. (Int - M r) - M r) - M Int forall r. ((Int - M r) - M r) - M Int ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] GLFW not working in Cabal 1.18
On 13-09-10 09:27 PM, Thiago Negri wrote: The package GLFW is not building in Cabal 1.18. Setup.hs [1] depends on `rawSystemStdInOut` [2] that changed signature between 1.16 and 1.18. Consider cabal install --cabal-lib-version=1.16. Replace 1.16 by the correct number. Use ghc-pkg list Cabal to find the correct number. http://www.haskell.org/haskellwiki/PVP allows 1.16-1.18 to change public API. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Readable GHC 7.6.3 docs (Bootstrapped)
On 13-09-11 07:31 AM, Obscaenvs wrote: since the official version is a bit too TimesNewRoman-y for my ...developed taste. I question that. Is it the official CSS, or is it your own browser setting? I see no TimesNewRoman-y here. The official version in my Firefox (Ubuntu 13.04 Desktop): http://imageshack.us/a/img546/2439/6fqa.png The p element containing Let's start with an example GHCi session is under these CSS rules, which clearly requests a Sans Serif font. http://imageshack.us/a/img194/9026/0peh.png Lastly, my Firefox font setting: http://imageshack.us/a/img694/1183/jhc3.png ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Can I use String without in ghci?
On 13-09-01 02:02 AM, yi lu wrote: I have noticed if *bar* is predefined or it is a number, it can be used as arguments. But can other strings be used this way? Like in bash, we can use *ping 127.0.0.1* where *127.0.0.1* is an argument. Does Bash have a rich type system, like Haskell? Does Haskell use $joy to refer to a variable, and joy to not refer to a variable, like Bash? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Can I use String without in ghci?
On 13-09-01 02:41 AM, Mateusz Kowalczyk wrote: It's a bit like asking whether you can do addition everywhere by just typing the numbers to each other (no cheating and defining number literals as functions ;) ). To your horror, common math language does some of that. When 3 and ½ are typed next to each other, i.e., 3½ it is addition. See also page 8 in http://www.cs.utexas.edu/users/EWD/ewd13xx/EWD1300.PDF or look for Invisible operators in http://www.cs.utexas.edu/users/EWD/transcriptions/EWD13xx/EWD1300.html ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] sequence causing stack overflow on pretty small lists
On 13-08-26 04:46 AM, Niklas Hambüchen wrote: Effectively, sequence is a partial function. (Note: We are not trying to obtain a lazy list of random numbers, use any kind of streaming or the likes. We want the list in memory and use it.) We noticed that this problem did not happen if sequence were implemented with a difference list. What do you think about this? Should we fix functions like this, probably trading off a small performance hit, or accept that idiomatic Haskell code can crash at any time? 1. Disputed: sequence overflows stack, for all monads (Bonus: a demo of Control.Monad.ST.Lazy) (Bonus: a secret of Control.Monad.State revealed) import Control.Monad.ST.Lazy(runST) import Control.Monad.State(evalState) long :: Monad m = m [Int] long = sequence (map return [1..100]) infinite :: Monad m = m [()] infinite = sequence (repeat (return ())) -- these take constant time one_a = take 1 (runST long) one_b = take 1 (evalState long ()) unit_a = take 1 (runST infinite) unit_b = take 1 (evalState infinite ()) sequence is exactly right for Control.Monad.ST.Lazy and Control.Monad.State. If you fix sequence, you will cause idiomatic use of sequence and Control.Monad.State to use too much time (up to infinite) and too much memory (up to infinite). Note: Control.Monad.State = Control.Monad.State.Lazy For more demos of Control.Monad.ST.Lazy and Control.Monad.State(.Lazy), see my http://lpaste.net/41790 http://lpaste.net/63925 2. What to do for IO, Control.Monad.ST, Control.Monad.State.Strict, etc As you said, we can combine right recursion (foldM) and difference list (aka Hughes list). I will dispute its questionable benefit in the next section, but here it is first. sequence_hughes ms = do h - go id ms return (h []) where go h [] = return h go h (m:ms) = do x - m go (h . (x :)) ms equivalently, sequence_hughes ms = do h - foldM op id ms return (h []) where op h m = do x - m return (h . (x :)) However, as I said, sequence_hughes is totally wrong for Control.Monad.State and Control.Monad.ST.Lazy. And this is not even my dispute of the questionable benefit. 3. Disputed: stack is limited, heap is unlimited sequence_hughes consumes linear heap space in place of linear stack space. That's all it does. There is no free lunch. Empirically: on linux i386 32-bit GHC 7.6.3 -O2: xs - sequence (replicate 200 (return 0 :: IO Int)) print (head xs) 8MB stack, 16MB heap xs - sequence_hughes (replicate 200 (return 0 :: IO Int)) print (head xs) 24MB heap What has sequence_hughes saved? Since a couple of years ago, GHC RTS has switched to growable stack, exactly like growable heap. It starts small, then grows and shrinks as needed. It does not need a cap. The only reason it is still capped is the petty: to stop the program eating up all the available memory in the machine if it gets into an infinite loop (GHC User's Guide) Asymmetrically, the heap is not capped by default to stop the program eating up all the available memory. And the default stack cap 8MB is puny, compared to the hundreds of MB you will no doubt use in the heap. (Therefore, on 64-bit, you have to change 200 to 100 in the above.) (Recall: [Int] of length n entirely in memory takes at least 12n bytes: 4 for pointer to Int, 4 for the number itself, 4 for pointer to next, and possibly a few more bytes I forgot, and possibly a few more bytes if the Int is lazy e.g. randomIO as Bryan said. That's just on 32-bit. Multiply by 2 on 64-bit.) The correct fix is to raise the stack cap, not to avoid using the stack. Indeed, ghci raises the stack cap so high I still haven't fathomed where it is. This is why you haven't seen a stack overflow in ghci for a long time. See, ghci agrees: the correct thing to do is to raise the stack cap. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] GHC and backwards compatibility
On 13-08-19 10:58 AM, Ketil Malde wrote: b) the output isn't very helpful in tracking down the cause of this problem, it claims that all these packages depend on array-0.4.0.1, which is a lie. Somewhere, somehow, somethings depends on this (or at least a newer version), but I have no clue how to figure out which, except examining each of these packages and their dependencies manually. cabal install -v3 contains the complete record of deliberation. Although it's long, I know how to read it. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Applicative is like an Arrow
On 13-08-16 03:29 PM, Dan Burton wrote: Idioms are oblivious, arrows are meticulous, monads are promiscuous http://homepages.inf.ed.ac.uk/wadler/papers/arrows-and-idioms/arrows-and-idioms.pdf I much recommend this paper. Underrated, underknown, pinpointing, unifying. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Haskell Platform and Leksah on Windows
On 13-08-07 01:18 AM, Mihai Maruseac wrote: Anyway, he blogged about his problems at http://dorinlazar.ro/haskell-platform-windows-crippled/ and I'm sure that we can work on fixing some of them. To learn Haskell on Windows, and with Haskell Platform already installed, it is very easy and KISS to just add a text editor (even notepad will do for a while), and start experimenting using ghci. Haskell Platform is not cripplied. The next Windows user may find it just fine. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Alternative name for return
On 13-08-06 01:14 AM, J. Stutterheim wrote: N.B. I am _not_ proposing that we actually change the name of `return`. I do currently have the opportunity to pick names for common functions in a non-Haskell related project, so I was wondering if there perhaps is a better name for `return`. I suggest simply. Having said that, I like all the other names too. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Getting the 'ThreadId' of the calling thread
On 13-07-29 08:35 AM, Nikita Karetnikov wrote: I feel that a 'myThreadId' action, which is defined in this module [1], is useless, but I'm not sure. I think it will always return the Map.find: element not in the map exception because a 'threadMap' contains an empty 'ThreadMap'. Is it right, or am I missing something? Other actions such as withLinksDo and forkLinkIO' insert stuff into threadMap. It can be non-mepty. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Catch multiple exceptions using 'Control.Exception'
On 13-07-06 12:12 PM, Nikita Karetnikov wrote: Is there an open sum type or a closed existential type? OCaml has open sum types. I haven't really seen closed existential types. (I have seen some approximations, but each lacks one last bit.) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Upgrading GHC 7.6.3 global packages to latest versions
On 13-06-28 04:06 AM, Rouan van Dalen wrote: Now when I try to install the latest version of the [time] package, I have 2 time packages, 1 in the global package db (the older version), and 1 in the user package db (the newer version). Now I would like subsequent installed packages to always use the latest version of the [time] package. But if i try to install the [plugins] package, cabal says: You're trying to use plugins. That means you're also trying to use the GHC API (because plugins uses it). Then you have 0 options. The GHC API manifests as a package, called ghc again. It comes with GHC, and it is built againt whatever instances of array, bytestring, containers, time, template-haskell, etc etc that also come with GHC. It will not work with any array, bytestring, containers, time, template-haskell, etc etc that you build later. Definitely not different versions, and highly likely not even same version. It is sensitive to the exact build. Look at the output of ghc-pkg field ghc depends You see versions and hashes. You have to match versions and hashes, both of them. It accepts no substitute. More generally, it is confusing for cabal non-pros to allow two versions to co-exist. Oh, the pros keep saying it's fine, but that's because they are pros, they aren't confused. To determine whether you are a pro, read my http://www.vex.net/~trebla/haskell/sicp.xhtml If it contains some information new to you, you are not a pro. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANN: custom-hackage
On 13-06-13 11:09 AM, Niklas Hambüchen wrote: https://github.com/nh2/custom-hackage An (almost trivial) script to generate 00-index.tar.gz which is necessary to run your own `remote-repo`. I write the following critique with much reluctance, since I will be saying a lot of this cannot possibly work, here is why, but I would also like to think that it had worked for you before you published it. Assume the remote-repo line goes like remote-repo: custom:http://127.0.0.1:8080/packages/archive And assume it has just one package, formula-1.1 Then your scheme uses this layout: http://127.0.0.1:8080/00-index.tar.gz http://127.0.0.1:8080/packages/archive/formula/1.1/formula-1.1.tar.gz However, cabal-install expects this layout: http://127.0.0.1:8080/packages/archive/00-index.tar.gz http://127.0.0.1:8080/packages/archive/package/formula-1.1.tar.gz I know this by both reading cabal-install source code and empirical tests, both 0.14 and 1.16. I have a working example at http://www.vex.net/~trebla/haskell/conrepo Lastly, I want to emphasize these points: The layout is different from Hackage's; cabal-install source code hardcodes treating Hackage differently. Yes, it goes out of its way to detect http://hackage.haskell.org/packages/archive; and do a different thing. Mimicking Hackage is futile, unless you go out of your way to also mimic the host name hackage.haskell.org. And the layout is different from local-repo's; local-repo's is in fact close to Hackage's. See my http://www.vex.net/~trebla/haskell/cabal-cabal.xhtml#remote-repo ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Cabal config file Guide
On 13-05-25 04:52 PM, Daniel Díaz Casanueva wrote: As you already know, cabal-install is configured in the file config. It has a lot of fields, but I didn't find a single place where each field is explained with detail. There is none, but my new and timely http://www.vex.net/~trebla/haskell/cabal-cabal.xhtml talks about a few, and one of them is a real surprise. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] runhaskell flags: What is going on?
On 13-05-03 10:35 AM, Niklas Hambüchen wrote: runhaskell -fno-warn-unused-matches Myfile.hs [no output whatsoever but exit code 127] runhaskell -fasdf Myfile.hs [no output whatsoever but exit code 127] $ runghc --help Usage: runghc [runghc flags] [GHC flags] module [program args] The runghc flags are -f /path/to/ghc Tell runghc where GHC is --helpPrint this usage information --version Print version number # how to say end of runghc flags and start of GHC flags? # it seems undocumented. bad bad bad. # oh wait, it is documented, read GHC user's guide chapter 3 # actually, read the whole thing # the GHC user's guide is on your hard disk $ cat g.hs main = putStrLn hello where v=True $ runghc -- -fwarn-unused-binds g.hs g.hs:1:31: Warning: Defined but not used: `v' hello # \∩/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] conditional branching vs pattern matching: pwn3d by GHC
When I was writing http://www.vex.net/~trebla/haskell/crossroad.xhtml I wanted to write: branching on predicates and then using selectors is less efficient than pattern matching, since selectors repeat the tests already done by predicates. It is only ethical to verify this claim before writing it. So here it goes, eval uses pattern matching, fval uses predicates and selectors: module E where data E = Val{fromVal::Integer} | Neg{fromNeg::E} | Add{fromAdd0, fromAdd1 :: E} isVal Val{} = True isVal _ = False isNeg Neg{} = True isNeg _ = False isAdd Add{} = True isAdd _ = False eval (Val n) = n eval (Neg e0) = - eval e0 eval (Add e0 e1) = eval e0 + eval e1 fval e | isVal e = fromVal e | isNeg e = - fval (fromNeg e) | isAdd e = fval (fromAdd0 e) + fval (fromAdd1 e) Simple and clear. What could possibly go wrong! $ ghc -O -c -ddump-simpl -dsuppress-all -dsuppress-uniques E.hs ... Rec { fval fval = \ e - case e of _ { Val ds - ds; Neg ds - negateInteger (fval ds); Add ipv ipv1 - plusInteger (fval ipv) (fval ipv1) } end Rec } Rec { eval eval = \ ds - case ds of _ { Val n - n; Neg e0 - negateInteger (eval e0); Add e0 e1 - plusInteger (eval e0) (eval e1) } end Rec } Which of the following best describes my feeling? [ ] wait, what? [ ] lol [ ] speechless [ ] oh man [ ] I am so pwn3d [ ] I can't believe it [ ] what can GHC not do?! [ ] but what am I going to say in my article?! [ ] why is GHC making my life hard?! [X] all of the above ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] customizing haskeline?
On 13-04-14 10:22 PM, Evan Laforge wrote: I tried to colorize a haskeline prompt by putting control characters in it, but line editing was hopelessly confused, presumably because haskeline doesn't understand control characters and thought the prompt was longer than it really was. http://trac.haskell.org/haskeline/wiki/ControlSequencesInPrompt More broadly, http://trac.haskell.org/haskeline/wiki/WikiDocumentation ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Building the Haskell Platform in Linux
On 13-04-13 12:19 AM, Daniel Díaz Casanueva wrote: Hi cafe! Probably you all know how to do this, but I myself found confused when building the Haskell Platform in Linux for my first time. I was using Linux for my first time too! The first problem I encountered was to decide what linux packages install to make the ./configure successful in both GHC binary distribution and the Haskell Platform. So I collected the names of the minimum set of packages that you need to have installed before starting with GHC and the Platform in a small blog post: http://deltadiaz.blogspot.com/2013/04/haskell-platform-from-source-in-linux.html Shameless plug: also my http://www.vex.net/~trebla/haskell/haskell-platform.xhtml and it will be yet updated again next version. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Building the Haskell Platform in Linux
On 13-04-14 08:12 PM, Daniel Díaz Casanueva wrote: By the way, a random question, what's the memory of the computer you used to build the Platform? I have always used my laptop with 3GB RAM. I have not measured how much is actually needed, or what happens if I provide less. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Haskell is a declarative language? Let's see how easy it is to declare types of things.
On 13-04-05 04:56 AM, Tom Ellis wrote: any is very ambiguous. Doesn't the problem go away if you replace it with all? Yes, that is even better. The world would be simple and elegant if it did things your way, and would still be not too shabby if it did things my way, no? «Learn You a Haskell for Great Good!» by Miran Lipovača: http://learnyouahaskell.com/types-and-typeclasses#type-variables Because it's not in capital case it's actually a type variable. That means that a can be of any type. «The Haskell School of Expression» by Paul Hudak: page 57 Intuitively, what we'd like to say is that, for any type a, the type of length is [a] - Integer. So length can be applied to a list containing elements of any type. (Does [True, 'x'] count as a list containing elements of any type?) At this point, you may be rightful to accuse me of taking sentences out of context. I acknowledge it. The contexts have examples and other words on using this new freedom of any; hopefully, readers pick up the unsaid message: who has that freedom. It is correct to say: the accompanying examples and words make it sufficiently clear. The flip side is: look how many examples and words you have to set up to make it sufficiently clear. This thread began with the omission vs inclusion of syntax forall t or equivalent. It also, clearly, set the beginner classroom context. If someone replied, since it is a rank-1 language, the omission is syntactically simpler, the inclusion would be syntactically repetitive, I would agree. In fact I hold that opinion. But that has not been the reply. The reply has been, the omission is semantically simpler, and that's what I object to. All I see is evidence against it. Look how many examples and words you have to set up to teach it. Their length testifies the semantic complexity or complication. You have saved teaching syntax, but you haven't saved teaching semantics, semantics of something unrepresented by syntax. As for what mathematicians self-inflict on themselves, I should have, right at the beginning, just dismissed them and said: the context is beginner classroom, I don't care what happens between grad students and their thesis supervisors, it's their own business. If they just needed to wink-wink nudge-nudge and that finished transmitting a proof of P=NP, good for them. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Haskell is a declarative language? Let's see how easy it is to declare types of things.
On 13-04-04 01:07 AM, wren ng thornton wrote: When the quantifiers are implicit, we can rely on the unique human ability to DWIM. This is a tremendous advantage when first teaching people about mathematical concerns from a logical perspective. However, once people move beyond the basics of quantification (i.e., schemata, rank-1 polymorphism, etc), things get really hairy and this has lead to no end of quibbles in philosophy and semantics, where people seem perversely attached to ill-specified and outdated logics. On the other hand, with explicit quantification you can't rely on DWIM and must teach people all the gritty details up front--- since the application of those details is being made explicit. This is an extremely difficult task for people who are new to symbolic reasoning/manipulation in the first place. In my experience, it's better to get people fluently comfortable with symbolic manipulations before even mentioning quantifiers. I agree with most of it. I disagree with the first two sentences. With only one variable, therefore only one implicit quantifier, and even being told that this quantifier is placed outermost, it is already hairy enough. The unique human ability to DWIM (do what *I* mean) as opposed to DWYM (do what *you* mean) can be relied upon for confusion, frustration, students and teachers being at each others' throats, and needing to quibble in semantics which is WDYM (what do you mean) afterall. WDIM? (What do I mean?) In IRC channel #haskell, beginners write like the following and ask why it is a type error: f :: Bool - t f True = 'x' f False = 'y' You may think you know what's wrong, but you don't actually know until you know how to clarify to the beginners. Note: harping on the word any does not clarify, for the beginners exactly say this: Yeah, t can be *any* type, therefore *I* am making it Char. Isn't that what *any* means? The same reasoning happens in highschool and college math classes: Teacher: prove (t+2)^2 = t^2 + 4t + 4 Student: plug t=0. 2 = 2. works. Teacher: that's wrong, blah blah *any* blah blah Student: Yeah, t can be *any* number, therefore *I* am making it 0. Isn't that what *any* means? The folks in #haskell, after seeing it enough times, realize the real issue (not with the word any) and converge on this very efficient clarification: t can be chosen, but *I*, the vendor of f, the student, do not choose. *You*, the user of f, the teacher, choose. All beginners immediately understand. Later, they go on to understand higher-rank types with ease. (Identify positive and negative positions. Then, simply, user chooses what goes into the positive ones, and vendor chooses what goes into the negative ones.) The unique human ability of doing what *I*, the stduent, mean is the obstacle, not the pivot. At the basic level of single variable and rank 1, we already have to explain quantifier semantics, even if we don't display quantifier syntax. If we go implicit and do not spell it out upfront (symbolically or verbally), we force students to struggle at guessing, and then we are forced to spell it out anyway. That complexity does not decrease. And increased is the complexity of the aftermath flame war of why didn't you say it earlier? because it's obvious! no it's not! yes it is! is not! but all mathematicians find it obvious! well then I am not a mathematician and will never be! The two-person game semantics is in practice very efficient to convey; it is probably because most students have had extensive experience playing two-person games, coping with choices made by self and choices made by opponents, long before learning haskell or algebra. See also my http://www.vex.net/~trebla/weblog/any-all-some.html ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Haskell is a declarative language? Let's see how easy it is to declare types of things.
On 13-04-03 07:39 PM, Alexander Solla wrote: There's your problem. Mathematicians do this specifically because it is helpful. If anything, explicit quantifiers and their interpretations are more complicated. People seem to naturally get how scoping works in mathematics until they have to figure out free and bound variables. Quantifiers are complicated, but I don't see how explicit is more so than implicit. If anything, it should be the other way round, since correctly interpreting the implicit case incurs the extra step of first correctly guessing how to explicate. (If it doesn't have to be correct, I know how to do it 100 times simpler, to paraphrase Gerald Weinberg.) I have just seen recently prove or disprove: for all e0, there exists d0, if 0bad, then (a-b)/sqrt(b) e I grant you that clearly the implicit quantifiers for a and b are for all. The unclear part is where to put them. There are essentially 4 choices: for all a may be outside or inside there exists d, similarly for all b. Even when mathematicians care to explicate quantifiers, they pay lip service by the like of every x satisfies P(x,y) for some y leaving you to wonder between for all x, there exists y and there exists y, for all x. How does one resolve this kind of ambiguities? It seems to me the reader is expected to go through this algorithm: 1. for each candidate C of disambiguation: launch your theorem prover to find a proof or disproof of C remember whether it's a proof or disproof remember the complexity of the proof or disproof 2. guess whether the author intends the statement to be true or false 3. discard candidates whose truth values disagree with the author's intended truth value (e.g., if C is disproved, but the author intends a true statement, discard C) 4. among the remaining candidates, pick the one with the highest complexity of proof/disproof, for the author clearly intends the most interesting candidate 5. insist that this is the obvious choice. important! it is important to insist obvious so that people believe it and disbelieve what I'm saying In other words, to parse one statement, first prove or disprove four statements. The people you have observed must be the top 1% of math classes, those students who qualify for math grad school. I am sure they are born to excel at this guessing game. What I have observed are instead the rest of the students and how naturally miserably they get scoping wrong until they figure out free variables and bound variables. I am referring to this simple highschool scenerio (now also a simple college scenerio): Define f(x) = x^2 Define g(x) = 3*x Before I continue, recall that they have no clue about free vs bound variables. Without that clue, they already have to figure out scoping, and they naturally decide... x has global scope! (It does not help that teachers and books also send out that message, intended or unintended.) To compute f(0), set global x=0, f(x) = x^2 = 0^2. To compute f(1), set global x=1, f(x) = x^2 = 1^2. So far so good, and no problem on g(0) and g(1) either. Now ask this question: f(g(x)) = ? At this point, the rest of the students (i.e., not the top 1%) bifurcate: Group A say: g(x) varies, therefore don't set global x to anything. f(g(x)) = f(varying thing) = f(x) = x^2 Group B say: to compute f(g(x)), set global x=g(x)=3*x. so x=3*x. wtf? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] cabal install pandoc
On 13-04-01 06:26 AM, Roger Mason wrote: It turned out that there was a stale version of 'array' lurking in the ghc package db. In spite of reinstalling ghc it did not go away until I unregistered it. I think it was persisting because re-installing ghc simply unpacked over the old directory leaving that pre-existing file intact. See my http://www.vex.net/~trebla/haskell/sicp.xhtml for how does GHC know or not know what libs you have. In particular, it has very little to do with files, and clearing GHC is only half the story. And how to have the same kind of problems recur in the future. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] A Thought: Backus, FP, and Brute Force Learning
On 13-03-20 06:54 PM, OWP wrote: For me personally, one thing I enjoy about a typical procedural program is that it allows me to Brute Force Learn. [...] 1. I believe that you can also stare at functional programs and figure out as much as what you can with procedural programs. It only requires knowing the language and the libraries. And you can no longer argue that functional languages are more declarative or higher level than procedural languages. Once upon a time, it was true, with parametricity, algebraic data types, higher-order functions, and list comprehensions; now procedural languages have them too or competitive alternatives. 2. I doubt how much you can learn from staring, be it functional programs or procedural programs. I posit that at most you're just reading aloud in your native tongue how to execute the program. But then you're just competing with a computer at its job. You barely know what requirement the program satisfies, much less why the program satisfies that requirement. (With the exception that the program contains no iteration or recursion, or contains just boring iteration or recursion such as walking over an array.) I do not mean that you lack jargons like gradient and matrix, no. You can explain in your own words, if you know the right idea but just not the jargon. I am positing this: apart from telling me how to execute the program, you cannot explain the purpose of the program, not even in your own words, because you do not know. Here is an example I learned recently. It is ingenious. Let A, B be arrays of the same length N. Their elements are numbers. They use 0-based indexing. They are the input. int h=0, i=0, j=0; bool answer; while (hN iN jN) { int Aih = A[(i+h) % N], Bjh = B[(j+h) % N]; if (Aih == Bjh) { h = h + 1; } else if (Aih Bjh) { i = i + h + 1; h = 0; } else { /* Aih Bjh */ j = j + h + 1; h = 0; } } answer = (h = N); answer is the output. What does answer say about the input? The algorithm is no different in Haskell (it makes me use lowercase a, b, n): answer = go 0 0 0 go h i j = if hn in jn then case compare (a!((i+h) `mod` n)) (b!((j+h) `mod` n)) of EQ - go (h+1) i j GT - go 0 (i+h+1) j LT - go 0 i (j+h+1) else h=n 3. I completely refuse to believe that you literally do not know what you're doing before you start. If it were true, it must be like this: You throw dice 500 times to generate a 500-character file. If the compiler doesn't like it, you throw dice more times to decide what to mutate in that file. Eventually the compiler surrenders. Now, and only now, you stare at the file for a few minutes, and discover: it implements doubly linked list! It will be useful when you write your own web browser later, it can help provide the back button and the forward button... No, it has to be the other way round. You have to decide to attempt a web browser project or whatever in the first place. You are vague about details, what not to include, what to include, how to do them... but you know vaguely it's a web browser. After some time, you have to decide which part, however small, you start to code up. Maybe you decide to code up a doubly linked list first. Now you type up something. You type up something knowing that the short term goal is doubly linked list, and the long term goal is some kind of web browser or whatever project it is. This much you know. And while you type, every key you type you strive to get closer to a doubly linked list in good faith. Maybe sometimes you're creative, maybe sometimes you make mistakes, maybe you write clever code and I can't understand it, but it is not random typing, you know the purpose, you have reasons, you understand, and you don't just stare. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Compiled program using OpenGL fails to trigger GPU switch on Mac, but works in GHCi
On 13-03-18 09:19 AM, Jesper Särnesjö wrote: Interestingly, running the program in GHCi with the -fno-ghci-sandbox flag, causes it to misbehave in the same way as when compiled: Then perhaps to mimic default ghci in hope of getting good results: - compile with -threaded (more candidly, link with -threaded, it does not change code generation) - in the program, deliberately move the work to a forkIO-thread (I suggest forkIO instead of forkOS because I have just tried: $ ghci GHCi, version 7.4.2: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer-gmp ... linking ... done. Loading package base ... linking ... done. Prelude Control.Concurrent.isCurrentThreadBound False $ ghci -fno-ghci-sandbox GHCi, version 7.4.2: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer-gmp ... linking ... done. Loading package base ... linking ... done. Prelude Control.Concurrent.isCurrentThreadBound True Although, perhaps it doesn't matter.) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] To seq or not to seq, that is the question
On 13-03-08 11:53 PM, Edward Z. Yang wrote: Are these equivalent? If not, under what circumstances are they not equivalent? When should you use each? evaluate a return b a `seq` return b return (a `seq` b) Let a = div 0 0 (or whatever pure but problematic expression you like) b can be the same as a or something else. First assume IO. The 3rd one is distinguished by main = m return () where m is to be plugged in the 1st, 2nd, or 3rd. During IO execution, the 1st and 2nd throw an exception, the 3rd one does not. The 2nd is distinguished by main = evaluate m During IO execution, the 2nd throws an exception, the 1st and 3rd do not. (m `seq` return () should also do the same.) In practice, we seldom artificially evaluate or seq an IO action like that. And so, that distinction between the 1st and 2nd is seldom observed. But another difference matters more in practice: main = head [] `seq` (a `seq` return b) Two consecutive seqs is an instance where the impreciseness of imprecise exceptions kicks in. The compiler reserves the right to prefer either the empty-list exception or the divide-by-0 exception; perhaps even a difference choice at a different time. Whereas: main = evaluate (head []) (evaluate a return b) By virtue of IO's serializing (and lack of unsafeInterleaveIO hehe), the exception thrown must be the empty-list one. If the monad is not IO, then we cannot discuss evaluate. But we can be sure that different monads behave differently, and the difference involves =. Example: import Control.Monad.State.Strict a = div 0 0 b = whatever you like main = print (evalState ((a `seq` return b) return ()) ()) -- throws an exception import Control.Monad.State.Lazy a = div 0 0 b = whatever you like main = print (evalState ((a `seq` return b) return ()) ()) -- does not throw an exception (Did you know: Control.Monad.State refers to the Lazy one.) I leave the rest of the questions unanswered. Enough mind-bending for today! :) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] translating recursively defined sequence
On 13-03-05 12:19 AM, Christopher Howard wrote: Hi. My Haskell is (sadly) getting a bit rusty. I was wondering what would be the most straightforward and easily followed procedure for translating a recursively defined sequence into a Haskell function. For example, this one from a homework assignment. quote: a_1 = 10 a_(k+1) = (1/5) * (a_k)**2 (The underscore is meant to represent subscripting what follows it.) 1. decode subscripts back to arguments a 1 = 10 a (k+1) = (1/5) * (a k)**2 2. normalize LHS arguments sometimes, some arguments on the LHS (k+1 here) are not accepted by Haskell 2010; therefore, we need an equivalent definition with another argument form. a 1 = 10 a k = (1/5) * (a (k-1))**2 3. translate to Haskell (that's right, the above two steps are pure math, not Haskell) a 1 = 10 a k = (1/5) * (a (k-1))**2 The result may or may not be an efficient algorithm (which depends on how you use it). But it gives the correct answer. An efficient algorithm requires further study. Here is an example where step 3 makes change. b_0 = 0 b_(k+1) = sqrt k * b_k 1. decode subscripts back to arguments b 0 = 0 b (k+1) = sqrt k * b k 2. normalize LHS arguments b 0 = 0 b k = sqrt (k-1) * b (k-1) 3. translate to Haskell b 0 = 0 b k = sqrt (fromIntegral (k-1)) * b (k-1) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] cabal install ghc-mod installs 3 years old version
On 13-03-01 05:10 AM, Malcolm Wallace wrote: Doesn't Cabal tend to install library packages under the .cabal folder? So blowing it away gets rid of the problematic ones. (And everything else.) You need to perform scientific experiments to refute that claim, then see my http://www.vex.net/~trebla/haskell/sicp.xhtml#ident then perform more scientific experiments to try to refute my claim (and see that my claim passes your scrutiny). ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] package dependencies should distinguish between API and implementation?
On 13-02-25 06:50 AM, Johannes Waldmann wrote: or in general, A (and B.1) are baked into ghc, but there is some B.2/B.3 out there which U wants to use. Or is this what already happens? (ghc would notice that B.1.foo is different from B.2.foo. cabal-install would warn, but proceed? Then the effect of the proposal would just be to switch off these warnings in some cases?) GHC uses both versions of B as much as possible. If none of the following 3 problems occur, they co-exist peacefully. B defines a type T and/or a type class C. GHC considers B-1.T and B-2.T different and not interchangeable; similarly C. This is fine if one version is merely implementation-depended on. This becomes a visible type error if both versions are API-depended on and you try to mix them. You will see type errors like cannot match B-1.T with T or T is not an instance of B-1.C. (Because T refers to B-2's.) B-1 and B-2 both have instance Show (IO a) where Then you get some kind of overlapping instances error. B-1 and B-2 both contain C code, and both contain C extern functions of the same name (which is best practice) fps_count (real example from bytestring). Therefore, GHC cannot load both. (Neither can common linkers.) GHC panics in this case. Clearly, implementation-depend still suffers from 2 of these problems. As for cabal, it never considers multiple versions. Which I like. Just chop up the Gordian Knot. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] How to input Unicode string in Haskell program?
On 13-02-21 04:58 AM, Semyon Kholodnov wrote: — Windows console is locked to one specific local code page, and no codepage contains Latin-1, Cyrillic and Kanji symbols at the same time. Windows console is not locked to an anti-international code page; it is only defaulted to. Use CHCP 65001 to switch to the UTF-8 code page. Unfortunately, code page and encoding is only half of the battle; the other half is fonts. Most Windows fonts are incomplete; all Windows fixed-width fonts are incomplete. (Silver lining: Arial Unicode is sufficiently complete.) Therefore, you may be unable to display some characters, but they are the correct characters. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] question about: --hyperlink-source
On 13-02-21 05:18 AM, Doaitse Swierstra wrote: I ran into the problem that for the packages which I install using cabal install The generated html does not contain links to the sources. This issue was raised before in: http://stackoverflow.com/questions/1587635/haddock-for-cabal-installed-modules I have been looking into the documentation available, but could not find a way to set this e.g. as a default in some .haddock file. (I infer that you already have documentation: True in your $HOME/.cabal/config. Therefore, I will omit --enable-documentation.) Since cabal-install 0.14: cabal install --haddock-hyperlink-source Requires hscolour. Unfortunately, this flag has no corresponding line in $HOME/.cabal/config. There are several related --haddock-thisthat flags. See cabal install --help for more. (They are conveniently near the end.) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Next Meetup
On 13-02-04 02:56 AM, Alfredo Di Napoli wrote: Reverse engineering (aka Google searching) for Hacklab seems to reveal that the location is Edimburgh: Correct? :D There are many Hacklabs worldwide. But this one is Toronto, Canada. I know because Christopher runs the Toronto Haskell Meetup and I go. And I will be talking about Arrow in the February meeting. And last month I talked about Parsec, and I documented it at http://www.vex.net/~trebla/haskell/parsec-generally.xhtml Toronto is an international metropolis with three globally renowned universities, multiple major-player high-tech labs, a world-class orchestra and several world-class choirs, and fine cuisines from almost all cultures. Toronto is home of the Toronto Haskell Meetup. The Toronto Haskell Meetup welcomes attendees from all over the world. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] TIPS: To Insure Package Sanity
If you possess multiple instances (may be different versions, may be same version different builds) of a package, life can be hard and confusing. The problems are explained in my http://www.vex.net/~trebla/haskell/sicp.xhtml and faced by many people regularly. (Just read this mailing list.) cabal-install has a mechanism for not adding more instances. It is available since version 0.14.0, or earlier. It is just little known. It is also a bit manual. You have to give 1 instruction for each package. If you want to say it for n packages, you have to give n instructions. Also, if you give such an instruction for a package you do not already have, there is a problem: now you can't install that package. To insure package sanity, add these lines to your $HOME/.cabal/config, one line per package you want to protect. (Cannot merge into one line.) constraint: array installed constraint: bytestring installed constraint: Cabal installed constraint: containers installed ... Generally, do it for every package that comes with GHC, and every package that comes with the Haskell Platform if you have it, plus every package that you want stable. (You may omit packages that cannot possibly be on hackage, e.g., integer-gmp.) Remember to revise those lines whenever you switch GHC versions or Haskell Platform versions, since their package lists change. Alternatively, if you want even more manual work (in exchange for more fine-tuning perhaps?): every time you use cabal install: cabal install --constraint=array installed --constraint=bytestring installed --constraint=Cabal installed --constraint=containers installed ... ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] why no replace function in our regular expression libs ?
On 13-01-25 02:06 PM, Simon Michael wrote: People have put a lot of work into regular expression libraries on haskell. Yet it seems very few of them provide a replace/substitute function - just regex-compat and regepr as far as I know. Why is that ? [...] Secondly, as of today what do y'all do when you need that functionality I can only speak for myself, why I do not miss regex substitution too much. Sometimes, regex substitution is exactly the solution, and I use it. But the whole job is easily done in a shell script, or even in an editor. So I don't use regex substitution in Haskell in this case. Sometimes, the substitution job is: transform this article titlecodeMonad/code Tutorial/title content.../content /article to this !DOCTYPE html etc etc html headtitleMonad Tutorial/title/head body h1codeMonad/code Tutorial/h1 ... /body /html In this job, if a regex solution exists, I don't want to know. I just use HXT or XSLT. Sometimes, regex substitution plus Haskell is exactly the solution. Then I use regex-compat. It works. One solution is enough. I don't need a hundred choices for regex, or a hundred choices for Int. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] 9.3 - (2 * 4.5) = 0.3000000000000007
On 13-01-16 10:04 AM, Luis Cabellos wrote: You should read http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.22.6768 If you want to be efficient with floats. Language independent. And also http://floating-point-gui.de/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] How to disable document in .cabal file?
On 13-01-15 12:06 AM, Magicloud Magiclouds wrote: I have enabled document in .cabal/config, so I could get document every time I installed libraries or so. But when I compile my own applications, it also takes time on generating non-exist documents. How to disable it just for this project? If cabal install: add --disable-documentation. See also cabal install --help. If cabal configure and cabal build etc: nothing to do, just omit cabal haddock. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] How to disable document in .cabal file?
On 13-01-15 09:10 PM, Magicloud Magiclouds wrote: So the only way is to use param every time I build this certain project? Really hoping I could disable it in project.cabal The param is for cabal install only. So don't use cabal install. cabal configure # may be skipped usually cabal build cabal copy If your project is a library (as opposed to an executable): add cabal register Why this is not controlled in project.cabal: The author of the project should not control whether users build docs or not. P.S. Ivan, --enable-documentation and --disable-documentation are not even valid flags to cabal configure. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] help diagnosing space leak with IORef/STRef, just incrementing a million times.
On 13-01-07 12:12 AM, Thomas Hartman wrote: I have a space leak in a function that increments a number inside IORef or STRef (either lazy or strict). IORef and STRef operations do not automatically evaluate contents. writeIORef r (x + 1) simply stores a pointer to the expression (thunk) x + 1 into the mutable cell. readIORef just reports back a pointer. modifyIORef just calls readIORef and writeIORef. No evaluation throughout. modifyIORef incr where incr !x = x + 1 does not make a difference because it is just writeIORef r (incr x)), i.e., simply stores a pointer to the expression (thunk) incr x into the mutable cell. The whole process doesn't even care about how many bangs are in incr. (It is illuminating to consider how const True (incr x) does not evaluate x. A pointer to True and a pointer to incr x are passed to const, then const throws away the latter without even looking. See also const True undefined. One day, you will thank writeIORef r undefined; I certainly did.) Same for both Data.STRef.Strict and Data.STRef.Lazy. They do not mean what you think. Here is what they mean: Data.STRef.Strict means what Control.Monad.ST.Strict means Data.STRef.Lazy means what Control.Monad.ST.Lazy means Control.Monad.ST.Strict means that the following hangs: x = head (runST list) where list :: ST s [Bool] list = do {xs - list; return (True : xs)} Control.Monad.ST.Lazy means that the above terminates and gives the answer True. (Up to this point, same story for Control.Monad.State.Strict and Control.Monad.State.Lazy.) I still have not understood Control.Monad.ST.Lazy enough to articulate its full semantics, but I have some more examples to show what it does: http://hpaste.org/63925 By understanding what Lazy in Control.Monad.ST.Lazy means, you also see what Strict does *not* mean. In IO or Control.Monad.ST.Strict, use let y = x+1 in y `seq` write[IO/ST]Ref r y to expedite the evaluation of x+1. Using the same idea, you may write your own modify[IO/ST]RefNOW to evaluate while updating. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Makefile for a Haskell Project
On 13-01-02 01:01 AM, xuan bach wrote: = BASEDIR=/usr/local INCS= -I$(BASEDIR)/include/omega -I. LIBS= -L$(BASEDIR)/lib LIB= -lcode_gen -lomega -lm GHC=ghc # CFILES=$(CURDIR)/cfile HSFILES=$(CURDIR)/hsfile COBJFILES=$(CFILES)/termops.o $(CFILES)/termops2.o ALLCFILES=$(CFILES)/termops.c $(CFILES)/termops2.c # GHC_FLAGS= -O2 -fglasgow-exts -fallow-overlapping-instances _ffi_ex: $(COBJFILES) ghc $(GHC_FLAGS) -lstdc++ --make -main-is FfiEx -o ffi_ex FfiEx.hs $(HSFILES)/*.hs $(LIBS) $(LIB) $(COBJFILES) = = *fatal error: omega.h: No such file or directory An implicit rule is triggered to compile *.c to *.o. The rule goes like $(CC) -c $(CPPFLAGS) $(CFLAGS) Therefore, your -I$(BASEDIR)/include/omega -I. is ignored. To solve, put -I$(BASEDIR)/include/omega -I. in CFLAGS, or write your own rule for compiling *.c to *.o. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Cabal bug? repeat --reinstall
On 13-01-04 04:36 PM, Niklas Hambüchen wrote: I get the following: $ cabal install --only-dependencies --reinstall Resolving dependencies... All the requested packages are already installed: Use --reinstall if you want to reinstall anyway. Can somebody confirm that they see the same? I confirm. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Best approach to avoid dependency hells
On 12-12-08 07:39 AM, Ivan Perez wrote: When you install A, you may not know that you'll need to depend on a lower version of bytestring later on. Cabal will pick the highest version available (0.10 if present). If a program you install later on depends on A (needs bytestring-0.10) and ghc (needs bytestring-0.9), you'll have a conflict. You are saying, before cabal install A, you already have both bytestring 0.9.2 and 0.10 installed. This is new data not revealed last time. And it is important, this is exactly the cause, you have too many bytestring's installed. (You cannot be saying, you start without bytestring 0.10, and cabal install A brings in bytestring 0.10. You start with GHC, and since it depends on bytestring 0.9.2, you start with bytestring 0.9.2 too. And you don't already have another bytestring. Then cabal install A will stick with bytestring 0.9.2.) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Is it possible to have constant-space JSON decoding?
On 12-12-05 12:48 AM, Jason Dagit wrote: I thought it was possible to get around this with lazy patterns such Wadler's force function [1]? (untested code) force y = let Just x = y in Just x lazyDecode :: FromJSON a = ByteString - Maybe a lazyDecode = force . decode This says, the type is Maybe, but the value is always Just. If there will be a parse error, you will get an async imprecise exception, not Nothing, at the later time when you look closer. This respects the letter, but not the point, of the Maybe type. If you are to do this (I have no moral, I hold nothing against doing this, the async imprecise exception will give you enough grief), you may as well skip the Just wrapping and directly go ByteString - a. The point of the Maybe type is to communicate parse errors by a less async, less imprecise way. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Best approach to avoid dependency hells
On 12-12-05 01:52 PM, Ivan Perez wrote: I've spent the last couple of days fighting my way around a dependency hell with my own libraries and packages. If I install them package by package (by hand), I'm very likely to hit one of these conflicts that I'm talking about. A simple example of something that did happen: - Package A depends on bytestring, and is compatible with both 0.9.* and 0.10.* - Package B depends on ghc, which I installed using the package manager and which depends on bytestring 0.9.2 - Package B depends on package A. I do not understand the conflict. First you have GHC, and it comes with bytestring-0.9.2. Then one of two things happen, but I can't see a conflict either way: * You request A, but A should be fine with the existing bytestring-0.9.2. Then you request B, but B should be fine with the existing A you have, and indifferent about bytestring. OR * You request B. So cabal-install bring in A and then B. A should be fine with the existing bytestring-0.9.2, and then B should be fine with that A and indifferent about bytestring. If there is a conflict, it cannot be deduced from your data. I would like to the best approach to 1) avoid these situations and 2) fix them when they happen. To prevent or foresee problems, add --dry-run to your cabal install commands to see what packages are to be brought in, and check that list. If the list contains packages you already have, same version or different version, then it is a potential problem. It is fine with the pros of cabal matters, they know how to live with it, and they tell others it's fine. But it is not fine for non-pros, it causes confusion. I am fine with adding constraints such as bytestring == the version that comes with GHC to your cabal install commands and/or your ~/.cabal/config, contrary to what someone else says. The problem with setting it in ~/.cabal/config is that you will forget to change it when you change to another GHC version. But adding it manually as --constraint flags to cabal install may help with specific cases. How do you know whether it helps or hurts one case? Use --dry-run to find out. Play with adding and omitting constraints to see which list you like most. Your different projects can have different needs. This is why cabal-dev or other sandboxing methods are a good idea. This does not deny that some packages benefit all of your projects and can be installed outside sandboxes. You have to choose carefully. To clean up a mess or bad state, see my http://www.vex.net/~trebla/haskell/sicp.xhtml#remove Actually, see the whole thing. It does not suffice to erase ~/.cabal (and mostly unnecessary). It does not suffice to erase GHC and then install the same GHC version again. You are still missing an important piece of metadata. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] How to incrementally update list
On 12-11-30 01:16 PM, Mark Thom wrote: Is there a paper or other single resource that will help me thoroughly understand non-strictness in Haskell? See my http://www.vex.net/~trebla/haskell/lazy.xhtml ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] cabal configure cabal build cabal install
On 12-11-27 04:40 AM, kudah wrote: On Tue, 27 Nov 2012 02:20:35 -0500 Albert Y. C. Lai tre...@vex.net wrote: When cabal build succeeds, it always says: (older) registering name-version (newer) In-place registering name-version That's what it says. But use ghc-pkg and other tests to verify that no registration whatsoever has happened. It doesn't register in user package-db, it registers in it's own dist/package.conf.inplace. If it didn't you wouldn't be able to build an executable and a library in one package such that executable depends on the library. That's fair. But it also means cabal configure cabal build is not equivalent to cabal configure cabal build cabal register --inplace which was the context when you said (newer) cabal build registers inplace automatically. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] cabal configure cabal build cabal install
On 12-11-26 04:34 AM, Kim-Ee Yeoh wrote: Nice tip, Albert! Good to know! One question I have is, is (runghc Setup.lhs) equivalent to (cabal) in runghc Setup.lhs $ [configure, build, install] ? Setup defaults to --global --prefix=/usr/local cabal defaults to --user --prefix=$HOME/.cabal This confuses a lot of people. FAQ #1: Why does Setup copy abort and say no permission? Answer: because you haven't escalated privilege for writing to /usr/local FAQ #2: Why does sudo cabal install register nothing in both the global database and my database? Answer: because --user means not global, and sudo means the user is root, not you. Look under /root. Lastly, there is no Setup install. Use copy and register. On Mon, Nov 26, 2012 at 8:08 AM, Brent Yorgey byor...@seas.upenn.edu mailto:byor...@seas.upenn.edu wrote: [cabal haddock, if you want] cabal copy cabal register Even this does not do the same thing as 'cabal install', because it does not download and install any dependencies (whereas 'cabal install' does). Brent, that's useful to know too, thanks! Fwiw, I think Albert had the backdrop of classic GNU autoconf in mind, predating all that newfangled stuff of downloading (!) dependencies (!!). This is ignorant of a common workflow. cabal configure is used by a lot of programmers. Today. Why? Because they use it on their own projects. They use cabal-install as a builder, not exactly an installer. In fact, some of them do: cabal configure cabal build cabal register --inplace This has no cabal install correspondence. So you ask, but surely their own projects require some packages from hackage? Yes, surely. But those packages have already been installed in the past, once and for all. That is, when the project started, they already did cabal install yesod. This is not so old-school, is it? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] cabal configure cabal build cabal install
On 12-11-27 01:02 AM, kudah wrote: On Mon, 26 Nov 2012 18:21:33 -0500 Albert Y. C. Lai tre...@vex.net wrote: Lastly, there is no Setup install. Use copy and register. $ runghc Setup.hs --help [...] install Copy the files into the install locations. Run register. copy Copy the files into the install locations. I stand corrected, thank you. But then to complete answering a previous question, Setup install does not configure, does not build, and is far from cabal install. (newer) cabal build registers inplace automatically. I see where you heard this, but it is a misrepresentation from cabal, and older cabal has always told a similar misrepresentation. When cabal build succeeds, it always says: (older) registering name-version (newer) In-place registering name-version That's what it says. But use ghc-pkg and other tests to verify that no registration whatsoever has happened. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] cabal configure cabal build cabal install
Among many programmers, and/or users who manually unpack source tarball before installing, this idiom is very common: cabal configure cabal build cabal install This idiom is an urban legend, i.e., a popular error. cabal install re-does the configure and the build steps, among other things. That it has not caused trouble for you so far is only because: 1. configure has been idempotent, so far 2. the 2nd build has not caused duplicate work because ghc knows when not to re-compile One day, you will run into a surprise, because you will add some flags to configure, and then... cabal configure --prefix=/nondefault --enable-shared cabal build cabal install Whee! Your laborously entered flags are lost on deaf ears. You get the default prefix, and you get the default disable-shared. Why? Because cabal install re-does the configure step, but this time, since you give no flags to install, you give no flags to the 2nd configure either. If you begin with cabal configure, the correct idiom is: cabal configure [flags] cabal build [cabal haddock, if you want] cabal copy cabal register If you find it too long, why not just begin with: cabal install [flags] [--enable-documentation, if you want] ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Cabal failures...
On 12-11-20 08:48 AM, Gregory Guthrie wrote: It was also interesting to note a comment that most developers don't have access to a Windows machine for testing. With Windows at 90% of the computing market (Linux = 1.6%), this seems like a problem which might limit growth of Haskell usage. Just an observation. :-) There is a paradox in that sentence. The first sentence says, most developers don't have access to Windows machines for testing. But they have access to Linux machines. Then Windows machines must be a scarcity compared to Linux machines, no? So scarce, you even have difficulty borrowing or renting. Then the next sentence says, the scarcity is the other way round, Linux machines are scarce, Windows machines are abundant. OK, so why is it so hard to access something abundant, and so easy to access something scarce? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Compilers: Why do we need a core language?
On 12-11-20 06:54 AM, c...@lavabit.com wrote: I know nothing about compilers and interpreters. I checked several books, but none of them explained why we have to translate a high-level language into a small (core) language. Is it impossible (very hard) to directly translate high-level language into machine code? Let the overall distance be fixed. More steps over that same distance means each step is smaller, easier to design, easier to understand, easier to correct if there are mistakes. Forget code generation. Just parse and validate and then discard. Already there are like 4 steps. Translate character sequence into token sequence. Translate token sequence into grammar tree, while checking grammar. Translate grammar tree into declaration groups, identifier lookup tables, etc., while checking whether every used identifier is declared or imported. Translate those groups and tables into type-annotated groups and tables, while checking types. Whew! After 4 steps of translating this to that, we still haven't reached the core language! Why? Because... have you ever tried to write a type-checker for character sequence? I'm sure some mad genius can do it, but I don't want to be that mad genius. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Hackage dependencies problem.
On 12-11-19 09:39 PM, Magicloud Magiclouds wrote: And, the key point is that using upgrade-dependencies with cabal-install. I am using git (current) version of cabal-install. Without that argument, things could be fine. With it, it must fail. Therefore, don't use upgrade-dependencies. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Cabal failures...
On 12-11-20 05:37 PM, Gregory Guthrie wrote: No; the first sentence says that someone else had reported that testing on Windows was hard to do because of (a perceived) lack of access to Windows by Haskell developers... The implication is that Haskell developers (only/mainly) use *nix. I commented that if true this lack of Windows testing could limit the availability of Haskell to the largest market share of users. Clearly, since 90% of computers have Windows, it should be trivial to find one to test on, if a programmer wants to. Surely every programmer is surrounded by Windows-using family and friends? (Perhaps to the programmer's dismay, too, because the perpetual I've got a virus again, can you help? is so annoying?) We are not talking about BeOS. Therefore, if programmers do not test on Windows, it is because they do not want to. And why would they want to? Take webapp programmers for example. 99.999...% [1] of computers have sufficiently new web browsers. This market share is even higher than Windows. At the server side, the programmers have freedom in choosing the OS, and apparently, they choose anything but Windows, and this has never limited them in accessing 99.999...% of computer users. And this, 99.999...% web browser market share, is exactly driving Haskell growth. Not the petty 90% Windows slice. [1] http://en.wikipedia.org/wiki/0.999... ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Cabal failures...
On 12-11-20 08:20 PM, Johan Tibell wrote: This logic is flawed. More than 90% of computers having Windows doesn't imply that 90% of all computers in a given household runs Windows. What's the probability that your household has a Windows computer if you're a programmer that don't live with your parents? What if that programmer is an open source contributor. Surely not 90%. This counter-argument is flawed. Why limit oneself to one's own household? (Garage? Basement?) Get out more! Visit a friend. Talk to an internet cafe owner for a special deal to run one's own programs. Rent virtual machine time in the cloud. There are many creative, flexible, low-cost possibilities. If one wants to. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Hackage dependencies problem.
On 12-11-19 04:45 AM, Ivan Lazar Miljenovic wrote: On 19 November 2012 18:21, Magicloud Magiclouds magicloud.magiclo...@gmail.com wrote: command line: cannot satisfy -package Cabal-1.16.0: Cabal-1.16.0-dd0ce1db6fea670a788547ee85411486 is unusable due to missing or recursive dependencies: directory-1.2.0.0-8edf300597b0da609c8eccc9aa6d0cc3 process-1.1.0.2-03ae5757aa509ffbe497f42660cba52c unix-2.6.0.0-4bc27fc415f60036a88211de7cde3e9a (use -v for more information) What should I do? Why user space directory and process would interrupt Cabal in global space? It shouldn't. Can you please give an example of a package that gives you an error like this? Also, what does ghc-pkg check say? The only thing I can think of is that you're trying to upgrade a package like array, containers, etc. It does. It has always been. When unioning user and global, user takes precedence: user directory-1.2.0.0 shadows global directory-1.2.0.0 (GHC User's Guide 4.9.4). But look closer: user directory-1.2.0.0-feedbabe... shadows global directory-1.2.0.0-deadbeef... Therefore, if global Cabal-1.16.0 was built against directory-1.2.0.0-deadbeef..., it's a missing dependency for you. See my http://www.vex.net/~trebla/haskell/sicp.xhtml#pigeon Fortunately, shadowing is a sessional property, not a data-loss property. One can say, it's a data-surplus property. To regain working sessions, cut surplus data, add -no-user-package-db to all your ghc and ghci commands. ghc-pkg check does not report shadowing. Go straight for ghc -v. This is what you get for --reinstall. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Cabal failures...
On 12-11-19 04:25 PM, Gregory Guthrie wrote: I am not exert in the area, but I wonder how /why/ this is different than other package managers, like apt in Linux, I have never had any problems with it, and I would think that their dependencies are of at least similar complexities. I feel very strongly about the dissonance in comparing problems without comparing costs. Debian has a horde of volunteers for just the menial and manual work of perpetually finding one coherent set of versions so end users don't have to. And in practice, There is never one coherent set of versions. There is only a not-too-incoherent set of versions, and the volunteers first have to decide on it, and then manually pick patches from other versions (backporting patches, cherry-picking patches) to turn the not-too-incoherent set into a coherent set that does not exist in any pristine version. On top of that, Mark Shuttleworth actually pays money for Ubuntu to start from Debian and further test the set, pick some more patches, unpick some other patches... How many hours and/or dollars are you willing to pay for the menial, manual, perpetual chore of identifying coherent sets of versions so other people don't have to? And if a coherent set does not exist, how many are you willing to pay for backporting patches? At least I paid my 3 hours to explain some cabal stuff at http://www.vex.net/~trebla/haskell/sicp.xhtml Even the Haskell Platform, one very small set, costs volunteer hours. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] need help with understanding expression
On 12-11-17 02:19 AM, damodar kulkarni wrote: Let's see tthis: Prelude :t 3 a 3 a :: (Num ([Char] - t)) = t No complaint from GHC; but now see this: Prelude :t a 3 interactive:1:0: Couldn't match expected type `t1 - t' against inferred type `[Char]' In the expression: a 3 Why does it not fail for (:t 3 a) but does fail for (:t a 3)? 3 is polymorphic, a is monomorphic (exactly [Char]). To make a polymorphic, turn on OverloadedStrings: :set -XOverloadedStrings :type a a :: Data.String.IsString a = a :type a 3 a 3 :: (Num a, Data.String.IsString (a - t)) = t Success! This is clearly depravity. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] need help with understanding expression
On 12-11-16 02:10 AM, Daryoush Mehrtash wrote: I am having hard time understanding how removing the outer parenthesis in (max.(+1)) 2 2 to max.(+1) 2 2 changes the meaning of expression. I recommend http://bm380.user.srcf.net/prettyparsetree.cgi for discovering the correct parse. Specifically, max.(+1) 2 2 = { use uniform spacing to un-presume } max . (+1) 2 2 = { . is lower than application } max . ((+1) 2 2) etc. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Profiling a project with cabal and cabal-dev
On 12-11-07 12:00 AM, Mike Craig wrote: Got it. Thanks for the info, Erik. I've updated my cabal config and reinstalled some of the global packages, and the world seems much less bleak! :) The good news is that whatever comes with GHC comes with profiling, you do not need to reinstall them. The bad news is that you have reinstalled them, and that is a latent disaster. http://www.vex.net/~trebla/haskell/sicp.xhtml#pigeon ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Where is the documentation on exception types kept?
On 12-11-07 03:36 PM, timothyho...@seznam.cz wrote: I am trying to catch an thread blocked on MVar indefinitely exception. Of course I can use ::SomeException as explained in http://hackage.haskell.org/packages/archive/base/latest/doc/html/Control-Exception.html#g:3 but there is no explanation as to how to find the more case specific exceptions. In general, because Exception instances are Typeable instances, you can get a name, and then you can use that for searches. import Control.Exception import Data.Typeable main = do aida - try (readFile no) case aida of Left (SomeException e) - print (typeOf e) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] referential transparency? (for fixity of local operators)
On 12-10-06 05:18 AM, Johannes Waldmann wrote: wren ng thornton wren at freegeek.org writes: As for whether the default should be infix 9 instead of infixl 9 ... that was exactly the point of my message. - J. Perhaps, half of the people want infixl, another half of the people want infixr, and so at the end the middle ground of neither l nor r is taken. Perhaps, political decision is about saying no to both the left and the right? :) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Monads
On 12-10-01 05:34 AM, Jon Fairbairn wrote: Albert Y. C. Lai tre...@vex.net writes: On 12-09-30 06:33 PM, Jake McArthur wrote: 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. I don't understand that definition. Or maybe I do subconsciously. I have s :: State Int () s = do { x - get; put (x+1) } Is there an effect triggered by merely evaluating s? I have m :: IO () m = if True then putStrLn x else putChar 'y' Is there an effect triggered by merely evaluating m? What counts as evaluate? Evaluation! Consider m `seq` 42. m is evaluated, but to no effect. Sure thing. So s has no side effect, and m has no side effect. Since they have no side effect, there is no effect to be decoupled from evaluation. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Monads
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? 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
Re: [Haskell-cafe] Monads
On 12-09-30 06:33 PM, Jake McArthur wrote: 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. I don't understand that definition. Or maybe I do subconsciously. I have s :: State Int () s = do { x - get; put (x+1) } Is there an effect triggered by merely evaluating s? I have m :: IO () m = if True then putStrLn x else putChar 'y' Is there an effect triggered by merely evaluating m? What counts as evaluate? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Tutorial: Haskell for the Evil Genius
On 12-09-14 05:18 PM, Andrew Pennebaker wrote: One thing I want to double check is that Haskell does, in fact, automatically memoize all pure function calls. Is this true? A simple back-of-envelope calculation that immediately raises doubts: 2 seconds on a 2 GHz computer is 4x10^9 clock cycles, or something between 10^9 to 4x10^9 steps. This sounds more like 2^30 recursive calls to fib, not 30. Even with interpreter inefficiency. A simple experiment to nail the coffin: Experiment #1: fib :: Int - Int fib 0 = 0 fib 1 = 1 fib n = fib (n - 1) + fib (n - 2) main :: IO () main = mapM_ (print . fib) (replicate 10 30) Null hypothesis: fibs are memoized, therefore the first printing takes 2 seconds, the remaining 9 printings are free. Alternative hypothesis: fibs are not memoized, therefore every printing takes 2 seconds. Observation: __ Which hypothesis to reject: ___ A few advanced experiments to mess with your mind: Experiment #2: fib :: Int - Int fib 0 = 0 fib 1 = 1 fib n = fib (n - 1) + fib (n - 2) main :: IO () main = let y = fib 30 in mapM_ print (replicate 10 y) Question: Is anything memoized here? Which thing? Experiment #3: fib :: Int - Int fib 0 = 0 fib 1 = 1 fib n = fib (n - 1) + fib (n - 2) main :: IO () main = mapM_ print (replicate 10 (fib 30)) Question: is this like #1? or is this like #2? Experiment #4: fib :: Int - Int fib n = mem !! n mem :: [Int] mem = map aux [0..] -- remark: even [Int] is not a very efficient data structure for this aux 0 = 0 aux 1 = 1 aux n = mem!!(n-1) + mem!!(n-2) main :: IO () main = mapM_ (print . fib) (replicate 10 30) Question: How fast is this compared to #1? Why? Final remark: Evil geniuses should use the scientific method, not the opinionative method. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Data.Text UTF-8 question
On 12-08-31 01:59 AM, jeff p wrote: I have a sample file (attached) which I cannot read into Text: Prelude Control.Applicative Data.Text.IO.readFile foo *** Exception: utf8.txt: hGetContents: invalid argument (invalid byte sequence) Prelude Control.Applicative Data.Text.Encoding.decodeUtf8 $ Data.ByteString.Char8.readFile foo *** Exception: Cannot decode byte '\x6e': Data.Text.Encoding.decodeUtf8: Invalid UTF-8 stream At offsets from 0x55 to 0x5A: 0x4D 0x61 0x72 0x74 0xED 0x6E This is clearly not UTF-8. This would be, in ISO-8859-1, Martín. Martín in UTF-8 is 0x4D 0x61 0x72 0x74 0xC3 0xAD 0x6E, and it takes one more byte. And like Gregory Collins says, different UTF-8 decoders may handle errors differently. Some abort. Some others fill in a special character. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Data structure containing elements which are instances of the same type class
On 12-08-15 03:20 AM, wren ng thornton wrote: (forall a. P(a)) - Q = exists a. (P(a) - Q) For example: A. (forall p. p drinks) - (everyone drinks) B. exists p. ((p drinks) - (everyone drinks)) In a recent poll, 100% of respondents think A true, 90% of them think B paradoxical, and 40% of them have not heard of the Smullyan drinking paradox. Hehe! http://www.vex.net/~trebla/weblog/any-all-some.html ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] but module Data.Array.Rep.Algorithms.Ramdomish is in package repa-algorithms
On 12-08-12 02:18 PM, KC wrote: I use cabal install repa but then WinGHCi says module Data.Array.Rep.Algorithms.Ramdomish not found. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] parsec: parserFail multiple error messages
On 12-08-08 03:24 PM, silly wrote: The problem is that when I try this parse integer 7 I get the following error: Left (line 1, column 6): unexpected end of input expecting digit integer overflow ie there are three error messages but I only want the last one. Is there something I can do about this? import Text.Parsec import Text.Parsec.String integer :: Parser Int integer = try integ3r ? number at most 65535 integ3r = do s - many1 digit let n = read s if n 65535 then unexpected number overflow else return n main = do parseTest integer a7 parseTest integer 7 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] why does a foldr not have a space leak effect?
On 12-07-25 09:06 AM, Mathieu Boespflug wrote: Albert Y. C. Lai tre...@vex.net writes: foldr (+) and foldl (+) for Int have the same asymptotic costs, both time and space. See my http://www.vex.net/~trebla/haskell/lazy.xhtml Therefore, I do not understand why they are labeled opposite space-leakness. That may be true, but if the function argument supplied to foldr is lazy in its second argument, then the story can be quite different. In my http://www.vex.net/~trebla/haskell/lazy.xhtml which I mentioned yesterday, I have an example for that, too. foldr (||). ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] why does a foldr not have a space leak effect?
On 12-07-23 10:52 PM, Qi Qi wrote: Foldl has the space leak effect, and that's why foldl' has been recommended. foldr (+) and foldl (+) for Int have the same asymptotic costs, both time and space. See my http://www.vex.net/~trebla/haskell/lazy.xhtml Therefore, I do not understand why they are labeled opposite space-leakness. Perhaps it is an intuition leak, not a space leak. That is, one of them fulfills your intuition, the other fails your intuition. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Fwd: hackage compile failure with QuickCheck 2.5
On 12-07-17 01:43 PM, Levent Erkok wrote: It still feels like this'll start biting more folks down the road. I've created the following cabal ticket so it can be tracked: https://github.com/haskell/cabal/issues/978 However, my understanding of the problem is rather incomplete; please feel free to add comments to the ticket. I apologize for not being interested in a github account (at least for now), and therefore not posting there. 1. I am not convinced that it is a cabal issue. sbv-2.2 demands containers = 0.5 --- which most GHC versions don't have --- and template-haskell depends on containers. This requires replacing template-haskell or adding a new instance of template-haskell. As long as you or an algorithm obey dependencies, there is no way around it. In fact, cabal-install since 0.14 already adds a hesitation. It aborts and warns likely to be broken by the reinstalls. If you use --force-reinstalls, it is your poison. Why is it a cabal bug to obey human-decreed dependencies and instructions? 2. It is a very bad idea to keep around multiple versions of containers, multiple versions of template-haskell... generally multiple versions and instances of what comes with GHC. The GHC API (package name ghc) depends on them, too. Are we going to rebuild GHC multiple times too? See my http://www.vex.net/~trebla/haskell/sicp.xhtml#pigeon In fact, see the whole article. A rumour says that my article caused adding the hesitation to cabal-install 0.14. My article was written before. 3. I see that now we have sbv-2.3, and its dependency reads: containers == 0.4.2.1 So now people using GHC 7.0.x, 6.12.x... have to add multiple versions of containers, rebuild template-haskell, and go through the same ordeal again. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Getting a segmentation fault when starting/stopping the RTS, from C, several times.
On 12-07-10 11:35 PM, Brandon Allbery wrote: Quoth the Fine Manual (8.2.1.1. Using your own main() http://www.haskell.org/ghc/docs/latest/html/users_guide/ffi-ghc.html#using-own-main): There can be multiple calls to |hs_init()|, but each one should be matched by one (and only one) call to |hs_exit()|^[14 http://www.haskell.org/ghc/docs/latest/html/users_guide/ffi-ghc.html#ftn.id740774] . So this should theoretically work. Except that [14] says: the outermost hs_exit() de-initialises, and afterwards, cannot reliably re-initialise in current implementations. So the currently working use-case is just: Prog ::= nop | hs_init(); Prog; hs_exit() ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Getting a segmentation fault when starting/stopping the RTS, from C, several times.
On 12-07-15 08:37 PM, Felipe Almeida Lessa wrote: Would that be: Prog ::= nop | hs_init(); Prog'; hs_exit(); Prog' ::= nop | hs_init(); Prog'; hs_exit(); | Prog' Prog' Yeah, I keep forgetting that. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Bad interface problem.
On 12-07-11 09:28 PM, Magicloud Magiclouds wrote: And Albert, I did not directly install QuickCheck. It was required by yesod. I can't reproduce that dependency either. Output of cabal install --dry-run yesod does not contain QuickCheck or template-haskell. I do not have QuickCheck installed. Resolving dependencies... In order, the following would be installed (use -v for more details): SHA-1.5.1 ansi-terminal-0.5.5 attoparsec-0.10.2.0 base-unicode-symbols-0.2.2.4 base64-bytestring-0.1.2.0 blaze-builder-0.3.1.0 blaze-markup-0.5.1.0 blaze-html-0.5.0.0 byteorder-1.0.3 cereal-0.3.5.2 cpu-0.1.1 css-text-0.1.1 dlist-0.5 data-default-0.4.0 cookie-0.4.0 entropy-0.2.1 enumerator-0.4.19 attoparsec-enumerator-0.3 asn1-data-0.6.1.3 failure-0.2.0.1 fast-logger-0.0.2 hashable-1.1.2.3 case-insensitive-0.4.0.1 http-types-0.6.11 largeword-1.0.2 mime-mail-0.4.1.1 path-pieces-0.1.1 pem-0.1.1 primitive-0.4.1 ranges-0.2.4 email-validate-0.2.8 regex-base-0.93.2 regex-posix-0.95.2 regex-compat-0.95.1 safe-0.3.3 semigroups-0.8.3.2 shakespeare-1.0.0.2 hamlet-1.0.1.4 shakespeare-css-1.0.1.2 shakespeare-i18n-1.0.0.2 shakespeare-js-1.0.0.3 shakespeare-text-1.0.0.2 simple-sendfile-0.2.4 socks-0.4.1 stm-2.4 stringsearch-0.3.6.3 syb-0.3.7 system-filepath-0.4.6 tagged-0.4.2.1 crypto-api-0.10.2 crypto-pubkey-types-0.1.1 certificate-1.2.3 cryptohash-0.7.5 pureMD5-2.1.0.3 pwstore-fast-2.2 skein-0.1.0.7 tagsoup-0.12.6 transformers-base-0.4.1 monad-control-0.3.1.4 lifted-base-0.1.1.1 resourcet-0.3.3.1 unix-compat-0.3.0.1 unordered-containers-0.2.1.0 utf8-string-0.3.7 vault-0.2.0.0 vector-0.9.1 aeson-0.6.0.2 cryptocipher-0.3.5 cprng-aes-0.2.3 clientsession-0.7.5 resource-pool-0.2.1.0 pool-conduit-0.1.0.2 tls-0.9.6 tls-extra-0.4.6 void-0.5.6 conduit-0.4.2 attoparsec-conduit-0.4.0.1 blaze-builder-conduit-0.4.0.2 network-conduit-0.4.0.1 persistent-0.9.0.4 persistent-template-0.9.0.2 wai-1.2.0.3 wai-logger-0.1.4 warp-1.2.2 xml-types-0.3.2 xml-conduit-0.7.0.3 xss-sanitize-0.3.2 yesod-routes-1.0.1.2 zlib-bindings-0.1.0.1 zlib-conduit-0.4.0.2 http-conduit-1.4.1.10 authenticate-1.2.1.1 wai-extra-1.2.0.5 yesod-core-1.0.1.3 yesod-json-1.0.1.0 yesod-persistent-1.0.0.1 yesod-form-1.0.0.4 yesod-auth-1.0.2.1 yesod-1.0.1.6 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Bad interface problem.
On 12-07-11 05:28 AM, Magicloud Magiclouds wrote: I am using ghc 7.4.2 which includes template-haskell-2.7.0.0. When I installed QuickCheck-2.5, it requires template-haskell-2.6.0.0. Even I removed all user space packages, the error was still. Cannot reproduce. I start with ubuntu 11.04 x86 32-bit, fresh ghc 7.4.2 (linux x86 32-bit), fresh cabal-install 0.14: $ cabal install --dry-run QuickCheck Resolving dependencies... In order, the following would be installed (use -v for more details): QuickCheck-2.5 No pulling in template-haskell-2.6.0.0. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Bad interface problem.
On 12-07-03 04:19 AM, Magicloud Magiclouds wrote: $ cabal --upgrade-dependencies --enable-documentation --force-reinstalls --solver=topdown QuickCheck-2.5 Test/QuickCheck/All.hs:15:1: Bad interface file: /home/magicloud/.cabal/lib/template-haskell-2.6.0.0/ghc-7.4.2/Language/Haskell/TH.hi Something is amiss; requested module template-haskell-2.6.0.0:Language.Haskell.TH differs from name found in the interface file template-haskell:Language.Haskell.TH I think things are so messed up that it is time to clean out everything. See my http://www.vex.net/~trebla/haskell/sicp.xhtml#remove In fact, time to read the whole article and avoid unsafe re-installs and upgrades. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Cabal problem re. haskelldb-hdbc-mysql
On 12-07-04 10:58 AM, Yves Parès wrote: the package http://hackage.haskell.org/package/haskelldb-hdbc-mysql/ the use of HDBC 2.3.0 I'm using cabal-install 0.14, and with a fresh install (no packages already installed), cabal-install tries to install HDBC-2.1.1 instead of, say, HDBC-2.2.7.0. HDBC 2.2.* all want time=1.1.2.4 =1.2.0.3, GHC 7.4.1 comes with time-1.4, therefore HDBC 2.2.* are all rejected. 2.1.1 is the topmost one without the upper bound. This analysis is made possible by cabal install --dry-run -v3 haskelldb-hdbc-mysql of cabal-install 0.14. Now with actually relevant output! (As part of the new modular solver, I guess.) P.S. haskelldb-hdbc wants mtl-2.0.*, but you already have mtl-2.1 because you have cabal-install 0.14. mtl-2.0.1.0 in turn wants transformers-0.2.*, but you already have transformers-0.3.0.0 again because you have cabal-install 0.14. Expect mysterious problems in the future. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] cabal doens't forget old dependencies
On 12-06-27 11:29 AM, Sjoerd Visscher wrote: I tried to install reactive-banana. This failed due to a dependency conflict, and then I noticed there was a newer version of reactive-banana. So I did cabal update, and tried to install again. But whatever I do, cabal keeps trying to install fclabels, but fclabels is no longer a dependency of reactive-banana-0.6.0.0! How can I let cabal forget this dependency? In http://hackage.haskell.org/packages/archive/reactive-banana/0.6.0.0/reactive-banana.cabal : if flag(UseExtensions) extensions: TypeFamilies, GADTs, MultiParamTypeClasses, BangPatterns, TupleSections, EmptyDataDecls build-depends: QuickCheck = 1.2 2.5, fclabels == 1.1.*, unordered-containers = 0.2.1.0 0.3, hashable == 1.1.* CPP-options:-DUseExtensions Recall that the semantics of if flag is like Prolog not Pascal: if the packages under build-depends could be installed, then UseExtensions is set to true. Unless you manually override. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANNOUNCE : Leksah 0.12.1.2 (fixes some metadata issues)
On 12-06-20 07:59 PM, Hilco Wijbenga wrote: hilco@centaur ~ ~$ rm -rf .cabal/ I am not sure why you start with this. If you do this for a clean start, see my http://www.vex.net/~trebla/haskell/sicp.xhtml#remove for why it is not a clean start. If you do this for some other purpose, nevermind. ... lots of output ... I think that is the informative part. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Issues with installing packages
On 12-05-05 04:19 PM, Graham Berks wrote: New to haskell and having issues resolving packages, have the following output below and can't seem to resolve it. Text seems to have diff hash dependancies when I try and instal a diff version of 0.11.2.0 etc Any ideas on what todo ?? Thanks $ ghc-pkg check There are problems in package scion-browser-0.2.8: dependency text-0.11.2.0-2b6cea8526e93af24bb0154400fd64a6 doesn't exist [etc] See my http://www.vex.net/~trebla/haskell/sicp.xhtml for the significance of the hash value and more ways to break things. My article mostly doesn't say how to fix things (partly because there are many factors: problem details, self-inflicted constraints aka personal preferences). But knowing how GHC packages work may help you devise your tailored solution. Well, I suppose there is always the sledgehammer of erasing everything: erase $HOME/.ghc, erase GHC. (Again, see my article for why erasing $HOME/.cabal solves absolutely no problem.) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Learn you
On 12-05-06 01:58 AM, Tom Murphy wrote: FWIW, I loved the tone of those books, and I think it helps many people learn the material. It's nice to have a little reminder every once in a while: good job! Now go take a break; make some cookies - here's a recipe Learn_You_a_Baking_for_Great . Learn_You_a Haskell_for_Great $ Good ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] MonadError vs Control.Exception
On 12-05-04 07:03 PM, Станислав Черничкин wrote: Hi, guys, I'm interested in best practices in using of each approach. Personally I like MonadError because it is more explicit and Control.Exception-s becomes really ugly in complex scenarios. [...] User has to deal with both, but have no evidence on none of them from type signatures or documentation. My opinion is largely recorded in my sarcastic http://www.vex.net/~trebla/haskell/exception.xhtml Be sure to click the click me if you can button and read again. My sarcastic article focuses on control flow and doesn't comment on types. I agree about seeing exception possibilities in types. But that was done 8 years ago: http://www.haskell.org/pipermail/haskell/2004-June/014271.html So, I hate exceptions, I blame it, I think exceptions is junk came from OO-world and horrible languages like C# or even more horrible like Java, and it should be wiped out from Haskell with fire. But it is only my humble opinion. While you are entitled to have opinions, and I am fine with those parts about I hate exceptions, exceptions is junk, it is irresponsible and unreasonable to use that right on objective, verifiable, historical facts. Yes, I really hate it when people do that. I think Oleg is from Vulcus without even asking anyone. I think everyone uses Java without hard data. Programmers' habit of subsituting thinking for empirical facts is one of many reasons why the software profession has not yet earned the engineering status. The only two responsible, reasonable positions are: 1. find the answer or 2. hold the position that you just don't know Exceptions appeared as early as in ML and Ada in the 1980s, before many people knew OO, before ML or Ada got OO stuff, before Java or C# existed (or when Java was an internal project under two old names at Sun), even before C++ got exceptions. Exceptions first appeared under another name in the paper of David Parnas and Harald Würges response to undesired events in software systems in ICSE 1976. Exceptions did not come from OO or languages you mentioned, and this is not about opinion. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Can't install snap (problem with syb)
On 12-03-28 06:30 PM, Brandon Allbery wrote: Did you also remove ~/.ghc? Libraries are actually installed and registered there, not under ~/.cabal. Reality is less simplistic than that. .ghc has library metadata. .cabal has library files. See my http://www.vex.net/~trebla/haskell/sicp.xhtml and verify, verify, verify. Since GHC simply trusts its metadata (and not re-scan library files to re-discover libraries), metadata dominates. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Are there arithmetic composition of functions?
On 12-03-19 10:05 PM, Richard O'Keefe wrote: http://www.haskell.org/onlinereport/haskell2010/haskellch9.html#x16-1710009 Haskell 2010 is already beginning to be out of date. http://thread.gmane.org/gmane.comp.lang.haskell.libraries/16125/focus=16324 http://thread.gmane.org/gmane.comp.lang.haskell.glasgow.user/21065/focus=21078 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Haskell showcase in 5 minutes
On 12-02-27 04:36 PM, rocon...@theorem.ca wrote: In less than 5 minutes I can solve NP-Complete problems in restaurant orders: http://www.reddit.com/comments/24p2c/xkcd_does_anyone_else_feel_compelled_to_solve_this/c24pc5 and right in haskell-cafe: http://www.mail-archive.com/haskell-cafe@haskell.org/msg26459.html http://www.mail-archive.com/haskell-cafe@haskell.org/msg27286.html ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Preventing leaked open file descriptors whencatching exceptions
I cannot reproduce pretty much any claim made in this thread. Unless PIO does not mean System.IO.Posix. I run mkfifo hello to create a named pipe. Then I run this program to keep trying to open for writing, non-blocking (without anyone at the read end initially): import System.Posix.IO import System.Posix.Types(Fd(..)) import qualified Control.Exception as E import Control.Concurrent(threadDelay) main = do E.handle (\e - putStrLn (caught exception: ++ show (e :: E.IOException))) -- you can change IOException to SomeException too (do fd - openFd hello WriteOnly Nothing defaultFileFlags{nonBlock=True} case fd of Fd n - putStrLn (fd number ++ show n) -- I deliberately leak fd ) threadDelay 150 main openFd failures are successfully caught as exceptions; it does not return an Fd that stands for -1 when it fails. (Check its source code and chase down what throwErrnoPathIfMinus1Retry means.) When it fails, it does not leak file descriptors. lsof hello shows nothing. To force file descriptors to be leaked and see what lsof says, I then run cat hello as the read end while the above program is still running, so that openFd succeeds and I have something to leak. lsof hello successfully shows: COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME f 3725 trebla3w FIFO8,5 0t0 158922 hello f 3725 trebla4w FIFO8,5 0t0 158922 hello f 3725 trebla5w FIFO8,5 0t0 158922 hello f 3725 trebla6w FIFO8,5 0t0 158922 hello cat 3726 trebla3r FIFO8,5 0t0 158922 hello My point is that if openFd ... WriteOnly leaks anything, you should be seeing 3w, 4w, etc., emphasis on w. But you're seeing a ton of rs. Your leaker is some read-end code. Ubuntu 11.04 x86 32-bit, kernel 2.6.38, GHC 6.12.3, 7.0.4, 7.2.1, 7.4.1 Lastly, the control structure loop = handle (\e - ... loop) job is very problematic. Go to the haddock of Control.Exception, search for the string The difference between using try and catch for recovery to see why. You should use this: loop = do lr - try job case lr of Left e - ... loop Right a - return a i.e., get out of the exception handler as soon as possible. (Thus, my use of putStrLn inside a handler is also questionable. But mine is a toy. I wouldn't do it in production code.) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] GHC -WAll, -fwarn-unused-do-bind and Cabal
On 12-02-14 03:01 PM, JP Moresmau wrote: I'm confused: I'm using GHC 7.0.2 and Cabal 1.10.1.0 with cabal-install 0.10.2. I use -Wall in my Cabal file. If I build a Haskell file with unused do binds, via the GHC API I get no warning, which is normal, since the doc states: The warnings that are not enabled by -Wall are ..., -fwarn-unused-do-bind But if I build my project through cabal it gives me the warning! Why is compiling with Cabal giving that extra warning that GHC on its own with the same flags doesn't give? Using --verbose on cabal build does not give any clue, no suspicious extra flag is passed on. The plot thickens as I perform some experiments. Experiment #1: main :: IO () main = do { x - getLine; putStrLn thank you } ghc -Wall = Warning: Defined but not used: `x' ghc -fwarn-unused-do-bind = (no warning) Apparently, warn-unused-do-bind does not mean that x is unused. Experiment #2: main :: IO () main = do { getLine; putStrLn thank you } ghc -fwarn-unused-do-bind = Warning: A do-notation statement discarded a result of type String. Suppress this warning by saying _ - getLine, or by using the flag -fno-warn-unused-do-bind ghc -Wall = Warning: A do-notation statement discarded a result of type String. Suppress this warning by saying _ - getLine, or by using the flag -fno-warn-unused-do-bind ghc -Wall -fno-warn-unused-do-bind = (no warning) Apparently, -Wall turns on -fwarn-unused-do-bind, despite the user guide. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Stable pointers: use of cast to/from Ptr
On 12-02-12 09:18 AM, Yves Parès wrote: According to the documentation (http://hackage.haskell.org/packages/archive/base/4.5.0.0/doc/html/Foreign-StablePtr.html), StablePtrs aims at being opaque on C-side. The doc multiply warns again and again that StablePtr, as well as whatever Ptr you get from castStablePtrToPtr, are opague (meaningless) to the C side. This is sanctioned by Haskell 2010, and GHC certainly exploits it to the fullest. The following example shows what kind of pointer values the C side receives for real (I deliberately do not free anything to show you more possible values): #include stdio.h void expose(void *p, void *q) { printf(%p %p\n, p, q); } import Foreign.StablePtr import Foreign.Ptr main = do printout (0 :: Int) printout (let x = not x in x) printout ([] :: [Integer]) printout :: a - IO () printout thunk = do p - newStablePtr thunk expose p (castStablePtrToPtr p) -- I deliberately do not free foreign import ccall expose :: StablePtr a - Ptr b - IO () Typically the output is like 0xf 0xf 0x10 0x10 0x11 0x11 Looks more like keys of a lookup table than pointers. I do not know what good is castStablePtrToPtr for, given that StablePtr is already translated to C side void*, so that no intermediate Ptr step is necessary. Perhaps there is a story from a historical perspective. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] strict version of Haskell - does it exist?
http://www.vex.net/~trebla/haskell/lazy.xhtml It is half done. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] cabal-install package precedence with --extra-lib-dirs
On 12-02-02 12:12 AM, Scott Lawrence wrote: When running cabal install with --extra-lib-dirs=./lib, if a package is found both in ~/.cabal/lib and ./lib, cabal seems to favor the ~/.cabal/lib one. Is there some way to specify the correct precedence to use? --extra-lib-dirs is for C libs only. Haskell packages for GHC are not rediscovered every time by scanning lib directories. They are registered in 2 metadata stores (3 if you add an option), and only the metadata stores are consulted. On existence of packages, this is final. The 2 metadata stores also come with a precedence: the user store has higher priority than the global store. On disambiguation of packages, this is final. http://www.vex.net/~trebla/haskell/sicp.xhtml#ident ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Stuck on HXT basics
On 12-01-30 08:06 AM, Pēteris Paikens wrote: import Text.XML.HXT.Core import Text.XML.HXT.DOM.XmlTreeFilter selectAllText :: ArrowXml a = a XmlTree XmlTree selectAllText = deep isXText Delete import Text.XML.HXT.DOM.XmlTreeFilter. Change isXText to isText. That is, import Text.XML.HXT.Core selectAllText :: ArrowXml a = a XmlTree XmlTree selectAllText = deep isText I am going to change that on Haskell Wiki. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Just found GHCI can be used as a debugger
On 12-01-25 04:06 PM, Yves Parès wrote: 1) Is there some documentation about it? GHC comes with a user guide in HTML somewhere on your disk. It is also on the GHC website, but I much prefer everyone to know and find it on his/her disk first. People spend lifetimes browsing the web, and not one minute browsing their very own disks. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Convert Double to Data.Fixed
On 11-12-26 10:55 AM, Eugene Kirpichov wrote: How do I most efficiently convert a Double to a Data.Fixed? Double is an instance of Real, Fixed E12 is an instance of Fractional, they are eligible for realToFrac. Similarly for many time types. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] strict, lazy, non-strict, eager
There are two flavours of MonadState, Control.Monad.State.Lazy and Control.Monad.State.Strict. There are two flavours of ByteString, Data.ByteString.Lazy and Data.Bytestring (whose doc says strict). There are two flavours of I/O libraries, lazy and strict. There are advices of the form: the program uses too much memory because it is too lazy; try making this part more strict. Eventually, someone will ask what are lazy and strict. Perhaps you answer this (but there are other answers, we'll see): lazy refers to such-and-such evaluation order. strict refers to f ⊥ = ⊥, but it doesn't specify evaluation order. That doesn't answer the question. That begs the question: Why do libraries seem to make them a dichotomy, when they don't even talk about the same level? And the make-it-more-strict advice now becomes: the program uses too much memory because of the default, known evaluation order; try making this part use an unknown evaluation order, and this unknown is supposed to use less memory because...? I answer memory questions like this: the program uses too much memory because it is too lazy---or nevermind lazy, here is the current evaluation order of the specific compiler, this is why it uses much memory; now change this part to the other order, it uses less memory. I wouldn't bring in the denotational level; there is no need. (Sure, I use seq to change evaluation order, which may be overriden by optimizations in rare cases. So change my answer to: now add seq here, which normally uses the other order, but optimizations may override it in rare cases, so don't forget to test. Or use pseq.) I said people, make up your mind. I do not mean a whole group of people for the rest of their lives make up the same mind and choose the same one semantics. I mean this: Each individual, in each context, for each problem, just how many levels of semantics do you need to solve it? (Sure sure, I know contexts that need 4. What about daily programming problems: time, memory, I/O order?) MigMit questioned me on the importance of using the words properly. Actually, I am fine with using the words improperly, too: the program uses too much memory because it is too lazy, lazy refers to such-and-such evaluation order; try making this part more strict, strict refers to so-and-so evaluation order. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] strict, lazy, non-strict, eager
Most individuals of the Haskell community have long been maintaining a cognitive dissonance; some cases turn into plain hypocrisy. You might excuse it for its ancient and prominent origin: Richard Bird and/or Philip Wadler themselves wrote like it is too lazy, make it more strict 13 years ago and surely more. But perpetuating it is not helping. I have not written this complaint until now because I have been waiting for unmistakable evidence, a smoking gun, a red hand so caught that you cannot explain away, for example you cannot explain that one sentence is from one person, the other sentence is from a different person. So, on IRC in #haskell, from the same person, speaking on the same topic in the same context, in the same interval of 3 minutes (the first two sentences in the same minute): 1. a function f is strict if f ⊥ = ⊥ 2. ⊥ represents any computation which does not terminate, i.e. an exception or an infinite loop 3. strict describes the denotational semantics People, could you please make up your mind already? It has been more than 13 years. Denotational semantics: A. There are no computational steps. There is no termination, and there is no non-termination, since there are no steps to finish, and no steps to keep going. B. ⊥ represents no information, not non-termination. There is no non-termination to represent. C. fix id = ⊥ because ⊥ is the least fixed point of id, not because fix id non-terminates. There is nothing to terminate or non-terminate. D. You say strict, more strict, less strict; non-strict, more non-strict, less non-strict. You don't say eager, and you don't say lazy. Operational semantics: A. There is no ⊥; it does not appear in any sequence of computational steps, finitely long or infinitely long. B. You say eager, more eager, less eager; lazy, more lazy, less lazy; or speculative, more speculative, less speculative; or any other adjectives for evaluation strategies. You don't say strict, and you don't say non-strict. Semantics, semantically speaking: A. Which semantics, which semantically? There are two. B. Actually there are more, but apparently two is already enough to cause all kinds of incoherent statements. If I draw your attention to algebraic semantics, will you start saying it is too lazy, need to make it more idempotent? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] writeFile: commitBuffer: invalid argument (Illegal byte sequence)
On 11-12-04 07:08 AM, dokondr wrote: In GHC 7.0.3 / Mac OS X when trying to: writeFile someFile (Hoping You Have A iPhone When I Do This) Lol Sleep Is When You Close These ---gt; \55357\56384 I get: commitBuffer: invalid argument (Illegal byte sequence) The string I am trying to write can also be seen here: http://twitter.com/#!/search/Hoping%20You%20Have%20A%20iPhone%20When%20I%20Do%20This%20lang%3Aen http://twitter.com/#%21/search/Hoping%20You%20Have%20A%20iPhone%20When%20I%20Do%20This%20lang%3Aen \55357 and \56384 would be surrogates D83D and DC40 for use in UTF-16 only. Haskell's Char is not a UTF-16 code unit (unlike early versions of Java and probably current ones). GHC is correct in rejecting them. Haskell's Char is a Unicode character directly. If you want the character U+1F440 EYES, write \128064 directly (or \x1f440, or \x1F440). Use http://www.unicode.org/charts/ to find out what you are getting into. You can enter a hexadecimal number or choose a category. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] A Mascot
On 11-11-22 12:22 AM, Jeremy Shaw wrote: A mascot is supposed to represent characteristics, emotions, or desires that a particular group of people aspire to have, be like, etc. To outsiders, it provides a quick way to see if it might be a group they would like to belong to, and for insiders, it helps strengthen the bond and group identity by reminding them what they stand for. I don't know why I relate to Canada, with mascots of the maple leaf, the beaver, and the moose. I don't know why I relate to linux, with a mascot of the penguin. I don't know why I relate to Kraft peanut butter, with a mascot of a pair of bears... So far, the only justification I have noticed for why a lamb would represent Haskell users is that there is a pun about lambda's -- which only makes sense if you know English. Sheep are generally thought of as: - weak and needing protection - easily lead astray - being lead to the slaughter - dumb and easily lost A lamb-in-arms is the antithesis to all those. It stands up with determination and might against mainstream oppression and stereotyping. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe