
{-# OPTIONS -fglasgow-exts #-}

module Mod where

import Language.Haskell.TH
import List
import Char

expandVars :: String -> Q Exp
expandVars s =
    [| concat $(return (ListE (map f (groupBy (\x y -> g x == g y) s)))) |]
  where
    f x | all g x   = VarE (mkName x)
        | otherwise = LitE (StringL x)
    g = isAlphaNum

