debug
debug copied to clipboard
Illegal variable name when splicing a TH declaration
I'm trying to use debug to instrument a function. I have followed the instructions, so the top of my source file looks like this:
{-# LANGUAGE TemplateHaskell, ViewPatterns, PartialTypeSignatures #-}
{-# OPTIONS_GHC -Wno-partial-type-signatures #-}
module Day2 (
-- ...
) where
import Util
import Debug
I'm instrumenting the function as follows:
debug [d|
_seek_from :: (Integer, Integer) -> Integer -> [Integer] -> Maybe (Integer, Integer)
_seek_from (a, b) t [] = Nothing
_seek_from (a, b) t mem
| a > bound && b > bound = Nothing
| a < 0 || b < 0 = Nothing
| a > bound && b <= bound = _seek_from (0, b + 1) t mem
| otherwise =
let r = test_inputs (a, b) mem in
if r == t then Just (a, b) else _seek_from (a + 1, b) t mem
where bound = let x = toInteger . ((-) 1) . length $ mem in if x > 99 then 99 else x
|]
When I build (stack build) I get the following error:
Illegal variable name: ‘’Illegal variable name: ‘’
When splicing a TH declaration
It specifically has a problem on the debug [d| line.
The use of _ as function names looks odd. Perhaps try removing that?
The debug library is not massively supported at the moment, so you may be on your own if it doesn't work easily I'm afraid.