Re: [Haskell-cafe] a little parsec enhancement
The exported `mkPT` is equivalent to the old 'ParsecT' data constructor from parsec 3.0.x. I wouldn't mind exporting a similar alias for the new 'ParsecT' constructor from 3.1.x. On Fri, Sep 6, 2013 at 2:21 PM, Petr Pudlák petr@gmail.com wrote: Dne 09/05/2013 01:38 PM, Roman Cheplyaka napsal(a): * Petr Pudlák petr@gmail.com [2013-09-05 11:18:25+0200] Unfortunately |ParsecT| constructor isn't exported so I'm not able to implement it outside /parsec/. No, but there's an 'mkPT' function which is equivalent to the ParsecT constructor. (Although I, too, wish the ParsecT constructor were exposed.) Roman Yes, I tried to use `mkPT`, but the result looked very complicated and I wasn't quite sure if it'll be working correctly in all cases. Implementing the same thing with the `ParsecT` constructor is simple and comprehensible. Best regards, Petr ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Generating Haskell Code out of Haskell AST (GHC API)
The package haskell-src-exts is a lot less intimidating if all you are trying to do is programmatically generate Haskell source: http://hackage.haskell.org/package/haskell-src-exts The base types are here: http://hackage.haskell.org/packages/archive/haskell-src-exts/1.13.5/doc/html/Language-Haskell-Exts-Syntax.html#t:Module This module has some helper function for generating parts of the AST: http://hackage.haskell.org/packages/archive/haskell-src-exts/1.13.5/doc/html/Language-Haskell-Exts-Build.html On Thu, Jul 18, 2013 at 1:11 PM, John Blackbox blackbox.dev...@gmail.com wrote: Hi! I dont know GHC API very well, but I want to generate AST of a program using GHC API. Is there any standard method to generate Haskell code out of it? (something like print_this_for_me_please function? :D ___ 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] Fwd: Basic Parsec float integer parsing question
Forwarding to the list. -- Forwarded message -- From: Fredrik Karlsson dargo...@gmail.com Date: Fri, Jul 5, 2013 at 11:42 AM Subject: [Haskell-cafe] Basic Parsec float integer parsing question To: haskell-cafe@haskell.org Dear list, Sorry for asking a simple parsec question, but both Parsec and Haskell is new to me, so please be gentle :-) I have this code: import Text.ParserCombinators.Parsec import Text.Parsec.Token import Text.ParserCombinators.Parsec.Char data VariableLine = VariableLine String String deriving Show data TierType = IntervalTier | PointTier deriving Show data Tier = Tier TierType String Float Float Integer data Label = Interval Float Float String data LabelFile = LabelFile Float Float symbol :: Parser Char symbol = oneOf !#$%|*+-/:=?@^_~ testString = intervals [1]:\nxmin = 0 \nxmax = 0.028192 \ntext = \\ headTS1 = File type = \ooTextFile\\nObject class = \TextGrid\\n\nxmin = header :: Parser LabelFile header = do headTS1 start - float string \nxmax = end - float string \ntiers? exists\nsize = integer char '\n' return $ LabelFile start end Loading it into ghci I get : Prelude :l parsectest.hs [1 of 1] Compiling Main ( parsectest.hs, interpreted ) parsectest.hs:21:9: Couldn't match type `[]' with `Text.Parsec.Prim.ParsecT String () Data.Functor.Identity.Identity' Expected type: Text.Parsec.Prim.ParsecT String () Data.Functor.Identity.Identity Char Actual type: [Char] In a stmt of a 'do' block: headTS1 In the expression: do { headTS1; start - float; string \ \xmax = ; end - float; } In an equation for `header': header = do { headTS1; start - float; string \ \xmax = ; } parsectest.hs:22:18: Couldn't match expected type `Text.Parsec.Prim.ParsecT String () Data.Functor.Identity.Identity Float' with actual type `GenTokenParser s0 u0 m0 - Text.Parsec.Prim.ParsecT s0 u0 m0 Double' In a stmt of a 'do' block: start - float In the expression: do { headTS1; start - float; string \ \xmax = ; end - float; } In an equation for `header': header = do { headTS1; start - float; string \ \xmax = ; } parsectest.hs:24:16: Couldn't match expected type `Text.Parsec.Prim.ParsecT String () Data.Functor.Identity.Identity Float' with actual type `GenTokenParser s1 u1 m1 - Text.Parsec.Prim.ParsecT s1 u1 m1 Double' In a stmt of a 'do' block: end - float In the expression: do { headTS1; start - float; string \ \xmax = ; end - float; } In an equation for `header': header = do { headTS1; start - float; string \ \xmax = ; } parsectest.hs:26:9: Couldn't match expected type `Text.Parsec.Prim.ParsecT String () Data.Functor.Identity.Identity a0' with actual type `GenTokenParser s2 u2 m2 - Text.Parsec.Prim.ParsecT s2 u2 m2 Integer' In a stmt of a 'do' block: integer In the expression: do { headTS1; start - float; string \ \xmax = ; end - float; } In an equation for `header': header = do { headTS1; start - float; string \ \xmax = ; } Failed, modules loaded: none. I'm sure I'm doing something really stupid here, but I need help to get through this problem. I've used the predefined letter parser at other places in the code, so I can't understand why float and integer does not work. /Fredrik -- Life is like a trumpet - if you don't put anything into it, you don't get anything out of it. ___ 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] Layer on a layer of record syntax in the type synonym?
You could look into the Generic Monoid solution proposed in your other thread, then you wouldn't need your Socket types - you would use the Generic Monoid machinery to make a Monoid instance for whatever type needed it. This approach loses some type-safety, as you might pass on version of a Scoket3 to a function that was meant to take a different type of Socket3. On Fri, Dec 21, 2012 at 4:50 PM, Christopher Howard christopher.how...@frigidcode.com wrote: On 12/21/2012 04:52 AM, Daniel Trstenjak wrote: Why having a Socket3 in the first place, what's the point of it? The idea was to have some generic structures (Sockets) which were already instanced into the Monoids-within-Monoids abstraction, yet could still be made concrete into anything more specific. So, I have... code: data Socket3 a b c = Socket3 a b c deriving (Show) instance (Monoid a, Monoid b, Monoid c) = Monoid (Socket3 a b c) where mempty = Socket3 mempty mempty mempty Socket3 a b c `mappend` Socket3 w x y = Socket3 (a w) (b x) (c y) nullSocket3 :: (Monoid a, Monoid b, Monoid c) = Socket3 a b c nullSocket3 = Socket3 mempty mempty mempty ...which allows me to have... code: type ShipSys = Socket3 (Last Engine) (Last RotThruster) [LinThruster] nullShipSys :: ShipSys nullShipSys = nullSocket3 setEngineSocket (Socket3 a b c) x = Socket3 x b c engineSys :: Engine - ShipSys engineSys a = setEngineSocket nullShipSys (Last (Just a)) mk1Engine = engineSys (Engine 100 1 Mark I) -- etc. And so, with each individual component being wrapped as a generic ShipSys (ship system), I can make a complete system simply by composition: code: h :t mk1Engine mk1Engine :: ShipSys h :t stdRearThruster stdRearThruster :: ShipSys h :t stdFrontThruster stdFrontThruster :: ShipSys h :t stdRotThruster stdRotThruster :: Power - ShipSys h mk1Engine stdRearThruster stdFrontThruster stdRotThruster 10 Socket3 (Last {getLast = Just (Engine 100.0 1.0 Mark I)}) (Last {getLast = Just (RotThruster 10.0)}) [LinThruster 3.1415927 1.0,LinThruster 0.0 0.5] This seems to work well enough so far. But the issue I was concerned about is: if I can't layer record syntax onto the type synonym, then I have to rewrite a whole bunch of getters / setters each time I want to add an attribute (e.g., requiring a switch from a Socket3 to a Socket4.) If this is the case, then perhaps it would be better just to define the ShipSys type directly, and directly instance it into the monoid abstraction. -- frigidcode.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] SOX - play simple
The example is assuming you have an import statement like this: import qualified Sound.Sox.Option.Format as Option On Wed, Nov 28, 2012 at 8:48 AM, Gary Klindt gary.kli...@googlemail.com wrote: Dear Cafe, after installing the Sox library (cabal install sox) I wanted to let run a minimal example from http://hackage.haskell.org/packages/archive/sox/0.2.2.2/doc/html/Sound-Sox-Play.html module Main where import Sound.Sox.Play import Sound.Sox.Signal.List --import Sound.Sox.Option.Format import Data.Int main = do simple Sound.Sox.Signal.List.put Option.none 11025 (iterate (1000+) (0::Data.Int.Int16)) in this version, I get the error: Not in scope: `Option.none' So, I imported Sound.Sox.Option.Format, because there is a none with the right type. I also changed Option.none to none. Then the program compiles and I get the runtime error: fd:4: hClose: resource vanished (Broken pipe) What is wrong here? I appreciate your help! Best regards, Gary ___ 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: Using DeepSeq for exception ordering
Is this related to imprecise exceptions? http://research.microsoft.com/en-us/um/people/simonpj/papers/imprecise-exn.htm Antoine On Thu, Nov 8, 2012 at 12:01 PM, Nicolas Frisby nicolas.fri...@gmail.comwrote: And the important observation is: all of them throw A if interpreted in ghci or compiled without -O, right? On Thu, Nov 8, 2012 at 11:24 AM, Albert Y. C. Lai tre...@vex.net wrote: On 12-11-08 07:12 AM, Simon Hengel wrote: I was just going to say that I can give at least one counterexample where this does not hold: evaluate (('a' : undefined) `deepseq` return () :: IO ()) throwIO exceptionB But then I realized that here exceptionA is optimized away altogether. For me this smells like a bug. Is this related to [1]? [1] http://hackage.haskell.org/**trac/ghc/ticket/2273http://hackage.haskell.org/trac/ghc/ticket/2273 Interesting. A few more tests (all GHC 7.4.2, linux, x86 32-bit, use ghc -O to compile): The following cases throw A: import Control.DeepSeq import Control.Exception main = do evaluate (('a' : error A) `deepseq` return () :: Maybe ()) throwIO (userError B) main = do evaluate (('a' : error A) `deepseq` ()) throwIO (userError B) main = do evaluate (('a' : error A) `deepseq` True) throwIO (userError B) main = do x - evaluate (('a' : error A) `deepseq` putStrLn hi) x throwIO (userError B) The following cases throw B: main = do evaluate (('a' : error A) `deepseq` return () :: IO ()) throwIO (userError B) main = do evaluate (('a' : error A) `deepseq` putStrLn hi) throwIO (userError B) main = do evaluate (('a' : error A) `deepseq` getLine) throwIO (userError B) __**_ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.**org Glasgow-haskell-users@haskell.org http://www.haskell.org/**mailman/listinfo/glasgow-**haskell-usershttp://www.haskell.org/mailman/listinfo/glasgow-haskell-users ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: Proposal: EPHEMERAL pragma
On Thu, Oct 25, 2012 at 9:45 AM, Johan Tibell johan.tib...@gmail.com wrote: Interesting idea. On Thu, Oct 25, 2012 at 6:56 AM, José Pedro Magalhães j...@cs.uu.nl wrote: 3. Emit a warning if the generated core code still contains uses of Rep. I think this part will be really annoying, as GHC might end up generating warnings that the programmer can do nothing about (because some optimization failed to remove Rep). This could be a new warning which is not included in -Wall by default. It would be more a report than a warning, I guess. Antoine ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: [Haskell-cafe] How do I specify language literals in hsparql?
On Sun, Oct 21, 2012 at 10:41 AM, Andrew Pennebaker andrew.penneba...@gmail.com wrote: If the raw SPARQL is rdfs:label D (programming language)@en, what would the hsparql syntax be? The docs don't include any language literal examples. Have you emailed the maintainer of the package? Not all package authors subscribe to high-traffic lists like haskell-cafe. Antoine -- Cheers, Andrew Pennebaker www.yellosoft.us ___ 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] How to correctly benchmark code with Criterion?
On Thu, Oct 18, 2012 at 4:23 AM, Janek S. fremenz...@poczta.onet.pl wrote: Dear list, during past few days I spent a lot of time trying to figure out how to write Criterion benchmarks, so that results don't get skewed by lazy evaluation. I want to benchmark different versions of an algorithm doing numerical computations on a vector. For that I need to create an input vector containing a few thousand elements. I decided to create random data, but that really doesn't matter - I could have as well use infinite lists instead of random ones. My problem is that I am not certain if I am creating my benchmark correctly. I wrote a function that creates data like this: dataBuild :: RandomGen g = g - ([Double], [Double]) dataBuild gen = (take 6 $ randoms gen, take 2048 $ randoms gen) And I create benchmark like this: bench Lists $ nf L.benchThisFunction (L.dataBuild gen) The argument value will be evaluated by the first run of the bench-mark, and then laziness will keep the value around for the next few hundred runs that the bench function performs. So the evaluation will be included in the benchmark, but if bench is doing enough trials it will be statistical noise. Antoine ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] How to correctly benchmark code with Criterion?
On Thu, Oct 18, 2012 at 9:06 AM, Janek S. fremenz...@poczta.onet.pl wrote: So the evaluation will be included in the benchmark, but if bench is doing enough trials it will be statistical noise. When I intentionally delayed my dataBuild function (using delayThread 100) the estimated time of benchmark was incorrect, but when I got the final results all runs were below 50ms, which means that initial run that took 1 second was discarded. So it seems to me that the first evaluation is discarded. Would be good if someone could definitely confirm that. You could email Bryan, the author of criterion. Janek ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANNOUNCE: uuid-1.2.6
On Fri, Sep 21, 2012 at 12:30 AM, David Fox dds...@gmail.com wrote: I was wondering about this: -- My goal with this instance was to make it work just enough to do what -- I want when used with the HStringTemplate library. instance Data UUID where toConstr uu = mkConstr uuidType (show uu) [] (error fixity) gunfold _ _ = error gunfold dataTypeOf _ = uuidType Is there any reason not to just say deriving Data in the type declaration? I didn't want my 'Data' instance to leak the details of the constructor. Also I don't know much about how 'Data' works. I think a similar conversation is going on about the Data declarations in the 'containers' library. Antoine ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] What is the good way to work with list comprehension and UTCTime?
On Sun, Sep 16, 2012 at 5:04 PM, Richard O'Keefe o...@cs.otago.ac.nz wrote: On 15/09/2012, at 5:14 AM, Chris Heller wrote: You might want to have a look at the time-recurrence package: http://hackage.haskell.org/package/time-recurrence For your simple cases you would do something like: Each second: starting (UTCTime ...) $ recur secondly Each minute: starting (UTCTime ...) $ recur minutely Ouch. Look up minutely (my-NEWT-ly) in an English dictionary. Look up secondly while you're there. You can blame RFC 5545 for that one. In section 3.3.10. our frequencies are: freq= SECONDLY / MINUTELY / HOURLY / DAILY / WEEKLY / MONTHLY / YEARLY Antoine ___ 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
It should be pretty easy to write an adapter function of type String - (Show a = a). On Aug 11, 2012 12:34 PM, Patrick Palka patr...@parcs.ath.cx wrote: On Sat, Aug 11, 2012 at 4:14 AM, o...@okmij.org wrote: I'd like to point out that the only operation we can do on the first argument of MkFoo is to show to it. This is all we can ever do: we have no idea of its type but we know we can show it and get a String. That's not all you can do: you can also pass the first argument of MkFoo to a function that expects a Show a = a argument, like the function 'print'. Can you do that with just a String (that represents show x for some x)? ___ 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] parsec: parserFail multiple error messages
On Wed, Aug 8, 2012 at 8:26 PM, silly silly8...@gmail.com wrote: Inserting a character into the stream can be expensive if for example the stream is a ByteString. I tried the following crazy solution and it seems that it works: succeed :: Parser () succeed = mkPT $ \st - return $ Consumed $ return $ Ok () st $ unknownError st succeed is a parser that always succeeds without really consuming any input but it also resets the error state. Because you're using the 'Consumed' constructor, you're also telling parsec not the back-track if there any errors following this parsers. This means that 'succeed failingParser' won't backtrack, even if 'failingParser' doesn't consume input. Are you using your original parser within a larger parser? Are the error messages also not great? Antoine ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Capturing the parent element as I parse XML using parsec
On Sun, Jul 29, 2012 at 1:21 AM, C K Kashyap ckkash...@gmail.com wrote: Hi, With the help of the cafe I've been able to write up the xml parser using parsec - https://github.com/ckkashyap/really-simple-xml-parser/blob/master/RSXP.hs I am struggling with an idea though - How can I capture the parent element of each element as I parse? Is it possible or would I have to do a second pass to do the fixup? What are you trying to do? Maybe you could give an example of what you'd like to produce? Generally speaking, having tree elements in a Haskell datatype point to their parent and their children is asking for trouble - it means you can't change any part of the tree without re-building the entire tree (otherwise your parent pointers point to the parent in the old version of the tree). If you're interested in complex traversals and transformation of XML trees, I like the cursor API here: http://hackage.haskell.org/packages/archive/xml/1.3.12/doc/html/Text-XML-Light-Cursor.html HaXML is also popular for whole-tree queries and transformations. Antoine ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Need help with learning Parsec
On Sun, Jul 22, 2012 at 11:00 AM, C K Kashyap ckkash...@gmail.com wrote: What's the function to access it? The function 'runParser' returns either a result or a ParseError. You can extract the error position with the 'errorPos' function, and then you can extract the name of the file from the position with 'sourceName'. The the 'Show' instance of ParseError does this. Antoine ___ 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
Cabal doesn't play well with version constraints on the template-haskell package - it doesn't know it can't reinstall template-haskell. The workaround is to figure out why QuickCheck has version constraints on template-haskell and solve that problem in the QuickCheck package a different way - perhaps with CPP conditonal compilation macros - and then remove the problematic version constraints. On Jul 17, 2012 11:44 AM, Alexander Foremny alexanderfore...@gmail.com wrote: Dear Levent, unfortunately I am at a loss here. As far as I understand it this should be fixed in QuickCheck's .cabal file or on Hackage. But I am not experienced enough to decide. You best wait for someone else to comment on this. Depending on template-haskell in your .cabal file is not the way to go as far as I understand it. But maybe it's a possible work-around in case you depend on the package being available on Hackage timely. Regards, Alexander Foremny 2012/7/17 Levent Erkok erk...@gmail.com: It builds fine locally on my box; but not on hackage. Here's the page: http://hackage.haskell.org/package/sbv-2.2 Thanks for looking into this Alexander, I appreciate your help. -Levent. On Tue, Jul 17, 2012 at 9:09 AM, Alexander Foremny alexanderfore...@gmail.com wrote: Which package are you trying to build? Is it a local package that fails to build or something on Hackage? Its .cabal file or at least full dependencies would be of interest. Regards, Alexander Foremny 2012/7/17 Levent Erkok erk...@gmail.com: Thanks Alexander. However, I'm not sure how to use the workaround described so I can get hackage to properly compile my package. It sounds like I have to add a template-haskell = 2.7.0.0 dependency to my own cabal file, which sounds like the wrong thing to do in the long-run. Is there something that can be done on the hackage/ghc side to avoid this issue? Or something less drastic than adding a template-haskell dependency on my own package's cabal file? Thanks, -Levent. On Tue, Jul 17, 2012 at 7:31 AM, Alexander Foremny alexanderfore...@gmail.com wrote: Dear Levent, I think this [1] could be related. Regards, Alexander Foremny PS. Sent this to Levent directly. Here's a copy for the mailing list. Sorry for the noise. [1] http://haskell.1045720.n5.nabble.com/Bad-interface-problem-td5714184.html -- Forwarded message -- From: Alexander Foremny alexanderfore...@gmail.com Date: 2012/7/17 Subject: Re: [Haskell-cafe] hackage compile failure with QuickCheck 2.5 To: Levent Erkok erk...@gmail.com Dear Levent, I think this [1] could be related. Regards, Alexander Foremny [1] http://haskell.1045720.n5.nabble.com/Bad-interface-problem-td5714184.html 2012/7/17 Levent Erkok erk...@gmail.com: [This message is more appropriate for a hackage mailing list I presume, but that doesn't seem to exist. Let me know if there's a better place to send it.] I'm having a hackage compile failure for a newly uplodaded package that has a QuickCheck 2.5 dependence. The error message is: [13 of 13] Compiling Test.QuickCheck.All ( Test/QuickCheck/All.hs, dist/build/Test/QuickCheck/All.o ) Test/QuickCheck/All.hs:15:1: Bad interface file: /usr/local/tmp/archive/install/lib/template-haskell-2.6.0.0/ghc-7.4.1/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 The full log file is at (search for Something is a miss in it): http://hackage.haskell.org/packages/archive/sbv/2.2/logs/failure/ghc-7.4 Needless to say, I don't see this problem when I compile this package at home with the same compiler (ghc 7.4.1) as hackage is using; also Hackage has a successfully compiled QuickCheck 2.5 package. Could it be something related to the particular cabal/ghc installation on the hackage server? In particular, I don't understand why it picks template-haskell 2.6.0.0 when there's a newer version (2.7.0.0). As far as I can see, QuickCheck doesn't put an upper limit on its template haskell version dependency. I'd appreciate any pointers with this. (Googling and questions on the #haskell irc channel didn't help much, unfortunately.) -Levent. ___ 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] strange hangs with -threaded runtime (now with test case)
Well, hPipeFrom does indeed call forkProcess internally. I don't fully understand when it is and is not safe to use 'forkProcess' with the threaded runtime of GHC. Which version of GHC are you using? Antoine On Sat, Jul 14, 2012 at 1:24 PM, Joey Hess j...@kitenet.net wrote: I've found a minimal test case that seems to demonstrate a bug in either MissingH or ghc's threaded runtime. Or I'm doing something stupid in fewer lines of code than usual. ;) When built with the threaded runtime, after a short while it hangs in hGetContents. import System.Cmd import System.IO import System.Cmd.Utils import System.Posix.Process import Control.Monad main :: IO () main = forever $ pipeRead [hello, world] pipeRead :: [String] - IO () pipeRead params = do -- removing this next line avoids the hang somehow print $ pipeRead in ++ show params (p, h) - hPipeFrom echo params print pipeRead getcontents c - hGetContents h print $ got: ++ c _ - getProcessStatus True False $ processID p -- removing this last line avoids the hang somehow print pipeRead out joey@wren:~ghc --make -threaded test [1 of 1] Compiling Main ( test.hs, test.o ) Linking test ... joey@wren:~./test pipeRead in [\hello\,\world\] pipeRead getcontents got: hello world\n pipeRead out pipeRead in [\hello\,\world\] pipeRead getcontents got: hello world\n pipeRead out snip 20 repeats pipeRead in [\hello\,\world\] pipeRead getcontents hang Ghc 7.4.2, Debian Linux -- see shy jo ___ 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] strange hangs with -threaded runtime (now with test case)
If the MVar was set up prior to the fork, I can imagine things going crazy trying to use it on the ther side of the fork - especially if their were waiting readers or writers while the fork was executing. On Jul 14, 2012 3:01 PM, Joey Hess j...@kitenet.net wrote: I've isolated the hang further to hPipeFrom's use of System.Log.Logger. Commenting out calls to logging functions makes it reliably run ok. See the LINE OF DEATH in the attached updated test case. ... And it turns out that System.Log.Logger uses a MVar to hold the logger information. So I think this points to a MissingH bug, although I don't yet understand it. -- see shy jo ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Question on proper use of Data.IORef
On Fri, Jun 22, 2012 at 11:18 AM, Captain Freako capn.fre...@gmail.com wrote: Okay, I get it now. Thanks to all of you for your quick replies! So, here's what I need to do: My Haskell code gets called by a higher level C function and asked to initialize itself. As part of that initialization, I'm expected to return a pointer to an instance of a particular data structure, which gets created/initialized in Haskell. I create a stable pointer to a data structure instance, using newStablePtr, and return that pointer to the calling C function. The same C function then, at a later time, calls a different function in my Haskell code, sending it that very same pointer, and expects that code to modify the data structure pointed to, in place. So, I wrote some code that looks like this: secondFunction :: StablePtr DataStructure - IO () secondFunction dsPtr = do ds - deRefStablePtr dsPtr theRef - newIORef ds writeIORef theRef newDs which, of course, didn't work, because I didn't understand the true nature of IORef. So, my question is: How do I do this? That is, how do I modify, in place, a data structure, which I originally created and made stable, using a pointer to that structure, which is being passed back to me, by the higher level C function that is calling me? You could use a StablePtr (IORef DataStructure). Thanks, all! -db On Fri, Jun 22, 2012 at 8:43 AM, Max Rabkin max.rab...@gmail.com wrote: On Fri, Jun 22, 2012 at 5:30 PM, Captain Freako capn.fre...@gmail.com wrote: 12 main = do 13 let theValue = 1 14 print theValue 15 theValueRef - newIORef theValue 16 bump theValueRef 17 return theValue theValue is a plain old immutable Haskell variable. newIORef creates an IORef whose initial value is equal to the argument; it doesn't create a pointer to the value or something like that. Change return theValue to readIORef theValueRef to extract the changed value in the IORef. --Max ___ 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] ANNOUNCE: uuid-1.2.6
Hi folks, I'm happy to announce a new point release of the uuid library, 1.2.6: http://hackage.haskell.org/package/uuid-1.2.6 The 'uuid' package implements most of RFC 4122[1] including random generation and generation based on hardware MAC addresses. I haven't announced a point-release in a while. The changes since 1.2.1 include: * When generating UUIDs from the hardware MAC address, if the MAC address is not available we now use a random seed for our (hidden, global) state machine * The 'Read' instance now drops leading spaces * Added the functions 'toWords' and 'fromWords', primary to support the package uuid-quasi[2]. Take care, Antoine 1: http://tools.ietf.org/html/rfc4122 2: http://hackage.haskell.org/package/uuid-quasi ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Troubles understanding Parsec Error Handling
On Wed, May 30, 2012 at 5:47 PM, Roman Cheplyaka r...@ro-che.info wrote: With this patch your code prints: parse error at (line 1, column 7): unexpected Hallofb, expecting one of [Hello,Hallo,Foo,HallofFame] Hi folks, Roman's patch has been included in the newly-released parsec 3.1.3: http://hackage.haskell.org/package/parsec-3.1.3 Enjoy, Antoine ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] GHC 7.4 and TypeSynonymInstances
On Fri, Apr 20, 2012 at 12:25 AM, Ivan Lazar Miljenovic ivan.miljeno...@gmail.com wrote: Has there been a change in the behaviour/requirement of TypeSynonymInstances as of GHC-7.4.1? (Not sure if this behaviour occurs with 7.2.1 as I don't have it installed) I had an instance for String for a class which ghc accepted whilst using FlexibleInstances; however, when trying to load it in 7.0.* it stated that TypeSynonymInstances was needed (which I forgot to add since it didn't seem to need it). Previously FlexibleInstances implied TypeSynonymInstances, I think? I can't find any documentation for the change or a bug report, so I could be mis-remembering. Antoine ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-beginners] GHC7.4.1 - LLVM -W64
On Tue, Jun 5, 2012 at 1:49 AM, Alexander.Vladislav.Popov alexander.vladislav.po...@gmail.com wrote: Hi Haskellers, I want to build 64-bit Windows application. Will 64-bit mingw and compilation via LLVM help me? Who will shed light on it and lead me through darkened forest of my search? If you're talking about using GHC to do this you might be better off asking on the GHC-Users list (which I've CC'd, so I guess you've already asked them!). I know that folks were spending time on making GHC work for Win-64, but I don't remember if it has shipped. Antoine ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: [Haskell-cafe] Re-exports of resourcet in conduit
Is it possible that you are puuling in two different versions of the package that defines the MonadThrow class? That is, package a was built against version 1, but package b was built against version 2? This would make GHC think the type-class were incompatable. This is just a guess - I have not tried what you are trying. On Jun 2, 2012 6:35 PM, Myles C. Maxfield myles.maxfi...@gmail.com wrote: To: Michael Snoyman CC: haskell-cafe Hello, I'm having a problem working with the conduit library, and was hoping you could help me out. Data.Conduit re-exports ResourceT, MonadResource, and MonadThrow (but not ExceptionT) from Control.Monad.Trans.Resource. I have a conduit which operates on a monad in the MonadThrow class. I am trying to figure out which MonadThrow class this should be (the Data.Conduit.MonadThrow class, or the Montrol.Monad.Trans.Resource.MonadThrow class, since apparently GHC doesn't recognize them as the same, even though one is just a re-export of the other). If a user of this conduit wants to chain this conduit up with something like sourceFile, the underlying monad has to be a member of Data.Conduit.MonadResource and whatever MonadThrow class I chose to use. I would like to be able to use an existing instance to lift the class of the inner monad to the class of the entire monad stack (so I don't have to tell the user of my conduit that they have to define their own instances), and the only rule that I can find that does that is the following from Data.Conduit: Data.Conduit.MonadThrow m = Data.Conduit.MonadThrow (Data.Conduit.ResourceT m) However, GHC doesn't seem to think that Control.Monad.Trans.Resource.ExceptionT is an instance of Data.Conduit.MonadThrow: No instance for (Data.Conduit.MonadThrow (ExceptionT IO)) arising from a use of `.' Control.Monad.Trans.Resource has a similar instance: Control.Monad.Trans.Resource.MonadThrow m = Control.Monad.Trans.Resource.MonadThrow (Control.Monad.Trans.Resource.ResourceT m) but because sourceFile operates in the Data.Conduit.MonadResource class, and Control.Monad.Trans.Resource.ResourceT isn't a member of that class (it's only a member of Control.Monad.Trans.Resource.MonadResource), that doesn't help: No instance for (Data.Conduit.MonadResource (Control.Monad.Trans.Resource.ResourceT (ExceptionT IO))) arising from a use of `.' It should be noted that neither module defines anything like the following: MonadResource m = MonadResource (ExceptionT m) It seems like the underlying problem here is that: 1) I am required to use the Control.Monad.Trans.Resource.ExceptionT class, because Data.Conduit doesn't re-export it 2) I am required to use the Data.Conduit.MonadResource class, because sourceFile and others require it 3) There doesn't seem to be an existing instance that bridges between the two. This seems like a fundamental flaw with re-exporting; it can only work if you re-export every single last thing from the original module. This doesn't seem tenable because the orignal module might not be under your control, so its author can add new symbols whenever he/she wants to. I see two solutions to this problem: 1) Re-export Control.Monad.Trans.Resource.ExceptionT in Data.Conduit. This will work until someone adds something to the resourcet package and someone wants to use the new addition and Data.Conduit.ResourceT in the same stack 2) Don't re-export anything in Data.Conduit; make sourceFile and others explicitly depend on types in another module, but this might break compatibility with existing programs if they use fully-qualified symbol names. 3) Make anyone who wants to use a monad stack in MonadThrow and MonadResource define their own instances. This is probably no good because it means that many different modules will implement the same instance in potentially many different ways. I feel like option 2) is probably the best solution here. I'm perfectly happy to issue a pull request for whichever option you think is best, but I don't know which solution you think is best for your project. What do you think? --Myles ___ 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] Troubles understanding Parsec Error Handling
On Wed, May 30, 2012 at 4:18 PM, Kevin Charter kchar...@gmail.com wrote: On Wed, May 30, 2012 at 3:11 PM, Kevin Charter kchar...@gmail.com wrote: What version of parsec 3 are you using? In version 3.1.1, I get (using Text.Parsec.String instead of Text.Parsec.Text): Ah, answered my own question. I gather you're using 3.1.2, since it's the first and so far only version with the Text.Parsec.Text module. We changed how 'try' handled errors in some cases in between 3.1.1 and 3.1.2. I'll take a look at this. Antoine Kevin -- Kevin Charter kevin.char...@acm.org ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Template Haskell antiquotation in user-defined quasiquoters
On Fri, May 25, 2012 at 2:51 PM, Sam Lindley sam.lind...@ed.ac.uk wrote: Template Haskell supports antiquotation for built-in quasiquotes, e.g.: [| \x - x + $([|3 * 4|]) |] However, as far as I can tell, there is no way of supporting antiquotation in user-defined quasiquoters, because the only way to specify a new quasiquoter is through a quoteExp function of type String - Q Exp. Of course, it is perfectly possible to write a parser for some fragment of Haskell inside your quoteExp function, but that seems crazy given that Template Haskell or rather GHC already implements a parser for the whole language. I know about Language.Haskell.Exts.Parser in haskell-src-exts, which provides parseExp :: String - ParseResult Exp, but that Exp is a different type to the one provided by Template Haskell.http://hackage.haskell.org/packages/archive/haskell-src-exts/1.9.0/doc/html/Language-Haskell-Exts-Syntax.html#t:Exp I'm also aware of Dominic Orchard's syntax-trees package, which supports converting between the two representations using a cunning hack that pretty-prints the haskell-src-exts representation to a string and uses Template Haskell to parse it back. Is there a saner way of simulating antiquotation in user-defined quasiquoters? Have you looked at: http://hackage.haskell.org/package/haskell-src-exts-qq http://hackage.haskell.org/package/haskell-src-meta The might help you pull something together. Antoine Sam -- The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Problem with packet documentation generated by cabal on windows 7
On Fri, May 25, 2012 at 6:28 PM, Nicu Ionita nicu.ion...@acons.at wrote: I have Haskell Platform 2011.2.0.1 and I assumed that haddock comes with it. Now I checked the version - it is 2.9.2 and cabal info tells me that the last version is 2.10.0 and that I don't have the package installed (?). Ok, now I see, haddock is that from the patform and I never install it with cabal... Also 'cabal' doesn't track executables, only libraries. Antoine ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Safe Haskell at the export symbol granularity?
On Thu, May 17, 2012 at 8:50 AM, Ryan Newton rrnew...@gmail.com wrote: Thanks David. I'm glad to see it was discussed in the wiki. (Btw, my 2 cents is that I like the comment pragmas more than new keywords.) The issue that I think doesn't make it into the wiki is of splitting, not modules, but type-classes. That's where I think it becomes a more serious issue. Do you think a symbol-level Safe Haskell would be able to distinguish one method of a type class as unsafe, while the others are safe? You can still do this at the module level, with the down-side of potentially not being able to implement a class with the safe version: module Unsafe where class MyClass a where safeOp :: a - Int - IO () unsafeOp :: a - Int - IO () instance MyClass A where ... module Safe (MyClass(safeOp)) where import Unsafe I think this works. Antoine ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Datapacker?
What is datapacker? Can you summarize the sort of problem you are having? On May 9, 2012 9:34 PM, sharon kimble boudic...@talktalk.net wrote: Is this the right place to ask questions about datapacker please? If not, can anyone tell me where is please? Thanks Sharon. -- A taste of linux = http://www.sharons.org.uk/taste/index.html efever = http://www.efever.blogspot.com/ efever = http://sharon04.livejournal.com/ Debian 6,0.4, Gnome 1:2.30+7, LibreOffice 3.4.6 Registered Linux user 334501 ___ 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] Datapacker?
On Wed, May 9, 2012 at 10:09 PM, sharon kimble boudic...@talktalk.net wrote: On Thursday 10 May 2012 04:01:56 you wrote: What is datapacker? Can you summarize the sort of problem you are having? https://github.com/jgoerzen/datapacker/wiki datapacker is a tool to group files by size. It is perhaps most often used to fit a set of files onto the minimum number of CDs or DVDs. I just want to check the syntax of the command before i commit it to stone for backing up my mp3s? You should probably ask the author - that link is a part of the author's personal github page. Here is some contact information: http://www.complete.org/JohnGoerzen Antoine Thanks Sharon. On May 9, 2012 9:34 PM, sharon kimble boudic...@talktalk.net wrote: Is this the right place to ask questions about datapacker please? If not, can anyone tell me where is please? Thanks Sharon. -- -- A taste of linux = http://www.sharons.org.uk/taste/index.html efever = http://www.efever.blogspot.com/ efever = http://sharon04.livejournal.com/ Debian 6,0.4, Gnome 1:2.30+7, LibreOffice 3.4.6 Registered Linux user 334501 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Uploading a new hsc2hs
On Wed, Apr 25, 2012 at 4:59 PM, Thomas DuBuisson thomas.dubuis...@gmail.com wrote: Warning: I, not the maintainer of hsc2hs, will be uploading a trivial fix for hsc2hs to hackage (new build deps). Even after public attempts to contact anyone in charge of hsc2hs (last January) there still has been no word. Speak now or forever hold your peace. I don't think I've ever installed hsc2hs from Hackage as it ships with GHC. It looks like the version on Hackage was last updated in 2006 ... I'm pretty sure there have been changes to hsc2hs since then. Antoine ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] prettyprint with IO
Hi Warren, On Thu, Apr 12, 2012 at 6:31 PM, Warren Harris warrensomeb...@gmail.com wrote: I wrote a parsec parser that does symbols lookups during the parsing process (ParsecT String Store IO a). Now I'd like to write a pretty printer that does the reverse. Unfortunately there doesn't appear to be a transformer version of Text.PrettyPrint.HughesPJ. Can anyone suggest a way to do this? Thanks, It seems like the opposite would be a function of type 'a - Store - IO Doc'. Maybe a function of type 'a - ReaderT Store IO Doc' could be easier to work with. If you go this route you could write a lifted versions of (), (+), hcat etc. An example: () :: Applicative m = m Doc - m Doc - m Doc I haven't tried any of this, so I'm not sure if you would get any big win over just using the first suggestion (a function of type 'a - Store - IO Doc') and using the stock combinators and threading the store around by hand. But do let me know if something works out. Antoine ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] using FlexibleInstances and OverlappingInstances
On Sat, Apr 7, 2012 at 12:08 PM, TP paratribulati...@free.fr wrote: Hello, In a module I am writing, I would like to use FlexibleInstances and OverlappingInstances. But I get errors, so I am trying to reproduce the problems on a smaller program: Is your actual issue with Showing a list? If so, you might be better off using the 'showList' member of the 'Show' typeclass: instance Show Foo where show x = ... showList xs = ... Then your 'showList' method will be called when 'show' is called on a list of 'Foo' values. The first error is because 'map show l' is the wrong type - mapping show over a list will give you a list of strings, but 'show' must return a string. I think you could use 'concatMap' here. Other than that the only advice I can give is that I try my hardest to avoid OverlappingInstances. Antoine Antoine {-# LANGUAGE FlexibleInstances, OverlappingInstances #-} data Foo = Foo Int deriving ( Show ) instance Show [Foo] where show [] = [0] show l = map show l main = do let l = [ Foo 1, Foo 2 ] print l The first error I obtain is: test_overlappinginstances.hs:7:19: Couldn't match expected type `Char' with actual type `[Char]' Expected type: a0 - Char Actual type: a0 - String In the first argument of `map', namely `show' In the expression: map show l Where does this Char come from? How to solve this problem? The second error is: test_overlappinginstances.hs:11:5: Overlapping instances for Show [Foo] arising from a use of `print' Matching instances: instance Show a = Show [a] -- Defined in GHC.Show instance [overlap ok] Show [Foo] -- Defined at test_overlappinginstances.hs:5:10-19 The overlap is ok (overlap ok does not appear if not using the pragma OverlappingInstances), so it should work? Thanks in advance, TP ___ 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 there a generic way to detect mzero?
On Mon, Mar 26, 2012 at 1:33 PM, Ting Lei tin...@hotmail.com wrote: Hi, I was writing a code trying to use MonadPlus to detect some error cases (representing missing values etc. in pure code). With the Maybe monad, I can do this: can0 :: (a - Maybe b) - a - Bool can0 f x = case f x of Nothing - False Just x - True And I got the expected result: *Main can0 (\x - Just x) 1 True But, when I try to generalize this using MonadPlus, as follows: can :: (MonadPlus m) = (a - m b) - a - Bool can f x = case f x of mzero - False _ - True I got a warning: __testError.hs:31:11: Warning: Pattern match(es) are overlapped In a case alternative: _ - ... Ok, modules loaded: Main. Well, you can sort of do it with only MonadPlus - but it really depends on your choice of Monad whether or not it does anything like what you want: can :: (MonadPlus m) = (a - m ()) - a - m Bool can f x = (f x return True) | return false For 'Maybe' this works great, but for something like 'List' I couldn't even tell you what it would do without reasoning through it. So you might be better off with the suggestion from Tobias using Eq Antoine ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Is there a generic way to detect mzero?
On Mon, Mar 26, 2012 at 4:25 PM, Ting Lei tin...@hotmail.com wrote: Hi Antoine and Tobias (and everyone else), Thanks a lot for your answers. They are really helpful Can you please show me how to use the (Eq m) constraint to do this? Also, my general question (probably novice-level) is that in monadic programming, you can convert not necessarily monadic codes into monadic ones. I know for many cases, it is impossible to do the reverse conversion, e.g. you can't make a function involving real IO operations into a pure code. In other cases, for example, I may need to using things like Nothing as the null value as in other programming languages, just to represent a special missing value outside the regular type. Is mzero a reasonable replacement for this or is there any reasonable (abstract) approximation in Haskell for doing this? (Like null, I need the ability to detect it.) I think using 'Maybe' (with Nothing) is perfect for this - this function should come in handy: http://hackage.haskell.org/packages/archive/base/latest/doc/html/Data-Maybe.html#v:isNothing Antoine ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Quickest way to pass Text to C code
On Wed, Mar 21, 2012 at 3:35 AM, Yves Parès yves.pa...@gmail.com wrote: Hello, I have to interact with a C++ library that accepts as string types (putting c++ strings aside) pointers of wchar_t (CWString in Haskell) or unsigned 32-bit int (Ptr Word32 for UTF-32 codepoints). I have read what text, bytestring and base provide, but Text can only be directly converted to (Ptr Word16), and if I use encodeUTF32 to get a ByteString, then I only get useAsCString, no direct conversion to CWString or Ptr WordXX is possible. A CString is a (Ptr CChar). You can then use castPtr to get whichever pointer type you need, if you believe the underlying buffer has the representation you want (in this case, UTF-32). It still won't be null-terminated, however. Antoine ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] cabal test-suite library recompilation
On Tue, Mar 13, 2012 at 11:16 AM, Ozgur Akgun ozgurak...@gmail.com wrote: While waiting for a build to finish [ :) ], I just wanted to write an email and check if this is intentional or only an oversight. Or maybe a technical limitation for the time being? If your library code and test code are in separate sub-directories and you reference your library as a package dependency for your test then Cabal won't re-build your library. That is, the 'Hs-source-disr' for the library and the test should not overlap. Otherwise GHC will compile the file-on-disk instead of grabbing the module from a package. Antoine ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Impact of try on Parsec performance
On Fri, Mar 2, 2012 at 10:35 PM, Erik de Castro Lopo mle...@mega-nerd.com wrote: Omari Norman wrote: So my question is: what is the practical impact of using try? My experience is based mostly on trying to improve the error location reporting in Ben Lippmeier's DDC compiler. What I found was that removing Parsec.try's almost always resulted in the parser generating better location information. Roman Cheplyaka made some tweaks to 'try' error reporting in parsec 3.1.2, so this might be different now. Antoine ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Impact of try on Parsec performance
On Fri, Mar 2, 2012 at 10:30 PM, Omari Norman om...@smileystation.com wrote: The Parsec documentation says that Parsec performs best on predictive grammars, and Parsec does not backtrack by default to improve performance (though this also improves error messages). A big thing that parsec strives to do is to forget consumed portions of the input as quickly as possible, allowing it to be collected. Using 'try' forces the program to hold on to input for longer than would be required if the grammar were factored to avoid 'try'. The Parsec documentation says there is a penalty for using try and suggests left-factoring grammars when possible. Real World Haskell says that excessive use of try can degrade Parsec performance quite significantly. On the other hand, some of the combinators provided with Parsec, such as notFollowedBy, use try. The assumption is that 'notFollowedBy' is primarily used with 'short' parsers, which means the amount of input we need to preserve is less (also, I think using 'try' is the only way to implement 'notFollowedBy'). So my question is: what is the practical impact of using try? I ask because as a novice I have a simple grammar that could, perhaps, be factored to avoid use of try, but it's quite a brain puzzle for me and I wonder if it would ever be worth it. Does it matter how many characters try would have to store, or how often it would run? I guess you could test running a parser which always fails without consuming input both underneath a 'try' and not, to see what non-storage overhead 'try' has. I'm guessing the overhead would be minimal, but I have not measured it. Antoine ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: Help me grok addFinalizer
On Thu, Feb 16, 2012 at 2:04 PM, Michael Craig mks...@gmail.com wrote: When I read the docs for System.Mem.Weak, it all seems to make sense. But then this code doesn't run as I expect it to when I turn on -threaded: http://hpaste.org/63832 (Expected/actual output are listed in the paste.) I've tried this on 7.4.1 and 7.0.4 with the same results. Can someone enlighten me? First off, I'm pretty sure finalizers won't run until the data they were associated with has been GCd, and GHC doesn't do GCs unless there is allocation - threadDelay doesn't allocate much, I imagine. Also, from the docs: A weak pointer may also have a finalizer of type IO (); if it does, then the finalizer will be run at most once, at a time after the key has become unreachable by the program (dead). The storage manager attempts to run the finalizer(s) for an object soon after the object dies, but promptness is not guaranteed. It is not guaranteed that a finalizer will eventually run, and no attempt is made to run outstanding finalizers when the program exits. Therefore finalizers should not be relied on to clean up resources - other methods (eg. exception handlers) should be employed, possibly in addition to finalisers. Antoine ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: [Haskell-cafe] Compressed Data.Map for more efficient RAM usage?
On Thu, Feb 16, 2012 at 3:51 PM, Jeremy Shaw jer...@n-heptane.com wrote: Sometimes we want to store very large collection types in RAM -- such as a Data.Map or Data.IxSet. It seems like we could trade-off some speed for space savings by compressing the values in RAM. Lemmih has previously created compact-map: http://hackage.haskell.org/package/compact-map which mightybyte used to create: https://github.com/mightybyte/compact-ixset compact-map converts the Haskell values to a more compact binary representation. But could we do even better by compressing the bytestrings? Here is a useless implementation: http://hpaste.org/63836 You could have a re-implemented HashMap which would un-pack the payload's ByteString constructor into the leaves of the HashMap type itself. Then you would save on both the keys and the values. This assumes you're not using the ordering provided by Data.Map. Antoine ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Compressed Data.Map for more efficient RAM usage?
On Thu, Feb 16, 2012 at 4:29 PM, Johan Tibell johan.tib...@gmail.com wrote: On Thu, Feb 16, 2012 at 2:03 PM, Antoine Latter aslat...@gmail.com wrote: You could have a re-implemented HashMap which would un-pack the payload's ByteString constructor into the leaves of the HashMap type itself. Then you would save on both the keys and the values. Hah hah - forget what I said. HashMap may be smaller in terms of the structure of the tree it builds, but it can't be smaller in the size of its keys since the hash is lossy :-/ Note that ByteString has a high per-value overhead due to the internal use of ForeignPtrs and indicies that track offset/size: http://blog.johantibell.com/2011/06/memory-footprints-of-some-common-data.html You could store just the raw GHC ByteArray, which drops the indices. You could then promote to a ByteString to call into standard deserialization libraries. I don't know at what point we descend too far into voodoo-magic. -- Johan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Haskell-Cafe Tag (was: Optimizations and parallel execution in the IO for a small spellchecker)
On Wed, Feb 15, 2012 at 1:49 PM, JP Moresmau jpmores...@gmail.com wrote: I was not aware that it was something a poster was supposed to do, but now I notice that while the messages I get from the list have [Haskell-Cafe] on their subject, the ones I post don't. The Haskell-Cafe info page (http://www.haskell.org/mailman/listinfo/haskell-cafe) does not mention that you should have that tag in the subject. I'm probably a uncouth Frenchman knowing nothing about netiquette, but surely the list software could add such a tag if it was required? The tag appears to be added automatically by the mailing-list software that haskell-cafe runs on. I see it on threads that you have started, so there is no problem with your emails. If you add it manually, it looks like the software won't double-add it. Antoine ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] [haskell-cafe] Some reflections on Haskell
On Tue, Feb 14, 2012 at 9:13 AM, Doug McIlroy d...@cs.dartmouth.edu wrote: Nevertheless, I share Jardine's concern about the central problem. It is hard to find one's way in this ecosystem. It needn't be, as Java illustrates. To my mind Java's great contribution to the world is its library index--light years ahead of typical documentation one finds at haskell.org, which lacks the guiding hand of a flesh-and-blood librarian. In this matter, it seems, industrial curation can achieve clarity more easily than open source. Hi Doug, I'm not really familiar with the Java ecosystem - most of my experience has involved a couple Apache projects, which had decent wikis next to really terrible raw API documentation (with links from the wikis into the raw API documentation as if it were a useful thing). But I assume my experience isn't typical - I'm not a Java dev. Do you have any links to examples that we should imitate? Or a summary of how it works over there? Thanks, Antoine ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Building a Haskell project which depends on an old version of base
On Tue, Feb 14, 2012 at 3:53 PM, Rogan Creswick cresw...@gmail.com wrote: On Tue, Feb 14, 2012 at 12:14 PM, Steven J. Murdoch steven.murd...@cl.cam.ac.uk wrote: $ ghc-pkg list base /Users/ghc6/homebrew/Cellar/ghc/6.12.3/lib/ghc/package.conf.d base-3.0.3.2 base-4.2.0.2 I'm a bit fuzzy on the details when it comes to the core packages that are distributed with ghc, but my understanding is that the compiler is /very/ needy about which base it can use. As far as I know, the only way to change versions of Base is by changing the compiler to the version that uses the desired base. With that in mind, having two base libraries installed in the same package database seems like a recipe for disaster. GHC 6.12.1 shipped with two versions of base, so this is okay in this case. But I really don't know if we export two different versions of GHC.* from the different versions of base. Antoine ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Hackage 2 maintainership
On Mon, Feb 13, 2012 at 5:44 PM, Ben Gamari bgamari.f...@gmail.com wrote: Hey all, Those of you who follow the Haskell subreddit no doubt saw today's post regarding the status of Hackage 2. As has been said many times in the past, the primary blocker at this point to the adoption of Hackage 2 appears to be the lack of an administrator. It seems to me this is a poor reason for this effort to be held up. Having taken a bit of time to consider, I would be willing to put in some effort to get things moving and would be willing to maintain the haskell.org Hackage 2.0 instance going forward if necessary. I currently have a running installation on my personal machine and things seem to be working as they should. On the whole, installation was quite trivial, so it seems likely that the project is indeed at a point where it can take real use (although a logout option in the web interface would make testing a bit easier). One thing that made testing hard for me last time was that existing 'cabal install' client treats the server hackage.haskell.org different from any other server you put in your config files, so simulating the effect of a cutover on existing users can be tricky. If you don't know what I'm talking about I can look it up. I had a hacked 'cabal' client at one point, and I could probably re-create the patches. Antoine ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Hackage 2 maintainership
On Mon, Feb 13, 2012 at 10:17 PM, Antoine Latter aslat...@gmail.com wrote: On Mon, Feb 13, 2012 at 5:44 PM, Ben Gamari bgamari.f...@gmail.com wrote: Hey all, Those of you who follow the Haskell subreddit no doubt saw today's post regarding the status of Hackage 2. As has been said many times in the past, the primary blocker at this point to the adoption of Hackage 2 appears to be the lack of an administrator. It seems to me this is a poor reason for this effort to be held up. Having taken a bit of time to consider, I would be willing to put in some effort to get things moving and would be willing to maintain the haskell.org Hackage 2.0 instance going forward if necessary. I currently have a running installation on my personal machine and things seem to be working as they should. On the whole, installation was quite trivial, so it seems likely that the project is indeed at a point where it can take real use (although a logout option in the web interface would make testing a bit easier). One thing that made testing hard for me last time was that existing 'cabal install' client treats the server hackage.haskell.org different from any other server you put in your config files, so simulating the effect of a cutover on existing users can be tricky. Oh, and it isn't absolutely terrible - it only affects the 'upload' command, I think (and the upload + check). If you don't know what I'm talking about I can look it up. I had a hacked 'cabal' client at one point, and I could probably re-create the patches. Antoine ___ 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 Sun, Feb 12, 2012 at 8:18 AM, Yves Parès yves.pa...@gmail.com wrote: Hello, 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. But they provide functions to be casted to/from regular void*'s. Does that mean if for instance you have a StablePtr CInt you can cast it to Ptr () and alter it on C-side? void alter(void* data) { int* x = (int*)data; *x = 42; } -- -- using 'unsafe' doesn't change anything. foreign import ccall safe alter alter :: Ptr () - IO () main = do sptr - newStablePtr (0 :: CInt) deRefStablePtr sptr = print alter (castStablePtrToPtr sptr) -- SEGFAULTS! deRefStablePtr sptr = print freeStablePtr sptr But I tried it, and it doesn't work: I got a segfault when 'alter' is called. I think that 'castStablePtrToPtr' exists because many C APIs use 'void*' to mean 'opaque lump of data', and these exist to conform to that sort of API. Antoine ___ 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 Sun, Feb 12, 2012 at 3:09 PM, Yves Parès yves.pa...@gmail.com wrote: But then, In use case 1), how can a Haskell function modify the data addressed? http://hackage.haskell.org/packages/archive/base/latest/doc/html/Foreign-StablePtr.html#v:deRefStablePtr Antoine ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Happstack-state in non-happstack production apps
On Fri, Feb 10, 2012 at 3:56 PM, Tom Murphy amin...@gmail.com wrote: Hi, Is it common to use happstack-state without happstack for real-world code (web or otherwise)? The package 'acid-state' is considered the successor to happstack-state, and it doesn't include 'happstack' in it's name to advertise that it is quite usable outside of happstack. I don't have a list of who does, though. http://hackage.haskell.org/package/acid-state Antoine ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Contributing to http-conduit
On Tue, Feb 7, 2012 at 10:28 PM, Myles C. Maxfield myles.maxfi...@gmail.com wrote: I have been looking around at possibly making a Browser module for Network.HTTP.Conduit on top of Control.Monad.State. I came across this roadbump: In order to implement redirection following, client code must call 'http' with a redirection count of 0. If there is a redirect, 'http' will throw an exception. In order to catch this exception and continue on with the redirection chain, the 'catch' function must be called. The problem is that the 'catch' function has a type of (catch :: Exception e = IO a - (e - IO a) - IO a) which means that it can only be used in the IO monad. A call to 'http' inside the first argument of 'catch' must be wrapped in a 'runResourceT' Does this help? http://hackage.haskell.org/packages/archive/lifted-base/0.1.0.3/doc/html/Control-Exception-Lifted.html It should handle part of your problem, at least. Antoine ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] The State of Testing?
On Thu, Feb 2, 2012 at 4:30 PM, Michael Craig mks...@gmail.com wrote: I've been picking up Haskell as a side project for the last few months, and I'm now considering publishing some useful code I've written and reused in several small projects. So far I've done relatively little with testing (these have been non-mission-critical applications) but I feel I should get my act together before pushing my work into the common ecosystem. I'm comfortable writing tests in QuickCheck and HUnit and bundling them as optional executables with cabal, but I understand there's a better way. Specifically, I'm looking at the test-framework package and cabal's (newish) test-suite sections. Are these two used together or each to the exclusion of the other? Is there something else I should be using? I use Cabal's test-suite support to make building and running a test executable easy, and I use test-framework to write my 'main' method and provide nice output to the user. They have worked well together for me. Antoine ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] [Haskell] ANNOUNCE multiarg - parser combinators for command line parsing
On Mon, Jan 30, 2012 at 8:19 AM, Henning Thielemann lemm...@henning-thielemann.de wrote: On Sun, 29 Jan 2012, Simon Meier wrote: I'm currently using Neil Mitchell's cmdargs package [1]. How does your package compare to that? Last time I checked cmdargs it was not referential transparent. Is multiarg better in this respect? It has since been re-architectured as an impure library around a pure core library: http://hackage.haskell.org/packages/archive/cmdargs/0.9.2/doc/html/System-Console-CmdArgs-Explicit.html ___ 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] help with safecopy + acid-state
On Tue, Jan 31, 2012 at 8:27 AM, Johannes Waldmann waldm...@imn.htwk-leipzig.de wrote: Can I really rename old.T = new.T_orig ? It looks as if then tries to load the wrong acid-state snapshot. The name of your data type doesn't matter as acid-state doesn't store that on the disk. I think it does - because file names are state/T/*.log and so on? The function 'openLocalState' in AcidState uses the name of the passed in state type to locate the log files on disk. So as long as you always call 'openLocalState' with types of the same name to represent the same state you'll be fine - this is why it is safe to rename your old type, because you call 'openLocalState' with the new type. Alternatively, you can call 'openLocalStateFrom', which doesn't base anything on names of types (you can tell because there is no 'Typeable' constraint on its arguments). Antoine J.W. ___ 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] C++ Parser?
On Tue, Jan 24, 2012 at 4:06 AM, Christopher Brown cm...@st-andrews.ac.uk wrote: Hi, I have stumbled across language-c on hackage and I was wondering if anyone is aware if there exists a full C++ parser written in Haskell? I'm not aware of one. When it comes to parsing C++, I've always been a fan of this essay: http://www.nobugs.org/developer/parsingcpp/ It's a hobbyist's tale of looking into parsing C++ and then an explanation of why he gave up. It's older, so perhaps the state-of-the-art has advanced since then. Antoine ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] In-memory Handle for testing
On Fri, Jan 20, 2012 at 5:53 AM, Simon Hengel s...@typeful.net wrote: For testing I want to stub handles, performing all reads and writes in memory (and in process, so no mmap). From looking at the documentation of mkFileHandle[1], I think this should be possible. But it requires some work. Is there already something out there? John Miliken has one on Hackage: http://hackage.haskell.org/package/knob I had a read-only version that I used for testing things a ways back: http://hackage.haskell.org/trac/ghc/attachment/ticket/4144/ByteStringHandle.hs There might still be some things in GHC.IO.Handle that assume FD handles - I haven't tried it in a while. Antoine ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: strange behavior of let in ghci
On Thu, Jan 19, 2012 at 10:55 PM, Kazu Yamamoto k...@iij.ad.jp wrote: Hello, I met strange behavior of let in ghci 7.0.4. The following works well. You're running into the monomorphism restriction: http://www.haskell.org/haskellwiki/Monomorphism_restriction let chooseMax = maximumBy compFst If you re-define this to be: let chooseMax x = maximumBy compFst x you'll get around it in the easiest way. You can also turn off the restriction at the command-line with the argument '-XNoMonomorphismRestriction', I think. Antoine ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: [Haskell-cafe] Not an isomorphism, but what to call it?
On Thu, Jan 19, 2012 at 3:24 PM, Sean Leather leat...@cs.uu.nl wrote: I have two types A and B, and I want to express that the composition of two functions f :: B - A and g :: A - B gives me the identity idA = f . g :: A - A. I don't need g . f :: B - B to be the identity on B, so I want a weaker statement than isomorphism. I understand that: (1) If I look at it from the perspective of f, then g is the right inverse or section (or split monomorphism). (2) If I look at from g, then f is the left inverse or retraction (or split epimorphism). But I just want two functions that give me an identity on one of the two types and I don't care which function's perspective I'm looking at it from. Is there a word for that? I don't think it makes sense to say you want one label for the situation when looking from either end - the relation you're labeling is non-symmetric. Regards, Sean ___ 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] ANNOUNCE: quickcheck-instances
Hello! I'd like to announce the first release of the quickcheck-instances package, which aims to consolidate commonly needed class instances for use with QuickCheck. These instances are appropriate when your tests don't have strong requirements on the nature of the input data - for example, if you are testing a network-protocol parser, the ByteString instance provided in this package might not be what you want to use. Other limitations: * I do not have full coverage of the Haskell Platform - I have been adding instances as I need them. Patches are warmly welcomed, however. * I only have instances of the 'Arbitrary' class, however I would be happy to accept patches for instances of CoArbitrary and other classes that would be useful in quickcheck-based testing. On Hackage: http://hackage.haskell.org/package/quickcheck-instances Ordinarily I frown on orphaned instances in library packages, but the fact that quickcheck properties should never appear in a library Cabal package, most of the downsides of orphans are mitigated. Thanks, Antoine ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
Re: [Haskell-cafe] STM: nested atomically error
On Thu, Jan 12, 2012 at 6:48 AM, Johan Brinch brin...@gmail.com wrote: Hi all, I'm seeing the Control.Concurrent.STM.atomically was nested error, but I just can't figure out what's happening. I'm not using any unsafe IO (only for debug printing), and the test program is only running one thread. Where is a transaction being nested? What are the scenarios where this error is reported? Where is 'evalCacheSTM' defined? The behaviour is consistent on GHC 7.4.0 RC and GHC 7.2.2 (stable). That function that's being run can be found here: https://gist.github.com/30b94760abc27b05ec7c And here is the last output from the runtime system: https://gist.github.com/4356ae541895becb4169 Any ideas to track this down will be greatly appreciated! -- Johan Brinch, Dept. of Computer Science, University of Copenhagen ___ 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] ANNOUNCE: quickcheck-instances
Hello! I'd like to announce the first release of the quickcheck-instances package, which aims to consolidate commonly needed class instances for use with QuickCheck. These instances are appropriate when your tests don't have strong requirements on the nature of the input data - for example, if you are testing a network-protocol parser, the ByteString instance provided in this package might not be what you want to use. Other limitations: * I do not have full coverage of the Haskell Platform - I have been adding instances as I need them. Patches are warmly welcomed, however. * I only have instances of the 'Arbitrary' class, however I would be happy to accept patches for instances of CoArbitrary and other classes that would be useful in quickcheck-based testing. On Hackage: http://hackage.haskell.org/package/quickcheck-instances Ordinarily I frown on orphaned instances in library packages, but the fact that quickcheck properties should never appear in a library Cabal package, most of the downsides of orphans are mitigated. Thanks, Antoine ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] When will constraint kinds roll out?
On Tue, Jan 10, 2012 at 1:04 PM, Nicholas Tung nt...@ntung.com wrote: Just a quick, logistical question: I see constraint kinds didn't make it to GHC 7.2.2; does anyone have guesses when the extension will roll out in an official release? Our research team is interested in using Haskell for an EDSL, and having both constraint kinds and access to all of the libraries on Hackage would be optimal. (I've been writing an EDSL with monad transformers and the rmonad package myself, but think it is too difficult and cumbersome if we are to use Haskell EDSL approaches more broadly). Constraint kinds are in the release branch for the upcoming 7.4 release, and were in the build of 7.4.1 RC 1 that went out a bit ago: http://www.haskell.org/pipermail/glasgow-haskell-users/2011-December/021310.html I'm not on the GHC team, but from what I've seen new features like this generally don't get added in point releases (something like from 7.1.1 to 7.2.2). Antoine Thanks in advance, Nicholas — https://ntung.com — 4432-nstung ___ 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: ConstraintKinds and default associated empty constraints
On Sun, Jan 8, 2012 at 11:21 PM, wren ng thornton w...@freegeek.org wrote: Couldn't the following work? class Functor f where type C f :: * - Constraint type C f _ = () I get a parse error from that. The equivalent: class Functor f where type FC f :: * - Constraint type FC f a = () gives the error: Number of parameters must match family declaration; expected 1 In the type synonym instance default declaration for `FC' In the class declaration for `Functor' It seems to me that adding const to the type level (either implicitly or explicitly) is cleaner and simpler than overloading () to be Constraint, *-Constraint, *-*-Constraint,... -- Live well, ~wren ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: ConstraintKinds and default associated empty constraints
On Mon, Jan 9, 2012 at 12:30 AM, Antoine Latter aslat...@gmail.com wrote: On Sun, Jan 8, 2012 at 11:21 PM, wren ng thornton w...@freegeek.org wrote: Couldn't the following work? class Functor f where type C f :: * - Constraint type C f _ = () I get a parse error from that. The equivalent: class Functor f where type FC f :: * - Constraint type FC f a = () The definitions are accepted by GHC: class Functor f where type FC f a :: Constraint type FC f a = () fmap :: (FC f a, FC f b) = (a - b) - f a - f b instance Functor [] where fmap = map But I don't like the 'a' being an index parameter, and then the following expression: fmap (+1) [1::Int] Gives the error: Could not deduce (FC [] Int) arising from a use of `fmap' In the expression: fmap (+ 1) [1 :: Int] In an equation for `it': it = fmap (+ 1) [1 :: Int] gives the error: Number of parameters must match family declaration; expected 1 In the type synonym instance default declaration for `FC' In the class declaration for `Functor' It seems to me that adding const to the type level (either implicitly or explicitly) is cleaner and simpler than overloading () to be Constraint, *-Constraint, *-*-Constraint,... -- Live well, ~wren ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: [Haskell-cafe] too many open files using snap
2012/1/8 Eric Wong wsy...@gmail.com: I run both of these commands and found out that there're sockets leaking. Most of them are TCP connections in CLOSE_WAIT state. There're also some socket with can't identify protocol. So, What's the problem? Is it related to the timeout in the server config? I'm using the default value. Since they're sockets, it could be either the database connections or the HTTP connections, right? Is there some way you can insert a fake database layer to see if that makes your problem go away, to try and isolate the problem? Antoine 在 2012-1-8,下午10:56, Brandon Allbery 写道: On Sun, Jan 8, 2012 at 09:50, Felipe Almeida Lessa felipe.le...@gmail.com wrote: If you're on Linux, then you may $ ls -lah /proc/PID/fd to see where these open files are pointing to. And on other systems lsof can determine this information. $ lsof -p PID -- brandon s allbery allber...@gmail.com wandering unix systems administrator (available) (412) 475-9364 vm/sms ___ 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] [web-devel] [ANNOUNCE] First release of crypto-conduit
On Sat, Jan 7, 2012 at 10:12 PM, Aristid Breitkreuz arist...@googlemail.com wrote: 2012/1/8 Vincent Hanquez t...@snarc.org: What would you prefer ? At the moment, i'm inclined to someday move cryptohash apis to be similar to crypto-api. i.e. from a result type being a bytestring to an opaque type with serialize/show instance. Why? I don't actually need the hash object for anything, usually. All I need is the ByteString, and then I need to learn how to use the cereal package to get it... So talking purely about convenience, I would prefer hash :: HashType - InputData - ByteString. That would probably not be extensible enough, so I'm not sure how to optimally do it. You could use 'hash :: Hash h = Proxy h - ByteString - ByteString'. where 'data Proxy a = Proxy'. Defined for you in the 'tagged' package. Antoine ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] [web-devel] [ANNOUNCE] First release of crypto-conduit
On Sun, Jan 8, 2012 at 12:39 AM, Thomas DuBuisson thomas.dubuis...@gmail.com wrote: Why? I don't actually need the hash object for anything, usually. All I need is the ByteString, and then I need to learn how to use the cereal package to get it... What would you think if Crypto.Classes exported Data.Serialize.encode? This suggestion is probably a win even if you do nothing else. Or how about if it exported Antoine's hash suggestion (under a different name)? Cheers, Thomas ___ 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] Package for QuickCheck instances
Hi Haskell, I was writing some tests that involved a large number of quickcheck properties which don't ship with the library itself, so I thought I would package them all together and put the orphan instances on Hackage. Here's what I have so far: https://github.com/aslatter/qc-instances/tree/93a87fa06b5575ddcc12c2f9eb0f4672c6f9a317 The policy would be to allow anything into to package which is a part of the Haskell Platform or is a GHC build library. Has anyone already done this? I didn't find anything from grepping the Hackage package list. Has anyone already talked about doing this sort of thing? Are their any non-obvious pitfalls (aside from the package eventually becoming a cesspool of CPP conditions)? Thanks, Antoine ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] haxr standalone server?
On Thu, Jan 5, 2012 at 9:40 AM, Johannes Waldmann waldm...@imn.htwk-leipzig.de wrote: How could I use haxr (http://www.haskell.org/haskellwiki/HaXR) to build a stateful server? It should listen on some port, and fork threads (inside Haskell land) to handle incoming calls. Any of the Haskell web frameworks can do this? I guess this is the same question as: http://www.haskell.org/pipermail/haskell-cafe/2009-December/071185.html Pretty much any of the Haskell web frameworks listen on a port, accept HTTP requests and fork a new GHC thread into a handler. I'm more familiar with the Happstack/Snap approach to writing handlers (although the Snap approach is evolving away from Happstack), and a lot of people have good luck with Yesod. Happstack crash course: http://happstack.com/docs/crashcourse/index.html Snap quickstart: http://snapframework.com/docs/quickstart Installing and starting yesod in five minutes: http://www.yesodweb.com/page/five-minutes In particular, I know that the folks working on yesod have spent a lot of time on documentation. Antoine Thanks - J.W. ___ 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] [Haskell-beginners] WinRT and Haskell
On Thu, Jan 5, 2012 at 9:55 AM, AbdulSattar Mohammed codingta...@gmail.com wrote: WinRT has a concept of projections that expose its API. Microsoft has implemented projections for Native (C and C++), HTML/Javascript and .NET (from Miguel de Caza's WinRT demystified post: http://tirania.org/blog/archive/2011/Sep-15.html). There's no mention of creating your own projections (or I have seen none). I don't see any reason why we can't create our own projections. If it's possible a Haskell projection could really help. Yep, that's what I was thinking of. I'm pretty sure the C/C++ projections rely on compiler extensions for the MS C/C++ compiler, so I don't think we could use those directly from Haskell. Antoine On Thu, Jan 5, 2012 at 8:11 PM, Antoine Latter aslat...@gmail.com wrote: On Thu, Jan 5, 2012 at 5:12 AM, AbdulSattar Mohammed codingta...@gmail.com wrote: I suppose this should go into the GUI mailing list, but it is filled with spam. So, WinRT does not depend on the .NET Framework. C++ applications can directly compile to x86 and be able to use WinRT. Do we have a room for Haskell development there? From what I understand, WinRT is a set of COM libraries - C++ can directly compile to it because the MS C++ compiler has special extensions to handle the COM resources in the library. There is a COM library for Haskell: http://hackage.haskell.org/package/com But I've never used it. The API is encoded in a special meta-data format, which is then used by C++, .NET and Javascript to create the language-specific APIs - it might be possible to generate Haskell bindings to the COM components from this metadata. Antoine -- Warm Regards, AbdulSattar Mohammed ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] (no subject)
On Thu, Jan 5, 2012 at 10:54 AM, Christoph Breitkopf chbreitk...@googlemail.com wrote: Hello, I'm trying to figure out how to handle versioning of my IntervalMap package. I've just read the package versioning policy: http://www.haskell.org/haskellwiki/Package_versioning_policy I don't quite understand all the recommendations in the above document, though: a) You are not allowed to remove or change the types of existing stuff. Ok. b) You are allowed to add new functions. But that can break compilation because of name conflicts. Seems to be allowed on the grounds that this is easy to fix in the client code. This will never break clients who are using qualified imports, or only importing the symbols they use, which is strongly recommended behavior. c) You are not allowed to add new instances. I don't get this - how is this any worse than b)? Unlike adding functions, there is no way for a client of your library to control which instances they import. Antoine I do understand that it is not generally possible to prevent breaking code - for example if the client code depends on buggy behavior that gets fixed in a minor version update. That seems unavoidable - after all, bugfixes are _the_ reason for minor updates. Regards, Chris ___ 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] Sudden monomorphism with -XTypeFamilies
On Thu, Jan 5, 2012 at 3:32 PM, Rian Hunter r...@thelig.ht wrote: hello i'm getting inconsistent monomorphism behavior with the same code only depending on whether or not -XTypeFamilies is enabled: Which version of GHC are you using? Starting with GHC 7.0, the TypeFamilies extension implies the MonoLocalBinds language feature, which looks like what you're running into. Here's a blog post from the GHC folks about it: http://hackage.haskell.org/trac/ghc/blog/LetGeneralisationInGhc7 Antoine {-# LANGUAGE TypeFamilies #-} snda :: a - b - b snda ba = id main = do let ma = (return () :: IO ()) mBox bb = snda ma bb mBox $ return (4 :: Int) mBox $ return G return () in the preceding example, if -XTypeFamilies is enabled then mBox is monomorphic and the program will terminate early, otherwise, it's polymorphic and the program will complete successfully. i think i understand why this is the case but i couldn't find documentation on this inconsistency anywhere. is this expected behavior or is this a bug in GHC? thanks! rian ___ 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] Solved but strange error in type inference
On Wed, Jan 4, 2012 at 9:08 AM, Thiago Negri evoh...@gmail.com wrote: Do not compile: f :: a - a f x = x :: a Couldn't match type `a' with `a1' `a' is a rigid type variable bound by the type signature for f :: a - a at C:\teste.hs:4:1 `a1' is a rigid type variable bound by an expression type signature: a1 at C:\teste.hs:4:7 In the expression: x :: a In an equation for `f': f x = x :: a Any of these compiles: f :: a - a f x = undefined :: a Re-written: f :: forall a . a - a f x = undefined :: forall a . a Renaming variables to avoid shadowing: f :: forall a . a - a f x = undefined :: forall b . b Which is allowed. The rest of your examples are similar - a new value is introduced with a new type that can unify with the required type. This is different from the failing case: g :: a - a g x = x :: a Let's go through the same process. Insert foralls: g :: forall a . a - a g x = x :: forall a . a Rename shadowed variables: g :: forall a . a - a g x = x :: forall b . b In the function body we have declared that the value 'x' may take on any value. But that's not true! The value 'x' comes from the input to the function, which is a fixed 'a' decided by the caller. So it does not type-check. Antoine f :: Num a = a - a f x = undefined :: a f :: Int - Int f x = undefined :: a f :: Int - Int f x = 3 :: (Num a = a) Can someone explain case by case? Thanks, Thiago. 2012/1/4 Yves Parès limestr...@gmail.com: I don't see the point in universally quantifying over types which are already present in the environment I think it reduces the indeterminacy you come across when you read your program (where does this type variable come from, btw?) So is there anyway to force the scoping of variables, so that f :: a - a f x = x :: a becomes valid? You mean either than compiling with ScopedTypeVariables and adding the explicit forall a. on f? I don't think. 2012/1/4 Brandon Allbery allber...@gmail.com On Wed, Jan 4, 2012 at 08:41, Yves Parès limestr...@gmail.com wrote: Would you try: f :: a - a f x = undefined :: a And tell me if it works? IMO it doesn't. It won't Apparently, Yucheng says it does. ___ 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] Windows: openFile gives permission denied whenfilein use
On Thu, Dec 29, 2011 at 11:49 AM, Donn Cave d...@avvanta.com wrote: Quoth Antoine Latter aslat...@gmail.com, ... http://www.haskell.org/pipermail/libraries/2011-October/016978.html ... wherein Ian Lynagh proposed to remove this feature and let the programmer enforce locking or not, as in other programming languages' base I/O libraries. This met with enthusiastic universal support, so whatever the Report may say, it looks to me like the GHC libraries will eventually not do this. Wouldn't this lead to 'getContents' and friends being much less safe than they already are? Or would we have to do something at the GHC runtime level of things to add locking? Interesting question. I tend to steer clear of that function, rather than try to keep track of all the things that can go wrong with it! but I would guess, the effect is the same on any I/O strategy that executes the same way: e.g. if you were to read pieces of the file iteratively you would be similarly exposed to the possibility of concurrent modifications. That risk may be less obvious with getContents if you take the naive view that it returns the contents of the file in the same way that normal I/O operations return data, but then you will eventually be punished for that naivety anyway! Are you aware of some possible special issue with getContents? Well, the issue would more be with 'hGetContents'. Would this program then loop: append fromFilePath toFilePath = do str - readFile fromFile writeFile toFile str if 'from' and 'to' where the same file? Currently the locking prevents this. Antoine ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] On the purity of Haskell
On Thu, Dec 29, 2011 at 11:14 AM, Gregg Reynolds d...@mobileink.com wrote: On Dec 29, 2011, at 11:01 AM, Iustin Pop wrote: And to clarify better my original email: yes, (bar x) always gives you back the same IO action; More precisely: the same *type*. I'm confused - what do you mean by type? I don't think that Iustin's statement needs any sort of qualifier - (bar x) always returns the same IO action when called with the same value for x, no matter how many times you call it. Antoine ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Windows: openFile gives permission deniedwhenfilein use
On Thu, Dec 29, 2011 at 12:28 PM, Donn Cave d...@avvanta.com wrote: Quoth Antoine Latter aslat...@gmail.com, ... Would this program then loop: append fromFilePath toFilePath = do str - readFile fromFile writeFile toFile str if 'from' and 'to' where the same file? Currently the locking prevents this. Do you mean, locking makes that work, or just makes it fail in a different way? Anyway, I think that's an example that would have the same issues without hGetContents - that is, any way you set out to overwrite a file by modifying its contents, you have the same problem. Locking makes this fail with an exception, I think. Not locking would make this mis-behave. And lets pretend I wrote the function that was in my head: append fromFilePath toFilePath = do str - readFile fromFile appendFile toFile str Here, without locking, I would expect to fill my disk up, whereas previously my program would have crashed before writing out any data. Maybe these are pathological examples, but they are (I think!) the justification for having the locking in the first place. Antoine ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Windows: openFile gives permission denied whenfile in use
On Thu, Dec 29, 2011 at 10:53 AM, Donn Cave d...@avvanta.com wrote: Quoth Andrew Coppin andrewcop...@btinternet.com, On 29/12/2011 04:29 AM, Antoine Latter wrote: ... This bug and its discussion is similar, but not identical: http://hackage.haskell.org/trac/ghc/ticket/4363 This one has been rumbling on for ages. As others have said, the Report demands that locking occur, which is probably a mistake. The rationale that followed may have been a little sketchy, but apparently everyone agrees with with the point. I see the ticket led to a discussion on the libraries list - http://www.haskell.org/pipermail/libraries/2011-October/016978.html ... wherein Ian Lynagh proposed to remove this feature and let the programmer enforce locking or not, as in other programming languages' base I/O libraries. This met with enthusiastic universal support, so whatever the Report may say, it looks to me like the GHC libraries will eventually not do this. Wouldn't this lead to 'getContents' and friends being much less safe than they already are? Or would we have to do something at the GHC runtime level of things to add locking? Antoine ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Windows: openFile gives permission denied when file in use
On Wed, Dec 28, 2011 at 3:52 PM, Michael Snoyman mich...@snoyman.com wrote: Hi all, I just received a bug report from a client that, when an input file is open in FrameMaker, my program gives a permission denied error. This bug is reproducible with a simple Haskell program: import System.IO main = do putStrLn here1 h - openFile filename.txt ReadMode putStrLn here2 I tried writing a simple C program using fopen, and it ran just fine. Does anyone have experience with this issue, and know of a workaround? When GHC opens files for reading, it asks windows to disallow write access to the file. I'm guessing that Framemaker has the file open for writing, so GHC can't get that permission. I imagine that the Haskell runtime does this to make lazy-io less crazy. Here's the call GHC makes: https://github.com/ghc/packages-base/blob/0e1a02b96cfd03b8488e3ff4ce232466d6d5ca77/include/HsBase.h#L580 To open a file for reading in your C demo in a similar way you could do something like: fd = _sopen(file_name, _O_RDONLY | _O_NOINHERIT,_SH_DENYWR, 0); Here _SH_DENYWR is telling windows to deny others from writing to this file. Here's the msdn link for _sopen and _wsopen: http://msdn.microsoft.com/en-us/library/w7sa2b22%28VS.80%29.aspx I haven't tested any of that, but that should help you in reproducing how GHC opens files for read on windows. You should be able to use System.Win32.File.createFile with a share mode of (fILE_SHARE_READ .|. fILE_SHARE_WRITE) and then wrangling a Haskell Handle out of that, but I haven't tried it. Or you could modify the call to _wsopen and FFI call that - it takes fewer parameters and might be less confusing. Antoine ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] On the purity of Haskell
On Wed, Dec 28, 2011 at 3:45 PM, Steve Horne sh006d3...@blueyonder.co.uk wrote: On 28/12/2011 20:44, Heinrich Apfelmus wrote: Steve Horne wrote: This is just my view on whether Haskell is pure, being offered up for criticism. I haven't seen this view explicitly articulated anywhere before, but it does seem to be implicit in a lot of explanations - in particular the description of Monads in SBCs Tackling the Awkward Squad. I'm entirely focused on the IO monad here, but aware that it's just one concrete case of an abstraction. Warning - it may look like trolling at various points. Please keep going to the end before making a judgement. To make the context explicit, there are two apparently conflicting viewpoints on Haskell... 1. The whole point of the IO monad is to support programming with side-effecting actions - ie impurity. 2. The IO monad is just a monad - a generic type (IO actions), a couple of operators (primarily return and bind) and some rules - within a pure functional language. You can't create impurity by taking a subset of a pure language. My view is that both of these are correct, each from a particular point of view. Furthermore, by essentially the same arguments, C is also both an impure language and a pure one. [...] Purity has nothing to do with the question of whether you can express IO in Haskell or not. ... The beauty of the IO monad is that it doesn't change anything about purity. Applying the function bar :: Int - IO Int to the value 2 will always give the same result: Yes - AT COMPILE TIME by the principle of referential transparency it always returns the same action. However, the whole point of that action is that it might potentially be executed (with potentially side-effecting results) at run-time. Pure at compile-time, impure at run-time. What is only modeled at compile-time is realized at run-time, side-effects included. I don't think I would put it that way - the value 'bar 2' is a regular Haskell value. I can put it in a list, return it from a function and all other things: myIOActions :: [IO Int] myIOActions = [bar 2, bar (1+1), bar (5-3)] And I can pick any of the elements of the list to execute in my main function, and I get the same main function either way. Consider the following... #include stdio.h int main (int argc, char*argv) { char c; c = getchar (); putchar (c); return 0; } The identifier c is immutable. We call it a variable, but the compile-time value of c is really just some means to find the actual value in the big implicit IORef at runtime - an offset based on the stack pointer or whatever. Nothing mutates until compile-time, and when that happens, the thing that mutates (within that big implicit IORef) is separate from that compile-time value of c. In C and in Haskell - the side-effects are real, and occur at run-time. That doesn't mean Haskell is as bad as C - I get to the advantages of Haskell at the end of my earlier post. Mostly unoriginal, but I think the bit about explicit vs. implicit IORefs WRT an alternate view of transparency is worthwhile. I hope If convinced you I'm not making one of the standard newbie mistakes. I've done all that elsewhere before, but not today, honest. ___ 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] Windows: openFile gives permission denied when file in use
On Wed, Dec 28, 2011 at 3:52 PM, Michael Snoyman mich...@snoyman.com wrote: Hi all, I just received a bug report from a client that, when an input file is open in FrameMaker, my program gives a permission denied error. This bug is reproducible with a simple Haskell program: This bug and its discussion is similar, but not identical: http://hackage.haskell.org/trac/ghc/ticket/4363 import System.IO main = do putStrLn here1 h - openFile filename.txt ReadMode putStrLn here2 I tried writing a simple C program using fopen, and it ran just fine. Does anyone have experience with this issue, and know of a workaround? Thanks, Michael ___ 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] Non-exhaustive pattern match warning (incorrect?)
On Mon, Dec 26, 2011 at 1:21 PM, Michael Orlitzky mich...@orlitzky.com wrote: I'm cleaning up some old projects, and hit this: src/Octet.hs:47:27: Warning: Pattern match(es) are non-exhaustive In a record-update construct: Patterns not matched: Octet.None But in the source, I've checked for that case: class Maskable a where apply_mask :: a - Maskbits - Bit - a instance Maskable Octet where apply_mask _ Maskbits.None _ = Octet.None apply_mask Octet.None _ _ = Octet.None apply_mask oct mask bit | mask == Eight = oct | mask == Seven = oct { b8 = bit } -- Line 47 ... | otherwise = Octet.None Am I overlooking something, or did I already match Octet.None? What is your definition of the 'Octet' type? ___ 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] Non-exhaustive pattern match warning (incorrect?)
On Mon, Dec 26, 2011 at 2:19 PM, Michael Orlitzky mich...@orlitzky.com wrote: On 12/26/11 13:42, Antoine Latter wrote: Am I overlooking something, or did I already match Octet.None? What is your definition of the 'Octet' type? -- An Octet consists of eight bits. For our purposes, the most -- significant bit will come first. That is, b1 is in the 2^7 -- place while b8 is in the 2^0 place. data Octet = None | Octet { b1 :: Bit, b2 :: Bit, b3 :: Bit, b4 :: Bit, b5 :: Bit, b6 :: Bit, b7 :: Bit, b8 :: Bit } deriving (Eq) The error is warning you that the record update 'oct { b8 = bit }' can fail at run-time if 'oct' is None. Since it looks like you've checked for that you shouldn't have a problem, but the compiler doesn't know that. If you decompose your type into 'Octet' without the 'None' case, and 'Maybe Octet' for the times when 'None' is appropriate, the compiler will have enough information to not give warnings like this. I can't be the one to tell you if that is worth it or not. Antoine ___ 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: Occasional segfault in GHCi w/ 7.4.1-rc1 and 64bit OS X
On Sun, Dec 25, 2011 at 12:35 AM, austin seipp a...@hacks.yi.org wrote: Hello GHC hackers, I have been trying the recent 7.4.1-rc1 release on my OSX Snow Leopard machine. I am using the 64bit OSX .tar.bz. I used virthualenv/hsenv to set up a virtual environment to test packages with the RC, but I discovered that GHCi seems to segfault somewhat randomly when invoked. A data point: I've been testing out the RC, including minimal use of ghci, on a similar machine (same OS and arch). I've been using a 32-bit source build of RC and I haven't seen anything like this. Antoine ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: [Haskell-cafe] Images in Haddock documentation: best practices?
On Sun, Dec 25, 2011 at 12:04 AM, Brent Yorgey byor...@seas.upenn.edu wrote: Hi all, Although it doesn't seem to be documented in the user manual (!), Haddock supports inline images, using a url syntax. I'd like to include some images in the documentation for a package I'm writing, but not sure of the best way. In case nothing else works out: http://en.wikipedia.org/wiki/Data_URI_scheme They do not work in IE 7, and in IE 9 they are limited to 32k. They also are not cached separately from the containing page. Antoine ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: ANNOUNCE: GHC 7.4.1 Release Candidate 1
On Fri, Dec 23, 2011 at 3:04 AM, Simon Peyton-Jones simo...@microsoft.com wrote: Yes, it's expected; it's also the behaviour of GHC 6.12 etc. Here what is happening. You define result = undefined What type does it get? In 6.12, and 7.4, it gets type result :: forall b. b So the two uses of 'result' in the two branches of the case have no effect on each other. But in 7.2 it was *not generalised*, so we got result :: f2 a And now the two uses *do* affect each other. Thanks for the explanation. So the 'where' binding in the following does not get generalized because it could not have been written at the top level, correct? cast :: (Typeable a, Typeable b) = a - Maybe b cast x = r where r = if typeOf x == typeOf (fromJust r) then Just $ unsafeCoerce x else Nothing Why the change. You'll remember that over the last year GHC has changed not to generalise local lets: http://hackage.haskell.org/trac/ghc/blog/LetGeneralisationInGhc7 I relaxed the rule in 7.2, as discussed in Which bindings are affected? in that post. For reasons I have not investigated, 7.2 *still* doesn't generalise 'result'; but 7.4 correctly does. Simon ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: ANNOUNCE: GHC 7.4.1 Release Candidate 1
One more code sample which compiled with GHC 7.2.1 and does not with the new RC: {-# LANGUAGE FlexibleContexts, FlexibleInstances, FunctionalDependencies, MultiParamTypeClasses, RankNTypes, UndecidableInstances, TypeFamilies #-} newtype MyMonadT m a = MyMonadT (m a) class MyClass b m | m - b where data StM m :: * - * myFunc :: b a - m a instance MyClass b m = MyClass b (MyMonadT m) where newtype StM (MyMonadT m) b = StMMine [b] myFunc = undefined In the instance, in GHC 7.2 the 'b' on the LHS of the newtype introduces a fresh type binding. In the RC I get a kind error, because the compiler seems to be trying to make all of the 'b' labeled types the same type. Since the 'b' isn't an indexing parameter, it doesn't make since for it to not introduce a new binding. This seems like an odd UI corner case, so I'm not sure what the correct answer is. But it is a regression, so I thought I would ask and make sure it was on purpose. Antoine ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: ANNOUNCE: GHC 7.4.1 Release Candidate 1
On Wed, Dec 21, 2011 at 1:29 PM, Ian Lynagh ig...@earth.li wrote: We are pleased to announce the first release candidate for GHC 7.4.1: http://www.haskell.org/ghc/dist/7.4.1-rc1/ This includes the source tarball, installers for OS X and Windows, and bindists for amd64/Linux, i386/Linux, amd64/FreeBSD and i386/FreeBSD. Please test as much as possible; bugs are much cheaper if we find them before the release! Hurrah! The following used to compile with GHC 7.2.1: {-# LANGUAGE RankNTypes, TypeFamilies, GADTs #-} import Data.Typeable ( Typeable1, gcast1, typeOf1 ) cast1 :: (Typeable1 f1, Typeable1 f2) = f1 a - f2 a cast1 val = case gcast1 (Just val) of Just (Just typed_val) - typed_val `asTypeOf` result Nothing - error $ Invalid cast: ++ tag ++ - ++ show (typeOf1 result) where result = undefined tag = show (typeOf1 val) main = putStrLn Hello, world! But with GHC 7.4.1 RC 1 I get the error: BugDowncast.hs:9:69: Ambiguous type variable `t0' in the constraint: (Typeable1 t0) arising from a use of `typeOf1' Probable fix: add a type signature that fixes these type variable(s) In the first argument of `show', namely `(typeOf1 result)' In the second argument of `(++)', namely `show (typeOf1 result)' In the second argument of `(++)', namely ` - ++ show (typeOf1 result)' Is this an expected change, or should I create a ticket? Thanks, Antoine The release notes are not yet available, but here are some of the highlights of the 7.4 branch since 7.2 and 7.0: * There is a new feature Safe Haskell (-XSafe, -XTrustworthy, -XUnsafe): http://www.haskell.org/ghc/dist/stable/docs/html/users_guide/safe-haskell.html The design has changed since 7.2. * There is a new feature kind polymorphism (-XPolyKinds): http://www.haskell.org/ghc/dist/stable/docs/html/users_guide/kind-polymorphism-and-promotion.html A side-effect of this is that, when the extension is not enabled, in certain circumstances kinds are now defaulted to * rather than being inferred. * There is a new feature constraint kinds (-XConstraintKinds): http://www.haskell.org/ghc/dist/stable/docs/html/users_guide/constraint-kind.html * It is now possible to give any sort of declaration at the ghci prompt: http://www.haskell.org/ghc/dist/stable/docs/html/users_guide/interactive-evaluation.html#ghci-decls For example, you can now declare datatypes within ghci. * The profiling and hpc implementations have been merged and overhauled. Visible changes include renaming of profiling flags: http://www.haskell.org/ghc/dist/stable/docs/html/users_guide/flag-reference.html#id589412 and the cost-centre stacks have a new semantics, which should in most cases result in more useful and intuitive profiles. The +RTS -xc flag now also gives a stack trace. * It is now possible to write compiler plugins: http://www.haskell.org/ghc/dist/stable/docs/html/users_guide/compiler-plugins.html * DPH support has been significantly improved. * There is now preliminary support for registerised compilation using LLVM on the ARM platform. Note: The release candidate accidentally includes the random, primitive, vector and dph libraries. The final release will not include them. Thanks Ian, on behalf of the GHC team ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: [Haskell-cafe] Mitigating state-threading through an application loop
On Tue, Dec 20, 2011 at 11:08 AM, Michael Serra mk.se...@gmail.com wrote: Hello Haskellers, I'm implementing a simple tree-manipulating (for sports tournaments) application prototype, with SDL for graphics and simple user interaction. For reference, I've posted the code on hpaste. My question is about code organization: everything was simple and elegant until I started writing the program's display/event loop. Every function in this section has to be passed the same parameters - the application window to draw on, the font to display text with, the tree representing the current application state, etc. The font is an especially egregious example of the problem, because it's only used by one function but to get there it must be threaded through all of them (looking at the hpaste, you will see I don't want to call openFont on every invocation of drawTexts; what's needed is to call it once in main and have the resulting value available to drawTxt. So my question: how can I mitigate the ugliness of this state-threading? I understand this is one purpose for monads; am I supposed to implement a monad transformer for this? I think it would be great if I could define a type AppState as a tuple of the various things I need to thread, and specify some kind of automatic as-pattern, so that every function taking this AppState parameter would implicitly have its components bound to certain preset names. I've never seen anyone do this however. What is the right solution? I've done that before in web-apps. It is conventional enough. To ease the threading-through of paramters you can use a Reader monad (perhaps ReaderT AppState IO). I don't know how well this fits in with the SDL libraries, though. Antoine ___ 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: Erratic failure to specialize function
On Sun, Dec 18, 2011 at 2:57 PM, Alexey Khudyakov alexey.sklad...@gmail.com wrote: Hello! I've found a puzzling performance problem with code which uses vector library and relies heavily on GHC to perform inlining and specialization. In some cases compiler refuses to specialize function and just copies there generic version which is slow. Here is smallest test case I've manages to make: This is a guess, but based on what I've read the GHC inliner only fires when the function is fully saturated as declared - so if you declare a function with one argument to the left of the '=' symbol, the inliner only then inlines when it is applied to one value. This means that the un-inlined function is passed to criterion in the first case, but not the second. Does adding a SPECIALIZE pragma help? Antoine file 'test.hs' import Criterion.Main import qualified Data.Vector.Unboxed as U import Boundary sample :: U.Vector Double sample = U.replicate 1 0 main = defaultMain [ bench eta $ nf variance sample , bench lambda $ nf (\x - variance x) sample ] file 'Boundary.hs' {-# LANGUAGE FlexibleContexts #-} module Boundary where import qualified Data.Vector.Generic as G variance :: (G.Vector v Double) = v Double - Double variance vec = G.sum vec {-# INLINE variance #-} Here is benchmarking results: benchmarking eta - mean: 220.8042 us benchmarking lambda - mean: 24.31309 us If variance is moved to the test.hs file or eta reduced or written as lambda: varance = \vec - G.sum vec difference goes away. What causes such behavior? ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: [Haskell-cafe] [Alternative] change some/many semantics
On Thu, Dec 15, 2011 at 2:20 AM, Gregory Crosswhite gcrosswh...@gmail.com wrote: On Dec 15, 2011, at 6:19 PM, Gregory Crosswhite wrote: After all, we already have the Monad typeclass which gives them essentially the same functionality. Make that the *Monoid* typeclass. :-) And this is an interesting discussion all of its own! Should the monoid instance of a Functor do what List does - which is analogious to its append or choice operation (where applicable), or should it do what Maybe does, which is lift the operation into its contained type? (That is, (Just x) `mappend` (Just y) == Just (x `mappend` y)). Since the Monoid instance for Maybe doesn't offer choice between Nothing and Some, it would be nice to have a standard choice operation that we could use for Maybe. Which is sort of what Alternative is - offering choice over a functor which supports it. Except that the notion of what choice means is richer in a parser than in Maybe (parsers may backtrack (like List) and parsing has some sort of stateful effect, which affects the success of future parses). It is an interesting dilemma. I am also fond of using Alternative (disguised as MonadPlus) in the Happstack sense, for building a web-site routing table. In the truest sense I am composing alternative responses to an input request, but using 'many', 'some', or 'sepEndBy` in this context would be odd. Antoine ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Splitting off many/some from Alternative
On Wed, Dec 14, 2011 at 8:03 PM, Ross Paterson r...@soi.city.ac.uk wrote: The current definition says that some and many should be the least solutions of the equations some v = (:) $ v * many v many v = some v | pure [] We could relax that to just requiring that they satisfy these equations (which I think is what John wants). In that case there would be another possible definition for Maybe: some Nothing = Nothing some (Just x) = Just (repeat x) many Nothing = Just [] many (Just x) = Just (repeat x) This seems to generalize to list: some [] = [] some xs = [cycle xs] many [] = [[]] many xs = [cycle xs] Although I'm still not sure why I would be using these operations in maybe or list. Antoine ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] [Alternative] change some/many semantics
On Wed, Dec 14, 2011 at 9:58 PM, Gregory Crosswhite gcrosswh...@gmail.com wrote: Hey everyone, This is even more out there than my previous posts, but the following just occurred to me: is it absolutely necessary that some/many have produced the entire list of results before returning? Couldn't we change their semantics so that the list of results is computed and/or extracted lazily? For example, if this were the case, then we would have that (some (Just 1)) returns an infinite list rather than running in an infinite loop (even without defining a special case some implementation), which is exactly what my intuition would expect. Isn't this what Ross previously suggested? I think his suggested instance methods for Maybe return the elements of the lists incrementally. Of course, this is not a simple change at all because it would have to be done in such a way as to respect the ordering of actions --- that is, we can't have each action executed only when the corresponding element of the list demanded is forced, or else actions would undesirably interleave. For example, in a parser when we use many v we expect everything matching v to be consumed by the time many v returns, but if instead many v only consumed as much of the input as we demanded from its result list then we might see a chunk of input matching v in another part of our parser despite having assumed we'd gotten rid of it, which would cause our parser to be broken. Nonetheless, if there were some way that we could use magic fairy dust to have the results returned by some and many be lazily generated lists, then this might solve many of the problems that come up with them performing infinite loops in cases where it seems like they shouldn't. :-) Cheers, Greg ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] [Alternative] change some/many semantics
On Wed, Dec 14, 2011 at 10:33 PM, Gregory Crosswhite gcrosswh...@gmail.com wrote: On Dec 15, 2011, at 2:13 PM, Antoine Latter wrote: Isn't this what Ross previously suggested? I think his suggested instance methods for Maybe return the elements of the lists incrementally. Yes and no. Yes, his excellent suggestion is one of my favorite ideas for what we should do with Alternative that I have seen so far and was the inspiration for my proposal, but no it is not the same idea at all. Whereas his suggestion keeps the types and generic definitions of some and many the way that they are but overrides them manually to work for types such as Maybe, my proposal is that we instead change the types and generic definitions of some and many themselves so that they automatically do the right thing for the Maybe and List types. Unless the Alternative and Applicative type classes offer class methods to guarantee laziness, we'll have a hard time writing functions with those guarantees. Such is the cost of parametric polymorphism! But also the beauty - in the absence of any laziness guaranteeing functions on the class, we are promised that a polymorphic function can't be using magic fairy dust behind our back. We could add some sort of laziness guaranteeing combinators to the class interface, but that would restrict its membership even further. Or we could not use 'some' and 'many' with list and maybe :-) Antoine ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] [Alternative] change some/many semantics
On Wed, Dec 14, 2011 at 10:57 PM, Brandon Allbery allber...@gmail.com wrote: On Wed, Dec 14, 2011 at 23:49, Antoine Latter aslat...@gmail.com wrote: Or we could not use 'some' and 'many' with list and maybe :-) Yes, yes, we get the message, a wink and a nod is all that's needed to discard the nonsensical notion that types and typeclasses *mean* something. That's the interesting thing about type-classes like Alternative and Functor - they mean very little, and are used in widely varying contexts. Heck, Control.Monad.void has the type signature Functor f a = f a - f () - how many functors is that operator sensible for? There are a lot of combinators you can build from (|) and empty that go terribly wrong for Maybe and List but are still quite useful. Even the operators at hand ('many' and 'some') are partial in parsing, but I'm not prepared to throw them out. Antoine ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] [Alternative] change some/many semantics
On Thu, Dec 15, 2011 at 1:23 AM, Gregory Crosswhite gcrosswh...@gmail.com wrote: On Dec 15, 2011, at 3:36 PM, Antoine Latter wrote: There are a lot of combinators you can build from (|) and empty that go terribly wrong for Maybe and List but are still quite useful. Yes, you *could* do that, but the whole point is that you shouldn't. Typeclasses generally come with informal laws that must be obeyed. If your instance does not obey those laws, then it should not be an instance. I said 'combinators', not 'instances'. A lot of popular parsers combinators can be written exclusively from (|) and empty, but make little sense for List and Maybe, and may not even function properly. The 'trifecta' package includes a nice reference: http://hackage.haskell.org/packages/archive/trifecta/0.49.1/doc/html/Text-Trifecta-Parser-Combinators.html See 'skipSome' through 'chainr1' - I wouldn't be surprised if most of these lead to the same infinite loop behavior for Maybe as the stock 'many' and 'some' in base. These sorts of functions are what Alternative is for. Maybe I'm missing something fundamental here. Antoine ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] [Alternative] change some/many semantics
On Thu, Dec 15, 2011 at 1:40 AM, Antoine Latter aslat...@gmail.com wrote: On Thu, Dec 15, 2011 at 1:23 AM, Gregory Crosswhite gcrosswh...@gmail.com wrote: On Dec 15, 2011, at 3:36 PM, Antoine Latter wrote: There are a lot of combinators you can build from (|) and empty that go terribly wrong for Maybe and List but are still quite useful. Yes, you *could* do that, but the whole point is that you shouldn't. Typeclasses generally come with informal laws that must be obeyed. If your instance does not obey those laws, then it should not be an instance. To clarify - I dropped Greg's sentence Incidentally, exactly what use cases do you have in mind?, which is most of what I was addressing in my previous email. I said 'combinators', not 'instances'. A lot of popular parsers combinators can be written exclusively from (|) and empty, but make little sense for List and Maybe, and may not even function properly. The 'trifecta' package includes a nice reference: http://hackage.haskell.org/packages/archive/trifecta/0.49.1/doc/html/Text-Trifecta-Parser-Combinators.html See 'skipSome' through 'chainr1' - I wouldn't be surprised if most of these lead to the same infinite loop behavior for Maybe as the stock 'many' and 'some' in base. These sorts of functions are what Alternative is for. Maybe I'm missing something fundamental here. Antoine ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Splitting off many/some from Alternative
On Mon, Dec 12, 2011 at 4:30 PM, John Meacham j...@repetae.net wrote: Yes, they are major pains for frisby, which is a parser but needs to be cleverer about recursion, the many and some that come with applicative actually cause infinite loops. That's why 'many' and 'some' were promoted up to being class methods, so that folks that needed a more specific implementation could provide one. But now they look as if they are of equal importance with the other class methods, which is not really true. Antoine John On Sun, Dec 11, 2011 at 9:18 PM, Gregory Crosswhite gcrosswh...@gmail.com wrote: Hey everyone, I am sure that it is too late to do more than idly speculate about this, but could we split the some/many methods out from Alternative? They simply don't make sense except in a subset of possible Alternatives --- in most cases they just result in an infinite loop. That is to say, it is not just that they are extraneous functionality, but most of the time they are *impossible* functionality to even implement! In a way, it is a lie to be including them in Alternative since people making use of the class might incorrectly (but quite reasonably!) assume that any type that is an instance of Alternative *has* a well-defined some and many method, when this is actually the exception rather than the rule. It is only recently that I have been able to grok what some and many are even about (I think), and they seem to only make sense in cases where executing the Alternative action results in a portion of some input being consumed or not consumed. some v means consume at least one v and return the list of items consumed or fail, and many v means consume zero or more v and return the list of items consumed or the empty list of none are consume. It thus makes sense for there to be some subclass of Alternative called something like Consumptive that contains these methods. The majority of Alternative instances would no longer have these methods, and again that would actually be an improvement since in such cases some/many were unworkable and did nothing but cause infinite loops anyway. Normally it would be unthinkable to even consider such a change to the base libraries, but I suspect that there are not more than a couple of packages out there that make active use of the some/many instances of Alternative; it is really only parser packages that need some/many, and users most likely use the versions included with the packages themselves rather than the Alternative version. Could we verify that this is the case, and if so split them away? I thought I heard a trick whereby people were able to grep all the source on Hackage, but I can't remember what it was. :-) Just a thought. :-) Thanks, Greg ___ 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] [ANNOUNCEMENT] xmobar 0.14
On Sun, Dec 11, 2011 at 8:48 AM, Peter Simons sim...@cryp.to wrote: Hi Jose, Peter, would using parsec 3.x be an acceptable solution to you? well, we can link xmobar with parsec 3.x on NixOS. The situation is tricky, though, because the latest version of parsec that we have, 3.1.2, doesn't compile with GHC 6.10.4 anymore, so we'd have to use some older version to work around that problem. That kind of setup somewhat complicated to maintain, which is why I would prefer to compile xmobar with parsec 2 2 if at all possible. Hi Peter, What errors are you getting compiling with GHC 6.10.4? If its a small thing I certainly don't mind patching things. Generally speaking, though, GHC 6.10.4 support is not a high priority. I just thought it might be worth pointing out that backwards compatibility has been lost in the 0.14 release, because earlier versions worked just fine. Take care, Peter ___ 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] [ANNOUNCEMENT] xmobar 0.14
On Sat, Dec 10, 2011 at 5:31 PM, Brandon Allbery allber...@gmail.com wrote: On Sat, Dec 10, 2011 at 18:25, Peter Simons sim...@cryp.to wrote: previous versions of xmobar used to compile fine with GHC 6.10.4, but the new version no longer does: src/Parsers.hs:163:52: Couldn't match expected type `Char' against inferred type `[Char]' Expected type: GenParser Char st Char Inferred type: GenParser Char st String In the second argument of `($)', namely `wrapSkip $ string Run' In a stmt of a 'do' expression: notFollowedBy $ wrapSkip $ string Run xmobar currently requires parsec 3.x; the above is the symptom of building it against 2.x. It's not clear to me from reading the sources and type signatures of 'notFollowedBy' why this is different in parsec 2 vs. parsec 3. Am I missing something easy? Because if it isn't obvious perhaps it wasn't on purpose. Antoine ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe