text: Template panics the compiler
  Experimenting a little with the template example from i tried to put a small parser into it, and ran into this: ghc --make -fth template.hs -o template Chasing modules from: template.hs Skipping Printf ( ./Printf.hs, ./Printf.o ) Compiling Main ( template.hs, template.o ) Loading package base-1.0 ... linking ... done. Loading package haskell98-1.0 ... linking ... done. Loading package parsec-1.0 ... linking ... done. Loading package template-haskell-1.0 ... linking ... done. ghc: panic! (the `impossible' happened, GHC version 6.4): ./Printf.hs:(40,0)-(42,20): Non-exhaustive patterns in function gen Please report it as a compiler bug to glasgow-haskell-bugs@haskell.org, or. Compilation exited abnormally with code 1 at Wed May 04 00:50:37 I was running on winxp The code was: --template.hs: module Main where import Printf (pr) main = putStrLn ( $(pr "hello")) --Printf.hs: module Printf where -- Skeletal printf from the paper. -- It needs to be in a separate module to the one where -- you intend to use it. -- Import some Template Haskell syntax import Language.Haskell.TH import Text.ParserCombinators.Parsec import Text.ParserCombinators.Parsec.Char import Text.ParserCombinators.Parsec.Prim import Text.ParserCombinators.Parsec.Combinator -- Describe a format string data Format = D | S | L String parsePercent = do char '%' k <- oneOf "sd" return (case k of 's' -> S 'd' -> D) parseString = do s <- many (satisfy (/= '%')) return (L s) -- Is not used yet since it doesn't work -- parseFormat' = return many (parsePercent <|> parseString) -- Parse a format string. This is left largely to you -- as we are here interested in building our first ever -- Template Haskell program and not in building printf. parseFormat :: String -> [Format] parseFormat s = case (parse (many parsePercent) [] s) of Left err -> fail "Printf parser error" Right x -> x --Format s)
  Trac metadata
  To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information