
#10924: Template variable unbound in rewrite rule -------------------------------------+------------------------------------- Reporter: crockeea | Owner: Type: bug | Status: new Priority: normal | Milestone: 7.10.3 Component: Compiler | Version: 7.10.2 Resolution: | Keywords: singletons, | templatehaskell Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): -------------------------------------+------------------------------------- Comment (by crockeea): I did figure out a workaround: don't use "as-patterns" at all. The following definition of `ppMul` compiles: {{{ ppMul :: PrimePower -> [PrimePower] -> [PrimePower] ppMul x [] = [x] ppMul (PP(p,e)) (PP (p',e'):pps') | p == p' = PP(p,e Num.+ e'):pps' | p <<= p' = (PP(p,e)):(PP (p',e'):pps') | otherwise = (PP(p',e')):ppMul (PP(p,e)) pps' }}} Since the point of using singletons is to get type-level functions, it's not clear that there is any performance overhead (except perhaps in the compiler) by rebuilding `PP(p,e)` and `PP(p,e')`, but it would be nice to be able to write this in a more idiomatic manner. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10924#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler