diff --git a/CHANGELOG.md b/CHANGELOG.md
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,4 +1,8 @@
-* lhs2tex-1.21
+# lhs2tex-1.22 (2018-09-23)
+
+- Compatibility with ghc-8.6.
+
+# lhs2tex-1.21 (2018-09-10)
 
 - Some code refactoring.
 - Experimental markdown mode.
diff --git a/INSTALL b/INSTALL
--- a/INSTALL
+++ b/INSTALL
@@ -32,7 +32,7 @@
 Unpack the archive. Assume that it has been unpacked into directory
 "/somewhere". Then say
 
-cd /somewhere/lhs2TeX-1.21
+cd /somewhere/lhs2TeX-1.22
 ./configure
 make
 make install
@@ -48,18 +48,18 @@
 lhs2TeX binary. The default search path is as follows:
 
 .
-{HOME}/lhs2tex-1.21//
+{HOME}/lhs2tex-1.22//
 {HOME}/lhs2tex//
 {HOME}/lhs2TeX//
-{HOME}/.lhs2tex-1.21//
+{HOME}/.lhs2tex-1.22//
 {HOME}/.lhs2tex//
 {HOME}/.lhs2TeX//
 {LHS2TEX}//
-/usr/local/share/lhs2tex-1.21//
-/usr/local/share/lhs2tex-1.21//
-/usr/local/lib/lhs2tex-1.21//
-/usr/share/lhs2tex-1.21//
-/usr/lib/lhs2tex-1.21//
+/usr/local/share/lhs2tex-1.22//
+/usr/local/share/lhs2tex-1.22//
+/usr/local/lib/lhs2tex-1.22//
+/usr/share/lhs2tex-1.22//
+/usr/lib/lhs2tex-1.22//
 /usr/local/share/lhs2tex//
 /usr/local/lib/lhs2tex//
 /usr/share/lhs2tex//
diff --git a/Setup.hs b/Setup.hs
--- a/Setup.hs
+++ b/Setup.hs
@@ -34,7 +34,7 @@
 minPolytableVersion = [0,8,2]
 shortversion = show (numversion `div` 100) ++ "." ++ show (numversion `mod` 100)
 version = shortversion ++ if ispre then "pre" ++ show pre else ""
-numversion = 121
+numversion = 122
 ispre = False
 pre = 1
 
diff --git a/config.mk.in b/config.mk.in
--- a/config.mk.in
+++ b/config.mk.in
@@ -20,6 +20,7 @@
 
 HUGS            = @HUGS@
 
+SHELL           = @BASH@
 INSTALL         = @INSTALL@
 MV              = @MV@
 CP              = @CP@
diff --git a/configure b/configure
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for lhs2tex 1.21.
+# Generated by GNU Autoconf 2.69 for lhs2tex 1.22.
 #
 #
 # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
@@ -576,8 +576,8 @@
 # Identity of this package.
 PACKAGE_NAME='lhs2tex'
 PACKAGE_TARNAME='lhs2tex'
-PACKAGE_VERSION='1.21'
-PACKAGE_STRING='lhs2tex 1.21'
+PACKAGE_VERSION='1.22'
+PACKAGE_STRING='lhs2tex 1.22'
 PACKAGE_BUGREPORT=''
 PACKAGE_URL=''
 
@@ -606,6 +606,7 @@
 RM
 CP
 MV
+BASH
 LN_S
 INSTALL_DATA
 INSTALL_SCRIPT
@@ -635,6 +636,7 @@
 docdir
 oldincludedir
 includedir
+runstatedir
 localstatedir
 sharedstatedir
 sysconfdir
@@ -701,6 +703,7 @@
 sysconfdir='${prefix}/etc'
 sharedstatedir='${prefix}/com'
 localstatedir='${prefix}/var'
+runstatedir='${localstatedir}/run'
 includedir='${prefix}/include'
 oldincludedir='/usr/include'
 docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
@@ -953,6 +956,15 @@
   | -silent | --silent | --silen | --sile | --sil)
     silent=yes ;;
 
+  -runstatedir | --runstatedir | --runstatedi | --runstated \
+  | --runstate | --runstat | --runsta | --runst | --runs \
+  | --run | --ru | --r)
+    ac_prev=runstatedir ;;
+  -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
+  | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
+  | --run=* | --ru=* | --r=*)
+    runstatedir=$ac_optarg ;;
+
   -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
     ac_prev=sbindir ;;
   -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
@@ -1090,7 +1102,7 @@
 for ac_var in	exec_prefix prefix bindir sbindir libexecdir datarootdir \
 		datadir sysconfdir sharedstatedir localstatedir includedir \
 		oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
-		libdir localedir mandir
+		libdir localedir mandir runstatedir
 do
   eval ac_val=\$$ac_var
   # Remove trailing slashes.
@@ -1203,7 +1215,7 @@
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures lhs2tex 1.21 to adapt to many kinds of systems.
+\`configure' configures lhs2tex 1.22 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1243,6 +1255,7 @@
   --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]
   --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
   --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
+  --runstatedir=DIR       modifiable per-process data [LOCALSTATEDIR/run]
   --libdir=DIR            object code libraries [EPREFIX/lib]
   --includedir=DIR        C header files [PREFIX/include]
   --oldincludedir=DIR     C header files for non-gcc [/usr/include]
@@ -1264,7 +1277,7 @@
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of lhs2tex 1.21:";;
+     short | recursive ) echo "Configuration of lhs2tex 1.22:";;
    esac
   cat <<\_ACEOF
 
@@ -1342,7 +1355,7 @@
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-lhs2tex configure 1.21
+lhs2tex configure 1.22
 generated by GNU Autoconf 2.69
 
 Copyright (C) 2012 Free Software Foundation, Inc.
@@ -1359,7 +1372,7 @@
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by lhs2tex $as_me 1.21, which was
+It was created by lhs2tex $as_me 1.22, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   $ $0 $@
@@ -1708,9 +1721,9 @@
 
 
 
-VERSION="1.21"
-SHORTVERSION="1.21"
-NUMVERSION=121
+VERSION="1.22"
+SHORTVERSION="1.22"
+NUMVERSION=122
 PRE=1
 
 
@@ -1938,6 +1951,46 @@
 
 
 # other programs
+# Extract the first word of "bash", so it can be a program name with args.
+set dummy bash; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_BASH+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $BASH in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_BASH="$BASH" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_path_BASH="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+BASH=$ac_cv_path_BASH
+if test -n "$BASH"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BASH" >&5
+$as_echo "$BASH" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
 # Extract the first word of "mv", so it can be a program name with args.
 set dummy mv; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
@@ -3347,7 +3400,7 @@
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by lhs2tex $as_me 1.21, which was
+This file was extended by lhs2tex $as_me 1.22, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -3400,7 +3453,7 @@
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-lhs2tex config.status 1.21
+lhs2tex config.status 1.22
 configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
 
diff --git a/doc/Guide2.pdf b/doc/Guide2.pdf
Binary files a/doc/Guide2.pdf and b/doc/Guide2.pdf differ
diff --git a/doc/Makefile b/doc/Makefile
--- a/doc/Makefile
+++ b/doc/Makefile
@@ -28,9 +28,7 @@
 	$(LN_S) ../polytable/lazylist.sty .
 
 RawSearchPath.lhs : ../src/Version.lhs
-	echo '\begin{code}' > $@
-	$(LHS2TEX) --searchpath >> $@
-	echo '\end{code}' >> $@
+	$(LHS2TEX) --texsearchpath > $@
 
 SearchPath.lhs : RawSearchPath.lhs
 	touch $@
@@ -81,5 +79,5 @@
 
 .PHONY : all srcdist clean
 clean :
-	rm -f $(SNIPPETSGD) $(SNIPPETSSTC)
+	rm -f $(SNIPPETSGD) $(SNIPPETSSTC) RawSearchPath.lhs
 
diff --git a/doc/RawSearchPath.lhs b/doc/RawSearchPath.lhs
--- a/doc/RawSearchPath.lhs
+++ b/doc/RawSearchPath.lhs
@@ -1,17 +1,16 @@
 \begin{code}
 .
-{HOME}/lhs2tex-1.21//
+{HOME}/lhs2tex-1.22//
 {HOME}/lhs2tex//
 {HOME}/lhs2TeX//
-{HOME}/.lhs2tex-1.21//
+{HOME}/.lhs2tex-1.22//
 {HOME}/.lhs2tex//
 {HOME}/.lhs2TeX//
 {LHS2TEX}//
-/usr/local/share/lhs2tex-1.21//
-/usr/local/share/lhs2tex-1.21//
-/usr/local/lib/lhs2tex-1.21//
-/usr/share/lhs2tex-1.21//
-/usr/lib/lhs2tex-1.21//
+/usr/local/share/lhs2tex-1.22//
+/usr/local/lib/lhs2tex-1.22//
+/usr/share/lhs2tex-1.22//
+/usr/lib/lhs2tex-1.22//
 /usr/local/share/lhs2tex//
 /usr/local/lib/lhs2tex//
 /usr/share/lhs2tex//
diff --git a/lhs2tex.cabal b/lhs2tex.cabal
--- a/lhs2tex.cabal
+++ b/lhs2tex.cabal
@@ -1,6 +1,6 @@
 cabal-version:  >=1.10
 name:           lhs2tex
-version:        1.21
+version:        1.22
 license:        GPL
 license-file:   LICENSE
 author:         Ralf Hinze <ralf.hinze@comlab.ox.ac.uk>, Andres Loeh <lhs2tex@andres-loeh.de>
@@ -24,7 +24,7 @@
   be invoked in another mode to just extract the Haskell code.
 category:       Development, Language
 build-type:     Custom
-tested-with:    GHC == 7.4.2, GHC == 7.6.3, GHC == 7.8.4, GHC == 7.10.3, GHC == 8.0.2, GHC == 8.2.1
+tested-with:    GHC == 7.4.2, GHC == 7.6.3, GHC == 7.8.4, GHC == 7.10.3, GHC == 8.0.2, GHC == 8.2.1, GHC == 8.4.3, GHC == 8.6.1
 extra-source-files:     AUTHORS
                         CHANGELOG.md
                         INSTALL
diff --git a/src/Directives.lhs b/src/Directives.lhs
--- a/src/Directives.lhs
+++ b/src/Directives.lhs
@@ -208,7 +208,7 @@
 >   appl                        =  do f <- optional not'
 >                                     e <- atom
 >                                     return (maybe e (\_ -> onBool1 not e) f)
->   atom                        =   do Varid x <- satisfy isVarid; return (value togs x)
+>   atom                        =   do x <- satisfy isVarid; return (value togs (string x))
 >                               <|> do _ <- true'; return (Bool True)
 >                               <|> do _ <- false'; return (Bool False)
 >                               <|> do s <- satisfy isString; return (Str (read (string s)))
@@ -237,10 +237,10 @@
 > define lang togs              =  parse lang (definition lang togs)
 >
 > definition                    :: Lang -> Toggles -> Parser Token (String, Value)
-> definition lang togs          =  do Varid x <- satisfy isVarid
+> definition lang togs          =  do x <- satisfy isVarid
 >                                     _ <- equal' lang
 >                                     b <- expression lang togs
->                                     return (x, b)
+>                                     return (string x, b)
 
 Primitive Parser.
 
diff --git a/src/Main.lhs b/src/Main.lhs
--- a/src/Main.lhs
+++ b/src/Main.lhs
@@ -52,7 +52,7 @@
 > main                          =  getArgs >>= main'
 
 > main'                         :: [String] -> IO ()
-> main' args                    =  case getOpt Permute options args of
+> main' args                    =  case getOpt Permute (options ++ hiddenOptions) args of
 >   (o,n,[])                    -> do hSetEncoding stdin  utf8
 >                                     hSetEncoding stdout utf8
 >                                     hSetEncoding stderr utf8
@@ -65,6 +65,9 @@
 >                                           -- ks, 22.11.2005, changed default style to |Poly|
 >                                       [Help]        -> quitSuccess (usageInfo uheader options)
 >                                       [SearchPath]  -> quitSuccess (init . unlines $ V.searchPath)
+>                                       [TeXSearchPath] ->
+>                                         quitSuccess (init . unlines $
+>                                           ["\\begin{code}"] ++ V.searchPath ++ ["\\end{code}"])
 >                                       [Version]     -> quitSuccess programInfo
 >                                       [Copying]     -> quitSuccess (programInfo ++ "\n\n" ++ copying)
 >                                       [Warranty]    -> quitSuccess (programInfo ++ "\n\n" ++ warranty)
@@ -180,6 +183,11 @@
 >   , Option []    ["copying"] (NoArg (return, id, [Copying]))                              "display license"
 >   , Option []    ["warranty"](NoArg (return, id, [Warranty]))                             "info about warranty"
 >   ]
+>
+> hiddenOptions                 :: [OptDescr (State -> IO State,[Class] -> [Class],[Style])]
+> hiddenOptions =
+>   [ Option []    ["texsearchpath"]
+>                              (NoArg (return, id, [TeXSearchPath]))                        "show searchpath in code environment" ]
 >
 > formatStr                     :: String -> Formatter
 > formatStr str                 =  formats (texparse 1 str) `catchError` abort
diff --git a/src/TeXCommands.lhs b/src/TeXCommands.lhs
--- a/src/TeXCommands.lhs
+++ b/src/TeXCommands.lhs
@@ -15,7 +15,7 @@
 
 These don't really belong into a module named TeXCommands:
 
-> data Style                    =  Version | Help | SearchPath | Copying | Warranty | CodeOnly | NewCode | Verb | Typewriter | Poly | Markdown | Math | Pre
+> data Style                    =  Version | Help | SearchPath | TeXSearchPath | Copying | Warranty | CodeOnly | NewCode | Verb | Typewriter | Poly | Markdown | Math | Pre
 >                                  deriving (Eq, Show, Enum, Bounded)
 
 > data Lang                     =  Haskell | Agda
@@ -71,7 +71,7 @@
 >     representation            =  [ ("tt", Typewriter), ("math", Math), ("poly", Poly), ("markdown", Markdown),
 >                                    ("verb", Verb), ("code", CodeOnly), ("newcode",NewCode),
 >                                    ("pre", Pre), ("version", Version),
->                                    ("copying", Copying), ("warranty", Warranty), ("help", Help), ("searchpath", SearchPath) ]
+>                                    ("copying", Copying), ("warranty", Warranty), ("help", Help), ("searchpath", SearchPath), ("texsearchpath", TeXSearchPath) ]
 > instance Representation Lang where
 >     representation            =  [ ("haskell", Haskell), ("agda", Agda) ]
 > instance Representation Command where
