I'm working on a program in which I'd like to use Alex and Happy to parse the input. I've written the scanner, and it uses Alex's "monadUserState" wrapper to track source location and various other things. Now, the problem is to integrate it with the parser. As far as I can tell from reading the Happy documentation, I need to use a monadic Parser in Happy as well, but the manuals don't relaly provide a lot of information about how to integrate the two. And I haven't really been able to find many examples of this either. Lots of folks cite "the Haskell parser", although I'm not sure which implementation that's referring to. I did check out the GHC source, and while it contains an Alex parser specification, it doesn't look like anything actually *uses* this, preferring instead a handwritten parser. Could anyone point me to a discussion of how to integrate these two tools, or examples of places where folks have done this before? Thanks much, Richard
Hi! After I do `cabal install`, I get two binaries: - in `dist/dist-sandbox-$ID/build/Foo/Foo` - in `.cabal-sandbox/bin/Foo` They seem to be different. Is this ok? Which one of them is the right one? Sorry if I missed this in docs. Thanks. _______________________________________________ Libraries mailing list Libraries< at >haskell.org http://www.haskell.org/mailman/listinfo/libraries
I'm loading data from XML into a Haskell data type, and I'd like to use Persistent to save it to a database. The examples from the Yesod book have you manually define a FooId field and create the relationships yourself from the bottom up. For example, "a person has many cars": blah blah [persistLowerCase| Person name String Car ownerId PersonId Eq name String |] This works well if you're responsible for creating every person/car manually. But what if the data are given to you? If I were to parse people from an XML file, the cars wouldn't have people_ids in them. Instead I'd get, blah blah [persistLowerCase| Person name String cars [Car] Car name String |] As long as the cars list contains another Persistent type, it seems like I should be able to insert a person and have it insert the cars, with proper foreign keys, automatically. Doing it manually isn't straight-forward because I can't add the "ownerId" field to my Car type and still expect to
Dear Cafe, Hope you all had a nice Christmas. I have been playing with generating method instances using Template Haskell but am a bit stuck now trying to generate an instance for a parametrized data type. I would like to generate the following: > instance (MyClass a) => MyClass (Tree a) where > mymethod _ = "todo" I defined a genMyClassInstance that is working fine for unparametrized data types, but clearly there is nothing here that inserts the '(MyClass a) =>' part here. My first question is: how should I instruct Template Haskell to insert the beforementioned code when appropriate? > genMyClassInstance :: Name -> Q [Dec] > genMyClassInstance name > = [d|instance MyClass $(conT name) where > mymethod _ = "todo" > |] My second question is how to pass the Name of a parametrized data type? I tried the following, but GHC does not seem to like that: "Not in scope: type constructor or class `Tree a' Perhaps you meant `Tree'" > $(genMyInstance (mkName
Are there any tools or vim-plugins that will automatically add import statements? For instance, I have the following code: ... import Data.Maybe (fromJust) import Text.ParserCombinators.Parsec (ParseError) import Text.Printf (printf) ... parseMyString :: String -> Either ParseError String parseMyString stringToParse = parse myParser "(unknown)" stringToParse Here's what I want to have happen. I put my cursor over "parse" and press some keystroke. It automatically adds the parse function to the list of import statements from the Text.ParserCombinators.Parsec module (hopefully sorted alphabetically). So the import statements end up looking like this: ... import Data.Maybe (fromJust) import Text.ParserCombinators.Parsec (ParseError, parse) import Text.Printf (printf) ... The haskellmode vim plugin (https://github.com/lukerandall/haskellmode-vim) has functionality similar to this, but it can only add new import lines. It can't add functions/types to existing import lines. The best it can do is some
Dear all, I want to announce a special holiday meeting of Munich's Haskell user group. It will take place on the 27th of December at 19h30 at Cafe Puck. Check out the details here: http://www.haskell-munich.de/news I wish everyone a nice holiday! Heinrich
Hello, guys. Recently I came across the definition of the function 'forever' on hoogle. I am intrigued that it works. The recursive definition does make sense to me in a mathematical way, but I can't figure out how it works under the hood in terms of thunks. To tell you the truth, I don't know how laziness works in general in haskell. Can someone help me understand how it works in this example, and give some pointers to materials on the subject? The "tying the knot" article on the wiki is pretty mind bending too.
Is anyone else using metalog (syslog implementation) along with hslogger to log to syslog? If I run the following with syslog-ng, it works. With metalog, I get nothing. Just want to make sure it isn't me before I report it. Prelude> :set prompt "ghci> " ghci> :m +System.Log.Logger ghci> :m +System.Log.Handler.Syslog ghci> sl <- openlog rootLoggerName  USER DEBUG ghci> updateGlobalLogger rootLoggerName (addHandler sl) ghci> errorM rootLoggerName "This won't show up with metalog."