Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Illegal variable name when splicing a TH declaration #64

Open
gfarrell opened this issue Dec 18, 2019 · 1 comment
Open

Illegal variable name when splicing a TH declaration #64

gfarrell opened this issue Dec 18, 2019 · 1 comment

Comments

@gfarrell
Copy link

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.

@ndmitchell
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants