Re: [Haskell-cafe] Haskell Weekly News?
While I would not be opposed to being paid, I don't think it's at all necessary or even really appropriate. I liken the job to volunteering at a local community action group -- not really the kind of thing you get paid for. That said, if any of you have time machines/time dilation devices in the works, I'm happy to beta test. One more week... /Joe On Apr 28, 2010, at 2:40 AM, David Virebayre wrote: On Wed, Apr 28, 2010 at 7:47 AM, David Sankel wrote: I'm wondering if a monetary incentive would keep the person who does this work more accountable. I personally would be willing to contribute to continue getting this service. I wonder if there are others as well. I don't think money would be an incentive for someone that has "7 classes worth of finals and papers" to do Now a time machine. David. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Haskell Weekly News?
On Wed, Apr 28, 2010 at 7:47 AM, David Sankel wrote: > I'm wondering if a monetary incentive would keep the person who does this > work more accountable. I personally would be willing to contribute to > continue getting this service. I wonder if there are others as well. I don't think money would be an incentive for someone that has "7 classes worth of finals and papers" to do Now a time machine. David. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Haskell Weekly News?
I'm wondering if a monetary incentive would keep the person who does this work more accountable. I personally would be willing to contribute to continue getting this service. I wonder if there are others as well. David On Mon, Apr 26, 2010 at 9:32 PM, Joe Fredette wrote: > Most certainly, the HWN is easy to put together, it's just a little time > consuming, the weekly schedule is just enough under a normal 40-hour > courseload. When that number jumps into the high billions (as it did this > last semester), it becomes someone more difficult to fit in. > > HWN will always be HWN, at least as long as I can keep it that way. :D > > /Joe > > > > On Apr 26, 2010, at 8:17 PM, Ivan Miljenovic wrote: > > On 27 April 2010 10:08, Joe Fredette wrote: >> >>> I hope to get HWN out shortly after it's all finished up. I shall >>> return! >>> >> >> As long as you don't end up copying the Gentoo situation where the >> Gentoo Weekly News died, was resurrected (not sure how many times), >> was converted to the Gentoo Monthly News to make it simpler, and then >> became the Gentoo Never News (hey, GNN sounds kinda catchy, though not >> as good as C :p). >> >> -- >> Ivan Lazar Miljenovic >> ivan.miljeno...@gmail.com >> IvanMiljenovic.wordpress.com >> > > ___ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- David Sankel Sankel Software ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: FRP for game programming / artifical life simulation
I'm not sure exactly what you want to do. It should certainly be easy to "freeze" an FRP program by lying about the amount of time that is passing and witholding all events. Do you want to save an FRP system instance to disk (generally unwise), or something else (what?). Friendly, --Lane On Tue, 27 Apr 2010, Ben wrote: slightly off topic, but how does one handle pausing / saving / restarting in the FRP framework, especially the arrowized version? i've only been able to do this via explicit (or monadic) state-passing, e.g. imperative / piecemeal versus declarative / wholemeal, which seems against the spirit of FRP. b ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] A newbie question ?
"proxy type" is indeed much clear! thanks Ryan Ingram wrote: > > Remember, "fromJust res" won't be evaluated unless typeOf needs it. > But it does get typechecked at compile time, and the type is used to > select which instance of typeOf to call. > > Fortunately, legal instances of Typeable require typeOf to not inspect > its argument. > > This is a somewhat old design; modern variations on this tend to use a > "proxy type" to make it clear that the argument's value cannot be > evaluated. In modern Haskell, I would write it like so: > > data Proxy a = Proxy > proxy :: a -> Proxy a > > class Typeable a where >typeOf :: Proxy a -> TypeRep > > -- uses ScopedTypeVariables extension > lookup :: forall a. Typeable a => TypeMap -> Maybe a > lookup (TypeMap mp) = liftM (fromJust . fromDynamic) $ Map.lookup > (typeOf (Proxy :: Proxy a)) mp > > -- ryan > > On Tue, Apr 27, 2010 at 5:17 PM, zaxis wrote: >> >> newtype TypeMap = TypeMap (Map.Map TypeRep Dynamic) >> >> lookup :: Typeable a => TypeMap -> Maybe a >> lookup (TypeMap mp) = res >> where res = liftM (fromJust . fromDynamic) $ Map.lookup (typeOf $ >> fromJust res) mp >> >> It seems that the `res` in `fromJust res` has not been defined ? >> >> Sincerely! >> >> - >> fac n = let { f = foldr (*) 1 [1..n] } in f >> -- >> View this message in context: >> http://old.nabble.com/A-newbie-question---tp28383563p28383563.html >> Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. >> >> ___ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > ___ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > - fac n = let { f = foldr (*) 1 [1..n] } in f -- View this message in context: http://old.nabble.com/A-newbie-question---tp28383563p28384431.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] A newbie question ?
Remember, "fromJust res" won't be evaluated unless typeOf needs it. But it does get typechecked at compile time, and the type is used to select which instance of typeOf to call. Fortunately, legal instances of Typeable require typeOf to not inspect its argument. This is a somewhat old design; modern variations on this tend to use a "proxy type" to make it clear that the argument's value cannot be evaluated. In modern Haskell, I would write it like so: data Proxy a = Proxy proxy :: a -> Proxy a class Typeable a where typeOf :: Proxy a -> TypeRep -- uses ScopedTypeVariables extension lookup :: forall a. Typeable a => TypeMap -> Maybe a lookup (TypeMap mp) = liftM (fromJust . fromDynamic) $ Map.lookup (typeOf (Proxy :: Proxy a)) mp -- ryan On Tue, Apr 27, 2010 at 5:17 PM, zaxis wrote: > > newtype TypeMap = TypeMap (Map.Map TypeRep Dynamic) > > lookup :: Typeable a => TypeMap -> Maybe a > lookup (TypeMap mp) = res > where res = liftM (fromJust . fromDynamic) $ Map.lookup (typeOf $ > fromJust res) mp > > It seems that the `res` in `fromJust res` has not been defined ? > > Sincerely! > > - > fac n = let { f = foldr (*) 1 [1..n] } in f > -- > View this message in context: > http://old.nabble.com/A-newbie-question---tp28383563p28383563.html > Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. > > ___ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Seeking the correct quote
Sterling Clover wrote: > I first encountered this quip on ltu: > http://lambda-the-ultimate.org/node/1926#comment-23411 > > However, that comment doesn't give a source either. > Probably where I remembered it from too. I'll continue searching - it's a good quote! Jacques ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Getting used and available memory
On 27 April 2010 17:55, Don Stewart wrote: > We could bind to Rts.c in the GHC runtime, and get all the stats > programmatically that you can get with +RTS -s A long time ago I made a simple binding which has been packaged for cabal by Gwern Branwen. The package is called highWaterMark: http://hackage.haskell.org/package/highWaterMark As the name suggests it tells you the upper limit of RTS allocated memory. It does not tell you about memory allocated by foreign calls. I can't test it at the moment, but it is probably bit-rotten. Maybe it is something to start with? Cheers, Bernie. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Seeking the correct quote
Bradford Larsen wrote: > On Tue, Apr 27, 2010 at 4:23 PM, Jacques Carette wrote: > >> I have heard generic programming described tongue-in-cheek as "the kind of >> polymorphism that a language does not (yet) have". I find this description >> rather apt, and it matches fairly what I see called 'generic' in various >> communities. But who said this, where and when? >> > I seem to > remember reading something along those lines in ``Datatype-Generic > Programming: International Spring School, SSDGP 2006, Nottingham, UK, > April 24-27, 2006, Revised Lectures'', edited by Backhouse, Gibbons, > Hinze, and Jeuring. I've got that book in my office - I'll check tomorrow. I read the preface before I posted on -cafe, and it wasnt' there. I'll read further in, see if I can spot it. Jacques ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: mtl design (was ``What do _you_ want to see in FGL?'')
On 28 April 2010 11:22, Bradford Larsen wrote: > Could you elaborate on what you mean regarding the mtl approach & > design? What makes them bad? Neil seems to have summed up the detractors opinions of mtl quite well at http://chplib.wordpress.com/2010/04/09/removing-mtl-dependency/ . Short version: mtl isn't Haskell98, uses some extensions (notably Functional Dependencies) and has some bugs/design flaws. Several people have written competing libraries such as transformers, but no one library has emerged as the "successor" to mtl yet, which is why mtl is still the Platform. The problem is partially self-fulfilling: 1) No clear successor to mtl (which is still widely used), so keep mtl in the Platform. 2) Someone wants to write some code using monad transformers; mtl comes with the Platform (and is widely used) so they stick with it 2a) Someone searching on Hoogle for transformers, State monad, etc. finds links to mtl so they use it. 3) mtl gets used by more packages than other libraries, and so we go back to 1). Note that I too have fallen into stage 2): for SourceGraph, I wanted a RWS monad so I stuck with mtl because it's been around, used so much, no clear successor, etc. (the only argument that didn't apply to me was "it's in the Platform" since I personally don't use the Platform). This is what I want to avoid for FGL: developing a better, more modern version (though differing from the mtl case in that I plan on using extensions for FGL) only to find that people don't use it because they're used to FGL being the de-facto graph library for Haskell and hence don't use the new library with a different name. Also, if it gets called FGL', what happpens when it fully takes over and FGL is no longer used? The prime becomes redundant... -- Ivan Lazar Miljenovic ivan.miljeno...@gmail.com IvanMiljenovic.wordpress.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Seeking the correct quote
On Tue, Apr 27, 2010 at 4:23 PM, Jacques Carette wrote: > I have heard generic programming described tongue-in-cheek as "the kind of > polymorphism that a language does not (yet) have". I find this description > rather apt, and it matches fairly what I see called 'generic' in various > communities. But who said this, where and when? > > Jacques > ___ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > I don't have the book handy (it was from the library), but I seem to remember reading something along those lines in ``Datatype-Generic Programming: International Spring School, SSDGP 2006, Nottingham, UK, April 24-27, 2006, Revised Lectures'', edited by Backhouse, Gibbons, Hinze, and Jeuring. There's a lead for you, at least! Regards, Brad ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] mtl design (was ``What do _you_ want to see in FGL?'')
On Mon, Apr 26, 2010 at 7:35 AM, Ivan Lazar Miljenovic wrote: > Whilst freezing it is an option, I feel that this will lead to the same > problems that we already face with mtl: most people agree/know that the > approach/design is bad, but we keep using it because there's no (one) > viable alternative to be used (and thus mtl stays in the Platform, which > means more people use it, and thus we have this vicious cycle). Ivan, Could you elaborate on what you mean regarding the mtl approach & design? What makes them bad? Sincerely, Brad ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Seeking the correct quote
I first encountered this quip on ltu: http://lambda-the-ultimate.org/node/1926#comment-23411 However, that comment doesn't give a source either. Cheers, Sterl. On Tue, Apr 27, 2010 at 4:23 PM, Jacques Carette wrote: > I have heard generic programming described tongue-in-cheek as "the kind of > polymorphism that a language does not (yet) have". I find this description > rather apt, and it matches fairly what I see called 'generic' in various > communities. But who said this, where and when? > > Jacques > ___ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] A newbie question ?
On 28 April 2010 10:17, zaxis wrote: > > newtype TypeMap = TypeMap (Map.Map TypeRep Dynamic) > > lookup :: Typeable a => TypeMap -> Maybe a > lookup (TypeMap mp) = res > where res = liftM (fromJust . fromDynamic) $ Map.lookup (typeOf $ > fromJust res) mp > > It seems that the `res` in `fromJust res` has not been defined ? http://www.haskell.org/haskellwiki/Tying_the_Knot -- Ivan Lazar Miljenovic ivan.miljeno...@gmail.com IvanMiljenovic.wordpress.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] A newbie question ?
newtype TypeMap = TypeMap (Map.Map TypeRep Dynamic) lookup :: Typeable a => TypeMap -> Maybe a lookup (TypeMap mp) = res where res = liftM (fromJust . fromDynamic) $ Map.lookup (typeOf $ fromJust res) mp It seems that the `res` in `fromJust res` has not been defined ? Sincerely! - fac n = let { f = foldr (*) 1 [1..n] } in f -- View this message in context: http://old.nabble.com/A-newbie-question---tp28383563p28383563.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] What do _you_ want to see in FGL?
On 28 April 2010 08:48, Henning Thielemann wrote: > Ivan Lazar Miljenovic schrieb: >> Henning Thielemann writes: >>> I was not happy with the way FGL handles lables so far: >>> http://www.haskell.org/pipermail/libraries/2008-February/009241.html >> >> Not sure I follow what you want there: you want to remove the whole >> concept of labels and replace it with the node type? What about edge >> labels then? > > You can label edges using a Map (i,i) label. So you don't want the labels to be part of the actual datatype? And for users to then have to deal with any labels they want themselves? If so, I don't think this is feasible; some of the nice parts of FGL IMHO are how it deals with labels (admittedly, I've had to write and use my own "((Int,a) -> a') -> g a b -> g a' b" function because it doesn't have one...). Removing this would be a step backwards. How exactly is it bad/a pain to have to deal with specifying "g () ()", especially since there are some pre-defined "unlabelled" graph type and function aliases? -- Ivan Lazar Miljenovic ivan.miljeno...@gmail.com IvanMiljenovic.wordpress.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] What do _you_ want to see in FGL?
Ivan Lazar Miljenovic schrieb: > Henning Thielemann writes: >> I was not happy with the way FGL handles lables so far: >> http://www.haskell.org/pipermail/libraries/2008-February/009241.html > > Not sure I follow what you want there: you want to remove the whole > concept of labels and replace it with the node type? What about edge > labels then? You can label edges using a Map (i,i) label. > Also, what happens if I want a label to be a function? I don't see a problem, functions can be elements of an Array or a Map. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] What do _you_ want to see in FGL?
Henning Thielemann writes: > I was not happy with the way FGL handles lables so far: > http://www.haskell.org/pipermail/libraries/2008-February/009241.html Not sure I follow what you want there: you want to remove the whole concept of labels and replace it with the node type? What about edge labels then? Also, what happens if I want a label to be a function? -- Ivan Lazar Miljenovic ivan.miljeno...@gmail.com IvanMiljenovic.wordpress.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Getting used and available memory
We could bind to Rts.c in the GHC runtime, and get all the stats programmatically that you can get with +RTS -s mads.lindstroem: > Hi > > I was _not_ looking for the OS-level measure, but rather something > reported by the run-time. Thanks you for the answer anyway. > > /Mads > > On Tue, 2010-04-27 at 15:32 -0400, Daniel Peebles wrote: > > It's not an easy measurement to even define. There was a huge debacle > > recently about a windows program that reported misleading numbers > > about used memory. The fact that GHC has its own allocator and "hogs" > > OS memory (it never returns it to the OS) might complicate the > > definition further. But in general, if you're looking for an OS-level > > measure you're probably going to need to go to the FFI and talk to the > > specific OS's API for the task. I'm not sure if the GHC runtime allows > > you to ask much about allocated memory. The only thing I've done with > > it was FFI out to a variable that counts the number of bytes allocated > > to measure allocations in calls like GHCi does. > > > > On Tue, Apr 27, 2010 at 12:01 PM, Mads Lindstrøm > > wrote: > > Hi > > > > I have tried haskell.org, Google and Hoolge, but I cannot find > > any > > function to give me the available and/or used memory of a > > Haskell > > program. Is it just not there? Or am I missing it somehow? > > > > > > /Mads > > > > > > ___ > > Haskell-Cafe mailing list > > Haskell-Cafe@haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > > > > ___ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Getting used and available memory
Hi I was _not_ looking for the OS-level measure, but rather something reported by the run-time. Thanks you for the answer anyway. /Mads On Tue, 2010-04-27 at 15:32 -0400, Daniel Peebles wrote: > It's not an easy measurement to even define. There was a huge debacle > recently about a windows program that reported misleading numbers > about used memory. The fact that GHC has its own allocator and "hogs" > OS memory (it never returns it to the OS) might complicate the > definition further. But in general, if you're looking for an OS-level > measure you're probably going to need to go to the FFI and talk to the > specific OS's API for the task. I'm not sure if the GHC runtime allows > you to ask much about allocated memory. The only thing I've done with > it was FFI out to a variable that counts the number of bytes allocated > to measure allocations in calls like GHCi does. > > On Tue, Apr 27, 2010 at 12:01 PM, Mads Lindstrøm > wrote: > Hi > > I have tried haskell.org, Google and Hoolge, but I cannot find > any > function to give me the available and/or used memory of a > Haskell > program. Is it just not there? Or am I missing it somehow? > > > /Mads > > > ___ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Is XHT a good tool for parsing web pages?
Is XHT a good tool for parsing web pages? I read that it fails if the XML isn't strict and I know a lot of web pages don't use strict XHTML. Do you mean HXT rather than XHT? I know that the HaXml library has a separate error-correcting HTML parser that works around most of the common non-well-formedness bugs in HTML: Text.XML.HaXml.Html.Parse I believe HXT has a similar parser: Text.XML.HXT.Parser.HtmlParsec Indeed, some of the similarities suggest this parser was originally lifted directly out of HaXml (as permitted by HaXml's licence), although the two modules have now diverged significantly. Regards, Malcolm ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Number of CPUs/cores?
Hi, > another discussion) will tell you the number of capabilities (native > threads) that have been given to the RTS. The measurement doesn't > necessarily have any connection to the number of physical cores or > processors in your machine. You're correct, should have clarified this more. Cheers, Michael ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Run haskell program in emacs without typing "main" in the ghci buffer.
Jose A. Ortega Ruiz-2 wrote: > > Assuming you're using haskell-mode, does > > M-x inferior-haskell-load-and-run > This seems to be exactly what I want. Added couple of things: (defun haskell-run-preserve-focus () "Load and run but preserve focus." (interactive) (let ((buf (current-buffer))) (inferior-haskell-load-and-run inferior-haskell-run-command) (end-of-buffer) (switch-to-buffer-other-window buf))) Despite the end-of-buffer call for ghci buffer, couple of lines are always hidden after subsequent invoking of the haskell-run-preserve-focus function, albeit it is possible to scroll down with mouse. Thank you and all who replied! Zura -- View this message in context: http://old.nabble.com/Run-haskell-program-in-emacs-without-typing-%22main%22-in-the-ghci-buffer.-tp28368541p28381754.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Seeking the correct quote
I have heard generic programming described tongue-in-cheek as "the kind of polymorphism that a language does not (yet) have". I find this description rather apt, and it matches fairly what I see called 'generic' in various communities. But who said this, where and when? Jacques ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Lazy Parsing (ANN: vcd-0.1.4)
So UU parsers can construct input? The presence of an empty list in the 2nd slot of the tuple is the only indicator of errors? For parsing datatypes without a sensible default value, what happens? -- Jason Dusek ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: FRP for game programming / artifical life simulation
slightly off topic, but how does one handle pausing / saving / restarting in the FRP framework, especially the arrowized version? i've only been able to do this via explicit (or monadic) state-passing, e.g. imperative / piecemeal versus declarative / wholemeal, which seems against the spirit of FRP. b ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Getting used and available memory
It's not an easy measurement to even define. There was a huge debacle recently about a windows program that reported misleading numbers about used memory. The fact that GHC has its own allocator and "hogs" OS memory (it never returns it to the OS) might complicate the definition further. But in general, if you're looking for an OS-level measure you're probably going to need to go to the FFI and talk to the specific OS's API for the task. I'm not sure if the GHC runtime allows you to ask much about allocated memory. The only thing I've done with it was FFI out to a variable that counts the number of bytes allocated to measure allocations in calls like GHCi does. On Tue, Apr 27, 2010 at 12:01 PM, Mads Lindstrøm wrote: > Hi > > I have tried haskell.org, Google and Hoolge, but I cannot find any > function to give me the available and/or used memory of a Haskell > program. Is it just not there? Or am I missing it somehow? > > > /Mads > > > ___ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Number of CPUs/cores?
I believe numCapabilities (should be in IO, in my opinion, but that's another discussion) will tell you the number of capabilities (native threads) that have been given to the RTS. The measurement doesn't necessarily have any connection to the number of physical cores or processors in your machine. On Tue, Apr 27, 2010 at 11:05 AM, Dimitry Golubovsky wrote: > OK, makes sense. > > Thank you. > > On Tue, Apr 27, 2010 at 10:58 AM, Michael Lesniak > wrote: > > [skip] > > numCapabilities, I think. > > > -- > Dimitry Golubovsky > > Anywhere on the Web > ___ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Lazy Parsing (ANN: vcd-0.1.4)
How about: import Text.ParserCombinators.UU.Parsing import Text.ParserCombinators.UU.Examples pDate :: Pars (Int,Int,Int) pDate = (,,) <$> pNatural <* pDot <*> pNatural <* pDot <*> pNatural where pDot = pSym '.' and then: *Main> test pDate "3.4.5" Loading package syb-0.1.0.2 ... linking ... done. Loading package base-3.0.3.2 ... linking ... done. Loading package array-0.3.0.0 ... linking ... done. Loading package filepath-1.1.0.3 ... linking ... done. Loading package old-locale-1.0.0.2 ... linking ... done. Loading package old-time-1.0.0.3 ... linking ... done. Loading package unix-2.4.0.0 ... linking ... done. Loading package directory-1.0.1.0 ... linking ... done. Loading package process-1.0.1.2 ... linking ... done. Loading package time-1.1.4 ... linking ... done. Loading package random-1.0.0.2 ... linking ... done. Loading package haskell98 ... linking ... done. Loading package uu-parsinglib-2.3.1 ... linking ... done. ((3,4,5),[]) *Main> test pDate "3..7" ((3,0,7),[ Inserted '0' at position 2 expecting '0'..'9']) *Main> test pDate "" ((0,0,0),[ Inserted '0' at position 0 expecting '0'..'9', Inserted '.' at position 0 expecting one of ['0'..'9', '.'], Inserted '0' at position 0 expecting '0'..'9', Inserted '.' at position 0 expecting one of ['0'..'9', '.'], Inserted '0' at position 0 expecting '0'..'9']) *Main> test pDate "3.4.2010" ((3,4,2010),[]) *Main> Doaitse On 27 apr 2010, at 13:23, Tom Hawkins wrote: > I had been using Parsec to parse VCD files, but needed to lazily parse > streaming data. After stumbling on this thread below, I switch to > polyparse. > > What a great library! I was able to migrate from a strict to a > semi-lazy parser and many of my parse reductions didn't even need to > change. Thanks Malcolm! > > In addition to lazy VCD parsing, this version of vcd [1] also includes > step', which forces a step regardless if variables have changed or not > -- helpful for realtime simulation. > > (BTW, parsec is a great library too.) > > -Tom > > [1] http://hackage.haskell.org/package/vcd-0.1.4 > > > > On Sun, May 31, 2009 at 6:41 AM, Malcolm Wallace > wrote: >> >> I don't know whether you will be willing to change over to polyparse >> library, but here are some hints about how you might use it. >> >> Given that you want the input to be a simple character stream, rather than >> use a more elaborate lexer, the first thing to do is to specialise the >> parser type for your purposes: >> >>> type TextParser a = Parser Char a >> >> Now, to recognise a "mere digit", >> >>> digit :: TextParser Char >>> digit = satisfy Char.isDigit >> >> and for a sequence of digits forming an unsigned integer: >> >>> integer :: TextParser Integer >>> integer = do ds <- many1 digit >>> return (foldl1 (\n d-> n*10+d) >>> (map (fromIntegral.digitToInt) ds)) >>> `adjustErr` (++("expected one or more digits")) >> >>> I mean I'd like to be able to turn "12.05.2009" into something like (12, >>> 5, 2009) and got no clue what the code would have to look like. I do know >>> almost every variation what the code must not look like :). >> >>> date = do a <- integer >>> satisfy (=='.') >>> b <- integer >>> satisfy (=='.') >>> c <- integer >>> return (a,b,c) >> >> Of course, that is just the standard (strict) monadic interface used by many >> combinator libraries. Your original desire was for lazy parsing, and to >> achieve that, you must move over to the applicative interface. The key >> difference is that you cannot name intermediate values, but must construct >> larger values directly from smaller ones by something like function >> application. >> >>> lazydate = return (,,) `apply` integer `discard` dot >>>`apply` integer `discard` dot >>>`apply` integer >>>where dot = satisfy (=='.') >> >> The (,,) is the constructor function for triples. The `discard` combinator >> ensures that its second argument parses OK, but throws away its result, >> keeping only the result of its first argument. >> >> Apart from lazy space behaviour, the main observable difference between >> "date" and "lazydate" is when errors are reported on incorrect input. For >> instance: >> >> > fst $ runParser date "12.05..2009" >> *** Exception: In a sequence: >> Parse.satisfy: failed >> expected one or more digits >> >> > fst $ runParser lazydate "12.05..2009" >> (12,5,*** Exception: In a sequence: >> Parse.satisfy: failed >> expected one or more digits >> >> Notice how the lazy parser managed to build the first two elements of the >> triple, whilst the strict parser gave no value at all. >> >> I know that the error messages shown here are not entirely satisfactory, but >> they can be improved significantly just by making greater use of the >> `adjustErr` combinator in lots more places (it is rather like Parsec's ). >> Errors containing positional inform
[Haskell-cafe] Trouble with the FFI, Cabal, and GHCI -- installed libraries have invalid FFI pointers
I have two modules. One is a library, installed with Cabal: - -- Data/Text/IDN/StringPrep.hs {-# LANGUAGE ForeignFunctionInterface #-} module Data.Text.IDN.StringPrep where import Foreign foreign import ccall "stringprep.h &stringprep_nameprep" profileNameprep :: Ptr () - The other is the main program, either interpreted directly or compiled and run: - -- TestIDN.hs {-# LANGUAGE ForeignFunctionInterface #-} module Main where import Foreign import Data.Text.IDN.StringPrep foreign import ccall "stringprep.h &stringprep_nameprep" stringprep_nameprep :: Ptr () main = do putStrLn $ "stringprep_nameprep = " ++ show stringprep_nameprep putStrLn $ "profileNameprep = " ++ show profileNameprep - Now, given that both modules import the exact same C symbol, I would expect that the pointers would be the same when running. This is the case for compiled code: - $ ghc --make TestIDN [1 of 1] Compiling Main ( TestIDN.hs, TestIDN.o ) Linking TestIDN ... $ ./TestIDN stringprep_nameprep = 0x0067e3e0 profileNameprep = 0x0067e3e0 - However, if I use ghci / runhaskell, the pointers are different: - $ rm TestIDN TestIDN.o TestIDN.hi $ runhaskell TestIDN.hs stringprep_nameprep = 0x7feebe5fe4e0 profileNameprep = 0x40a908bc - Specifically, the pointer loaded from the library ('profileNameprep') is invalid -- attempting to pass it to libidn will result in errors, and trying to poke around in it yields segmentation faults. I'm using GHC 6.12.1, on Linux. This problem occurs with both dynamic and static libraries. Does anybody have suggestions about how to solve or work around it? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Sorting Types
On Tue, Apr 27, 2010 at 10:20 AM, John Creighton wrote: >> I was wondering if it is possible to sort types in hakell and if so what >> language extension I should use. There are multiple ways that some manner of ordering could be defined on types. A structural definition is one method; ordering Peano numerals is a simple example, but the same idea applies more generally to examining the size/depth/etc. of nested constructors. Another option is defining an explicit ordering on some specified group of types; this allows greater flexibility at the cost of needing to manually add types to the ordering. At any rate, both involve fairly straightforward type-level programming, possible (and in fact rather easy) to accomplish using functional dependencies with overlapping and undecidable instances. A more limited set of extensions is probably viable for some types of ordering, possibly at the expense of some verbosity or difficulty. Unfortunately I'm not very practiced with type families, so I'm not sure how it translates to those; the lack of overlapping instances makes some things awkward or impossible using type families, alas. >> I get the following error: >> >> Illegal type synonym family application in instance: And a (LT a i) >> In the type synonym instance declaration for 'Sort' Well, as it says, type synonym instances can't be used as parameters to type synonym instances. What constitutes a legal instance declaration is described in the GHC user's guide, section 7.7.2.2., if you want clarification. To keep this from being too much doom and gloom, here's a quick-and-dirty example of one way to define an arbitrary explicit ordering on a group of types, that might give you some ideas. First, all the usual extensions that announce: "Warning! We're about to abuse the type system!" > {-# LANGUAGE TypeOperators #-} > {-# LANGUAGE OverlappingInstances #-} > {-# LANGUAGE UndecidableInstances #-} > {-# LANGUAGE MultiParamTypeClasses #-} > {-# LANGUAGE FunctionalDependencies #-} > {-# LANGUAGE FlexibleInstances #-} > {-# LANGUAGE FlexibleContexts #-} My preferred type-level booleans, terse yet friendly. > data Yes = Yes deriving (Show) > data No = No deriving (Show) We'll need some very simple type-level lists. Nothing fancy here. > data Nil = Nil deriving (Show) > infixr 5 :*: > data a :*: b = a :*: b deriving (Show) Four possible results for a comparison. Note the presence of "Unordered", as the comparisons are defined only on an explicit group of types. The TypeOrdering class is used only to convert type-level results to equivalent values, for easier inspection. > data Less = Less deriving (Show) > data Equal = Equal deriving (Show) > data Greater = Greater deriving (Show) > data Unordered = Unordered deriving (Show) > class TypeOrdering t where toOrdering :: t -> Maybe Ordering > instance TypeOrdering Less where toOrdering _ = Just LT > instance TypeOrdering Equal where toOrdering _ = Just EQ > instance TypeOrdering Greater where toOrdering _ = Just GT > instance TypeOrdering Unordered where toOrdering _ = Nothing Now for the meaty bits. The type compare function takes three arguments: a type-level list that specifies the ordering to use, and two types to compare. The list is treated as a comprehensive least-to-greatest enumeration of the ordered types; if either type argument isn't in the list, the result will be Unordered. The general structure is just simple recursion, obfuscated by implementation details of type-level programming. Roughly speaking, conditionals in type-level functions are most conveniently written by calling another type function whose instances are determined by the conditional expression; this is to avoid having GHC evaluate both branches of the conditional, which would lead to unnecessary computation at best and compiler errors at worst. To start with, if the list is empty, the types are unordered; otherwise, we compare both types to the head of the list and branch on the results. > class Compare ord x y r | ord x y -> r where > tComp :: ord -> x -> y -> r > tComp = undefined > instance ( > TypeEq o x bx, > TypeEq o y by, > Comp' bx by ord x y r > ) => Compare (o :*: ord) x y r > instance Compare Nil x y Unordered > > class Comp' bx by ord x y r | bx by ord x y -> r If both types and the list head are all equal, the result is obviously Equal. > instance Comp' Yes Yes ord x y Equal If neither is equal to the list head, recurse with the list tail. > instance (Compare ord x y r) => Comp' No No ord x y r If one of the types is equal to the list head, that type will be the lesser if an ordering exists at all. We select the optimistic result and call another function with the type we didn't find. > instance (Comp'' ord y Less r) => Comp' Yes No ord x y r > instance (Comp'' ord x Greater r) => Comp' No Yes ord x y r If the list is empty, the result is unordered, as before. Otherwise, we compare the type with the list head and branch with yet a
[Haskell-cafe] Getting used and available memory
Hi I have tried haskell.org, Google and Hoolge, but I cannot find any function to give me the available and/or used memory of a Haskell program. Is it just not there? Or am I missing it somehow? /Mads ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Sorting Types
On Tue, Apr 27, 2010 at 10:20 AM, John Creighton wrote: > >> I was wondering if it is possible to sort types in hakell and if so what >> language extension I should use. Not sure if >> this is possible but here is my attempt: >> >> (I'm aware I don't need so many pragmas >> >> {-# LANGUAGE GADTs #-} >> {-# LANGUAGE TypeFamilies #-} >> {-# LANGUAGE UndecidableInstances #-} >> {-# LANGUAGE MultiParamTypeClasses #-} >> {-# LANGUAGE FlexibleInstances #-} >> {-# LANGUAGE TypeSynonymInstances #-} >> data Z=Z deriving (Show) >> data S i=S i deriving (Show) >> data family N a >> type family Add n m >> type instance Add Z m = m >> type instance Add m Z = m >> type instance Add (S n) (S m) = S (S (Add n m)) >> --14 >> type family LT a b >> data Cat=Cat >> data Dog=Dog >> data Fish=Fish >> type family Sort a --19 >> data And a b=And a b >> >> type instance LT Dog Z = Cat >> type instance LT Fish Z = Dog >> type instance LT a (S i) = LT (LT a Z) i >> type instance Sort (And a (LT a i))=And (LT a i) a >> >> I get the following error: >> >> Illegal type synonym family application in instance: And a (LT a i) >> In the type synonym instance declaration for 'Sort' >> Failed, modules loaded: none, >> >> > > > ___ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > It's certainly possible. There's a sample on the haskell wiki using functional dependencies: http://www.haskell.org/haskellwiki/Type_arithmetic#An_Advanced_Example_:_Type-Level_Quicksort This could be translated to type families. Your instance: type instance Sort (And a (LT a i))=And (LT a i) a is illegal because you are using a type function (LT) in the instance head. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Run haskell program in emacs without typing "main" in the ghci buffer.
On Mon, 26 Apr 2010 12:43:39 -0700 (PDT), Zura_ wrote: > > Hello, Hello, > Is it possible to run haskell program in emacs without typing "main" in the > ghci buffer? Assuming "main" function exists of course. > Or, maybe automate sending "main\n" string to ghci buffer input. > In other words, I want edit/run/see result style session. This is not directly related but I use :cmd in order to :reload and call main in only one GHCi command (easier for redoing it again and again). :cmd (return":reload\n :main") -- Nicolas Pouillard http://nicolaspouillard.fr ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Number of CPUs/cores?
OK, makes sense. Thank you. On Tue, Apr 27, 2010 at 10:58 AM, Michael Lesniak wrote: [skip] > numCapabilities, I think. -- Dimitry Golubovsky Anywhere on the Web ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Number of CPUs/cores?
Hello, > Does there exist a Haskell library function that returns the number of > CPUs/cores (in portable way) on a computer where the program calling > it runs? numCapabilities, I think. - Michael ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: The instability of Haskell libraries
I'm so sorry. I mean to say that there is no part of the standard prelude that is the "numeric" part. I was aware of the numeric-prelude package, which is good work and deserves recognition. Friendly, --Lane On Tue, 27 Apr 2010, Henning Thielemann wrote: Christopher Lane Hinson schrieb: On Tue, 27 Apr 2010, Brandon S. Allbery KF8NH wrote: I despair that a better Numeric hierarchy will never make it into Haskell. I thought the main reason for that was that nobody could agree on a "better" hierarchy that was actually usable. (Nobody wants to chain 10 typeclasses together to get work done.) I think that there is a way to do this so that everyone can be happy, if hassled. But GHC already has what we need to define our own numeric preludes. What we don't have is any numeric prelude at all. NumericPrelude does not count as numeric prelude? :-( http://hackage.haskell.org/package/numeric-prelude/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Number of CPUs/cores?
Hi, Does there exist a Haskell library function that returns the number of CPUs/cores (in portable way) on a computer where the program calling it runs? Thanks. -- Dimitry Golubovsky Anywhere on the Web ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Is XHT a good tool for parsing web pages?
On 27 April 2010 16:22, John Creighton wrote: >> Subject: Is XHT a good tool for parsing web pages? >> I looked a little bit at XHT and it seems very elegant for writing >> concise definitions of parsers by forms but I read that it fails if >> the XML isn't strict and I know a lot of web pages don't use strict >> XHTML. Therefore I wonder if it is an appropriate tool for web pages. I don't know about XHT but tagsoup [1] does a pretty good job parsing web pages. Peter [1] http://hackage.haskell.org/package/tagsoup ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Is XHT a good tool for parsing web pages?
> Subject: Is XHT a good tool for parsing web pages? > I looked a little bit at XHT and it seems very elegant for writing > concise definitions of parsers by forms but I read that it fails if > the XML isn't strict and I know a lot of web pages don't use strict > XHTML. Therefore I wonder if it is an appropriate tool for web pages. > > ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Sorting Types
> I was wondering if it is possible to sort types in hakell and if so what > language extension I should use. Not sure if > this is possible but here is my attempt: > > (I'm aware I don't need so many pragmas > > {-# LANGUAGE GADTs #-} > {-# LANGUAGE TypeFamilies #-} > {-# LANGUAGE UndecidableInstances #-} > {-# LANGUAGE MultiParamTypeClasses #-} > {-# LANGUAGE FlexibleInstances #-} > {-# LANGUAGE TypeSynonymInstances #-} > data Z=Z deriving (Show) > data S i=S i deriving (Show) > data family N a > type family Add n m > type instance Add Z m = m > type instance Add m Z = m > type instance Add (S n) (S m) = S (S (Add n m)) > --14 > type family LT a b > data Cat=Cat > data Dog=Dog > data Fish=Fish > type family Sort a --19 > data And a b=And a b > > type instance LT Dog Z = Cat > type instance LT Fish Z = Dog > type instance LT a (S i) = LT (LT a Z) i > type instance Sort (And a (LT a i))=And (LT a i) a > > I get the following error: > > Illegal type synonym family application in instance: And a (LT a i) > In the type synonym instance declaration for 'Sort' > Failed, modules loaded: none, > > > ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] What do _you_ want to see in FGL?
Ivan Lazar Miljenovic schrieb: > Since I've volunteered myself to help maintain/upgrade FGL, what do the > people in the community want to see happen with it? I was not happy with the way FGL handles lables so far: http://www.haskell.org/pipermail/libraries/2008-February/009241.html ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: The instability of Haskell libraries
Christopher Lane Hinson schrieb: > > On Tue, 27 Apr 2010, Brandon S. Allbery KF8NH wrote: > >>> I despair that a better Numeric hierarchy will never make it into >>> Haskell. >> >> >> I thought the main reason for that was that nobody could agree on a >> "better" hierarchy that was actually usable. (Nobody wants to chain >> 10 typeclasses together to get work done.) > > I think that there is a way to do this so that everyone can be happy, if > hassled. > > But GHC already has what we need to define our own numeric preludes. > What we don't have is any numeric prelude at all. NumericPrelude does not count as numeric prelude? :-( http://hackage.haskell.org/package/numeric-prelude/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Final call for participation: Summer school "Applied Functional Programming", Aug 16-27, Utrecht NL, Application deadline: May 1
[Feel free to advertise the school to others who might be interested.] ~~ Utrecht Summer School in Computer Science: Applied Functional Programming August 16-27, 2010 Utrecht, The Netherlands ~~ The summer school is intended as a first or an advanced course on Haskell, consisting of lectures and projects to be solved by the participants, working in teams. We mainly target bachelor and master students, but others who are interested are also welcome to apply. The deadline for applications is *** Saturday, May 1, 2010 ***. More information: http://www.cs.uu.nl/wiki/USCS2010 If you have any questions, feel free to contact me. Cheers, Andres -- Andres Loeh, Universiteit Utrecht mailto:and...@cs.uu.nl mailto:m...@andres-loeh.de http://www.andres-loeh.de ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] ANN: iteratee-parsec 0.0.3
iteratee-parsec is a package allowing parsec parser using iteratee. Changes in 0.0.3: - Update to transformers 0.2.* (tested with 0.2.1.0) - Add stricter checks for version of dependencies Regards signature.asc Description: This is a digitally signed message part ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Haddock infix constructors in markup
2010/4/26 Daniel Fischer : > Am Montag 26 April 2010 22:18:53 schrieb Daniel Fischer: >> Am Montag 26 April 2010 22:05:48 schrieb Ozgur Akgun: >> > So, how can we make use of this fix? >> >> My guess: >> >> $ cabal install haddock-2.7.2 > > No, it's not yet in there :( Yes, I should make a new release. In the meantime, you could try darcs get http://code.haskell.org/haddock David ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Lazy Parsing (ANN: vcd-0.1.4)
I had been using Parsec to parse VCD files, but needed to lazily parse streaming data. After stumbling on this thread below, I switch to polyparse. What a great library! I was able to migrate from a strict to a semi-lazy parser and many of my parse reductions didn't even need to change. Thanks Malcolm! In addition to lazy VCD parsing, this version of vcd [1] also includes step', which forces a step regardless if variables have changed or not -- helpful for realtime simulation. (BTW, parsec is a great library too.) -Tom [1] http://hackage.haskell.org/package/vcd-0.1.4 On Sun, May 31, 2009 at 6:41 AM, Malcolm Wallace wrote: > > I don't know whether you will be willing to change over to polyparse > library, but here are some hints about how you might use it. > > Given that you want the input to be a simple character stream, rather than > use a more elaborate lexer, the first thing to do is to specialise the > parser type for your purposes: > >> type TextParser a = Parser Char a > > Now, to recognise a "mere digit", > >> digit :: TextParser Char >> digit = satisfy Char.isDigit > > and for a sequence of digits forming an unsigned integer: > >> integer :: TextParser Integer >> integer = do ds <- many1 digit >> return (foldl1 (\n d-> n*10+d) >> (map (fromIntegral.digitToInt) ds)) >> `adjustErr` (++("expected one or more digits")) > >> I mean I'd like to be able to turn "12.05.2009" into something like (12, >> 5, 2009) and got no clue what the code would have to look like. I do know >> almost every variation what the code must not look like :). > >> date = do a <- integer >> satisfy (=='.') >> b <- integer >> satisfy (=='.') >> c <- integer >> return (a,b,c) > > Of course, that is just the standard (strict) monadic interface used by many > combinator libraries. Your original desire was for lazy parsing, and to > achieve that, you must move over to the applicative interface. The key > difference is that you cannot name intermediate values, but must construct > larger values directly from smaller ones by something like function > application. > >> lazydate = return (,,) `apply` integer `discard` dot >> `apply` integer `discard` dot >> `apply` integer >> where dot = satisfy (=='.') > > The (,,) is the constructor function for triples. The `discard` combinator > ensures that its second argument parses OK, but throws away its result, > keeping only the result of its first argument. > > Apart from lazy space behaviour, the main observable difference between > "date" and "lazydate" is when errors are reported on incorrect input. For > instance: > > > fst $ runParser date "12.05..2009" > *** Exception: In a sequence: > Parse.satisfy: failed > expected one or more digits > > > fst $ runParser lazydate "12.05..2009" > (12,5,*** Exception: In a sequence: > Parse.satisfy: failed > expected one or more digits > > Notice how the lazy parser managed to build the first two elements of the > triple, whilst the strict parser gave no value at all. > > I know that the error messages shown here are not entirely satisfactory, but > they can be improved significantly just by making greater use of the > `adjustErr` combinator in lots more places (it is rather like Parsec's ). > Errors containing positional information about the input can be constructed > by introducing a separate lexical tokenizer, which is also not difficult. > > Regards, > Malcolm > > ___ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: The instability of Haskell libraries
On Tue, 27 Apr 2010, Brandon S. Allbery KF8NH wrote: I despair that a better Numeric hierarchy will never make it into Haskell. I thought the main reason for that was that nobody could agree on a "better" hierarchy that was actually usable. (Nobody wants to chain 10 typeclasses together to get work done.) I think that there is a way to do this so that everyone can be happy, if hassled. But GHC already has what we need to define our own numeric preludes. What we don't have is any numeric prelude at all. We just have a prelude prelude. I think it would *really* help if we could break the Prelude down into component packages, that can be separately imported, so that we don't have nonsense like this: http://hackage.haskell.org/packages/archive/list-extras/latest/doc/html/Prelude-Listless.html And such a thing could be done without breaking any code -- each compiler already has it's own non-standard breakdown anyway. Friendly, --Lane ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Haddock infix constructors in markup
I shouldn't have choosen Num for the constructor name, it led to confusions apparently. You can replace tha Num with anything you want, doesn't change the situation. I mean, it's not the problematic part. Is there any news about the fix in the lexer? When can we use it? On 27 April 2010 00:52, Ivan Miljenovic wrote: > On 27 April 2010 02:15, Ozgur Akgun wrote: > > data Expr = Num Int | Expr :+: Expr | Expr :-: Expr > > > > [snip] > > > > -- | If the input is 'Num' does magic, if it is ':+:' does even more > magic! > > someFunc :: Expr -> Expr > > > > In the output of this markup, the 'Num' is hyperlinked but the ':+:' is > not. > > I would hazard a guess that the Num hyperlink points to the Num > typeclass in the Prelude rather than your Num constructor. As for > your infix constructor, I have no idea. > > -- > Ivan Lazar Miljenovic > ivan.miljeno...@gmail.com > IvanMiljenovic.wordpress.com > -- Ozgur Akgun ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Installing ghc in an OpenSolaris Zone
Günther Schmidt schrieb: > Hello, > > has anyone yet managed to install ghc (6.10.4) into an OpenSolaris zone? http://www.haskell.org/ghc/download_ghc_6_10_4.html#x86solaris is supposed to work under open solaris, too. Cheers Christian ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe