-#define USE_FAST_STRINGS 1
-#define FAST_STRING _PackedString
-#define SLIT(x) (_packCString (A# x#))
-#define _CMP_STRING_ cmpPString
-#define _NULL_ _nullPS
-#define _NIL_ _nilPS
-#define _CONS_ _consPS
-#define _HEAD_ _headPS
-#define _TAIL_ _tailPS
-#define _LENGTH_ _lengthPS
-#define _PK_ _packString
-#define _UNPK_ _unpackPS
-#define _SUBSTR_ _substrPS
-#define _APPEND_ `_appendPS`
-#define _CONCAT_ _concatPS
+
+-- This #ifndef lets us switch off the "import FastString"
+-- when compiling FastString itself
+#ifndef COMPILING_FAST_STRING
+--
+import qualified FastString
+#endif
+
+# define USE_FAST_STRINGS 1
+# define FAST_STRING FastString.FastString
+# define SLIT(x) (FastString.mkFastCharString# (x#))
+# define _NULL_ FastString.nullFastString
+# define _NIL_ (FastString.mkFastString "")
+# define _CONS_ FastString.consFS
+# define _HEAD_ FastString.headFS
+# define _TAIL_ FastString.tailFS
+# define _LENGTH_ FastString.lengthFS
+# define _PK_ FastString.mkFastString
+# define _UNPK_ FastString.unpackFS
+# define _APPEND_ `FastString.appendFS`
+# define _CONCAT_ FastString.concatFS
+#else
+# define FAST_STRING String
+# define SLIT(x) (x)
+# define _CMP_STRING_ cmpString
+# define _NULL_ null
+# define _NIL_ ""
+# define _CONS_ (:)
+# define _HEAD_ head
+# define _TAIL_ tail
+# define _LENGTH_ length
+# define _PK_ (\x->x)
+# define _UNPK_ (\x->x)
+# define _SUBSTR_ substr{-from Utils-}
+# define _APPEND_ ++
+# define _CONCAT_ concat
+#endif
+
+#if __HASKELL1__ > 4
+# define FMAP fmap
+# define ISALPHANUM isAlphaNum
+# define IOERROR ioError
+# define PSEQ seq
+# define SAPPLY $!