diff --git a/gll.cabal b/gll.cabal
--- a/gll.cabal
+++ b/gll.cabal
@@ -3,7 +3,7 @@
 
 -- The name of the package.
 name:                gll
-version:             0.4.1.1
+version:             0.4.1.2
 synopsis:            GLL parser with simple combinator interface 
 license:             BSD3
 license-file:        LICENSE
@@ -12,8 +12,8 @@
 category:            Compilers
 build-type:          Simple 
 cabal-version:       1.22
-tested-with:         GHC >= 8.2.1 && <= 8.6, GHC == 8.8.3, GHC >= 9.2.5, GHC == 9.4.3
-copyright:           Copyright (C) 2015-2023 L. Thomas van Binsbergen
+tested-with:         GHC >= 8.2.1 && <= 8.6, GHC == 8.8.3, GHC >= 9.2.5, GHC == 9.4.3, GHC == 9.6.7
+copyright:           Copyright (C) 2015-2026 L. Thomas van Binsbergen
 stability:           experimental
 homepage:            https://github.com/ltbinsbe/gll-combinators
 bug-reports:         https://github.com/ltbinsbe/gll-combinators/issues
@@ -42,13 +42,13 @@
 
 library
     hs-source-dirs  :   src
-    build-depends   :     base >=4.3.1.0 && <= 5 
-                        , containers >= 0.4
-                        , array
-                        , pretty
-                        , text
-                        , regex-applicative >= 0.3
-                        , time >= 1.8
+    build-depends   :     base >=4.3.1.0 && < 6 
+                        , containers >= 0.4 && < 0.9
+                        , array >= 0.5 && < 0.6
+                        , pretty >= 1.1 && < 1.2
+                        , text >= 2 && < 3
+                        , regex-applicative >= 0.3 && < 0.4
+                        , time >= 1.8 && < 2
     exposed-modules :     GLL.Combinators.Interface
                         , GLL.Combinators.BinaryInterface
                         , GLL.GrammarCombinators
diff --git a/src/GLL/Combinators/BinaryInterface.hs b/src/GLL/Combinators/BinaryInterface.hs
--- a/src/GLL/Combinators/BinaryInterface.hs
+++ b/src/GLL/Combinators/BinaryInterface.hs
@@ -61,30 +61,12 @@
               someSepBy, someSepBy1,someSepBy2,
      -- * Memoisation
     memo, newMemoTable, memClear, MemoTable, MemoRef, useMemoisation,
-    module GLL.Combinators.Interface
     ) where
 
 import GLL.Combinators.Interface hiding (within, (**>), (<**>), (<**), (<<<**>), (<<<**), (**>>>), (<**>>>), satisfy, (<||>), (<||), (||>), (<$$>), (<$$), (<:=>), (<:=),(<::=>), (<::=), mkNt, manySepBy, manySepBy1, manySepBy2, multiple, multipleSepBy, many, multipleSepBy1, multipleSepBy2, someSepBy, someSepBy1, someSepBy2, some, memo, some1, many1, multiple1, shortest_match, longest_match, (<**>>), (<<**>), angles, braces, brackets, parens, within, optional, optionalWithDef, preferably, reluctantly, chooses, chooses_prec)
 import qualified GLL.Combinators.Interface as IF
 import GLL.Combinators.Options
-import GLL.Combinators.Visit.Join
-import GLL.Combinators.Visit.Sem (emptyAncestors)
-import GLL.Combinators.Memoisation
-import GLL.Combinators.Lexer
-import GLL.Types.Grammar
 import GLL.Parser hiding (parse, parseWithOptions)
-import qualified GLL.Parser as GLL
-
-import GLL.Types.TypeCompose (OO(..))
-import Control.Arrow
-import qualified Data.Array as A
-import qualified Data.IntMap as IM
-import qualified Data.Map as M
-import Data.Text (pack)
-import Data.IORef 
-import Data.Time.Clock
-import System.IO.Unsafe
-
 
 infixl 2 <:=>
 -- | 
diff --git a/src/GLL/Combinators/Interface.hs b/src/GLL/Combinators/Interface.hs
--- a/src/GLL/Combinators/Interface.hs
+++ b/src/GLL/Combinators/Interface.hs
@@ -254,7 +254,6 @@
 import GLL.Types.TypeCompose (OO(..))
 import Control.Arrow
 import qualified Data.Array as A
-import qualified Data.IntMap as IM
 import qualified Data.Map as M
 import qualified Data.Set as S
 import Data.Text (pack)
diff --git a/src/GLL/Combinators/Lexer.hs b/src/GLL/Combinators/Lexer.hs
--- a/src/GLL/Combinators/Lexer.hs
+++ b/src/GLL/Combinators/Lexer.hs
@@ -90,16 +90,20 @@
     <|> upcast . CharLit . Just <$> lCharLit
     <|> upcast . StringLit . Just <$> lStringLit
     <|> lMore
-  where     lMore = foldr ((<|>) . uncurry lToken) empty (tokens lexsets)
+  where     lMore :: SubsumesToken t => RE Char t 
+            lMore = foldr ((<|>) . uncurry lToken) empty (tokens lexsets)
 
             lChar c = upcast (Char c) <$ sym c
+            lCharacters :: SubsumesToken t => RE Char t
             lCharacters = foldr ((<|>) . lChar) empty (keychars lexsets)
 
             lKeyword k  = upcast (Keyword k) <$ string k
+            lKeywords :: SubsumesToken t => RE Char t
             lKeywords = foldr ((<|>) . lKeyword) empty (keywords lexsets)
 
 lToken t re = upcast . Token t . Just <$> re
 
+lStringLit :: RE Char String 
 lStringLit = toString <$ sym '\"' <*> many strChar <* sym '\"'
  where strChar =  sym '\\' *> sym '\"'
                   <|> psym ((/=) '\"')
diff --git a/src/GLL/Combinators/Test/BinaryInterface.hs b/src/GLL/Combinators/Test/BinaryInterface.hs
--- a/src/GLL/Combinators/Test/BinaryInterface.hs
+++ b/src/GLL/Combinators/Test/BinaryInterface.hs
@@ -51,6 +51,7 @@
                 j <- readIORef subcount
                 modifyIORef subcount succ
                 let parse_res   = parseWithParseOptions [noSelectTest] [useMemoisation] p str
+                    norm :: (Ord a, Eq a) => [a] -> [a]
                     norm        = take 100 . sort . nub
                     norm_p_res  = norm parse_res
                     b           = norm_p_res == norm res
@@ -82,6 +83,7 @@
     test Nothing "<::=>" pX [("ab",[97]),("a",[])]
 
     let  pX = "X" <:=> flip (:) <$$> pY <**> char 'a'
+         pY :: BNF Char String
          pY = "Y" <:=> (\x y -> [x,y]) <$$> char 'b' <**> char 'c'
     test Nothing "<::=> 2" pX [("bca", ["abc"]), ("cba", [])]
 
@@ -91,7 +93,8 @@
     test Nothing "<::=> <||>" pX [("ac", "a"), ("bc", "b")]
 
     --  (Right) Recursion
-    let pX = "X" <::=> (+1) <$$ char 'a' <**> pX <||> satisfy 0 
+    let pX :: BNF Char Int
+        pX = "X" <::=> (+1) <$$ char 'a' <**> pX <||> satisfy 0 
     test Nothing "rec1" pX [("", [0]), ("aa",[2]), (replicate 42 'a', [42]), ("bbb", [])]
 
     --  EBNF
@@ -102,21 +105,26 @@
     test Nothing "<||> optional" (pX <** optional (char 'z'))
                 [("az", "a"), ("bz", "b"), ("z", []), ("b", "b"), ("a", "a")]
 
-    let pX = "X" <::=> (1 <$$ optional (char 'a') <||> 2 <$$ optional (char 'b'))
+    let pX :: BNF Char Int
+        pX = "X" <::=> (1 <$$ optional (char 'a') <||> 2 <$$ optional (char 'b'))
     test Nothing "optional-ambig" (pX <** optional (char 'z'))
                 [("az", [1]), ("bz", [2]), ("z", [1,2]), ("b", [2]), ("a", [1])]
 
-    let pX = "X" <::=> id <$$ char 'a' <**> (char 'b' <||> char 'c')
+    let pX :: BNF Char Char 
+        pX = "X" <::=> id <$$ char 'a' <**> (char 'b' <||> char 'c')
     test Nothing "inline choice (1)" pX
                 [("ab", "b"), ("ac", "c"), ("a", []), ("b", [])]
 
-    let pX = "X" <::=> length <$$> multiple (char '1')
+    let pX :: BNF Char Int
+        pX = "X" <::=> length <$$> multiple (char '1')
     test Nothing "multiple" pX [("", [0]), ("11", [2]), (replicate 12 '1', [12])]
 
-    let pX = "X" <::=> length <$$> multiple1 (char '1')
+    let pX :: BNF Char Int
+        pX = "X" <::=> length <$$> multiple1 (char '1')
     test Nothing "multiple1" pX [("", []), ("11", [2]), (replicate 12 '1', [12])]
 
-    let pX = "X" <::=> 1 <$$ multiple (char 'a') <||> 2 <$$ multiple (char 'b')
+    let pX :: BNF Char Int
+        pX = "X" <::=> 1 <$$ multiple (char 'a') <||> 2 <$$ multiple (char 'b')
     test Nothing "(multiple <||> multiple) <**> optional" (pX <** optional (char 'z'))
                 [("az", [1]), ("bz", [2]), ("z", [1,2])
                 ,("", [1,2]), ("b", [2]), ("a", [1])]
@@ -130,7 +138,8 @@
             ]
 
     -- multiple with nullable argument
-    let pX = 1 <$$ char '1' <||> satisfy 0
+    let pX :: BNF Char Int
+        pX = 1 <$$ char '1' <||> satisfy 0
     test Nothing "multiple (nullable arg)" 
         (multiple pX) [("11", [[1,1]]), ("",[[]]), ("e", [])]
 
@@ -142,25 +151,29 @@
                     ,("aa", ["ab"])]
 
     let pX = (\x y -> [x,y]) <$$ char 'a' <**> pL <**> pL <** char 'e'
+        pL :: BNF Char Int
         pL =    1 <$$ char 'b'
             <||> 2 <$$ char 'b' <** char 'c'
             <||> 3 <$$ char 'c' <** char 'd'
             <||> 4 <$$ char 'd'
     test Nothing "longambig" pX [("abcde", [[1,3],[2,4]]), ("abcdd", [])]
 
-    let pX = "X" <::=> (1 <$$ multiple1 (char 'a') <||> 2 <$$ multiple (char 'b'))
+    let pX :: BNF Char Int
+        pX = "X" <::=> (1 <$$ multiple1 (char 'a') <||> 2 <$$ multiple (char 'b'))
         pY = "Y" <::=> (+) <$$> pX <**> pY
                    <||> satisfy 0
     test Nothing "multiple1 & multiple & recursion + ambiguities" pY
         [("ab", [3]),("aa", [1,2]), (replicate 10 'a', [1..10])]
 
-    let pX = "X" <::=>  1 <$$ char 'a' <||> satisfy 0
+    let pX :: BNF Char Int
+        pX = "X" <::=>  1 <$$ char 'a' <||> satisfy 0
         pY = "Y" <::=> (+) <$$> pX <**> pY
     -- shouldn't this be 1 + infinite 0's?
     test Nothing "no parse infinite rec?" pY 
         [("a", [])]
 
-    let pS = "S" <::=> ((\x y -> x+y+1) <$$ char '1' <**> pS <**> pS) <||> satisfy 0    
+    let pS :: BNF Char Int
+        pS = "S" <::=> ((\x y -> x+y+1) <$$ char '1' <**> pS <**> pS) <||> satisfy 0    
     test Nothing "aho_S" pS [("", [0]), ("1", [1]), (replicate 5 '1', [5])]
 
 
@@ -168,7 +181,8 @@
     test Nothing "aho_S" pS [("", ["0"]), ("1", ["100"]), ("11", ["10100", "11000"])
                     ,(replicate 5 '1', aho_S_5)]
 
-    let pE = "E" <::=> (\x y z -> x+y+z) <$$> pE <**> pE <**> pE 
+    let pE :: BNF Char Int
+        pE = "E" <::=> (\x y z -> x+y+z) <$$> pE <**> pE <**> pE 
                              <||> 1 <$$ char '1'
                              <||> satisfy 0
     test Nothing "EEE" pE [("", [0]), ("1", [1]), ("11", [2])
@@ -180,19 +194,23 @@
     test Nothing "EEE ambig" pE [("", ["0"]), ("1", ["1"])
                         ,("11", ["110", "011", "101"]), ("111", _EEE_3)]
 
-    let pX = "X" <::=>  maybe 0 (const 1) <$$> optional (char 'z') 
+    let pX :: BNF Char Int
+        pX = "X" <::=>  maybe 0 (const 1) <$$> optional (char 'z') 
                     <||> (+1) <$$> pX <** char '1'
     test Nothing "simple left-recursion" pX [("", [0]), ("z11", [3]), ("z", [1])
                                     ,(replicate 100 '1', [100])]
 
-    let pX = "X" <::=> satisfy 0 
+    let pX :: BNF Char Int
+        pX = "X" <::=> satisfy 0 
                     <||> (+1) <$$ pB <**> pX <** char '1'
+        pB :: BNF Char Int 
         pB = maybe 0 (const 0) <$$> optional (char 'z')
     test Nothing "hidden left-recursion" pX 
         [("", [0]), ("zz11", [2]), ("z11", [2]), ("11", [2])
         ,(replicate 100 '1', [100])]
 
     let pX = "X" <::=> (+) <$$> pY <**> pA
+        pA :: BNF Char Int 
         pA = 1 <$$ char 'a' <** char 'b' <||> satisfy 0
         pY = "Y" <::=> satisfy 0 <||> pX 
     test Nothing "hidden left-recursion + infinite derivations" pX
@@ -201,6 +219,7 @@
     putStrLn "Tests that use memoisation"
 
     let tab = newMemoTable
+        pX :: BNF Char Int
         pX = "X" <::=> (1 <$$ multiple1 (char 'a') <||> 2 <$$ multiple (char 'b'))
         pY = memo tab ("Y" <::=> (+) <$$> pX <**> pY
                    <||> satisfy 0)
@@ -208,6 +227,7 @@
         [("ab", [3]),("aa", [1,2]), (replicate 10 'a', [1..10])]
 
     let tab = newMemoTable 
+        pX :: BNF Char Int
         pX = "X" <::=>  1 <$$ char 'a' <||> satisfy 0
         pY = memo tab ("Y" <::=> (+) <$$> pX <**> pY)
     -- shouldn't this be 1 + infinite 0's?
@@ -216,6 +236,7 @@
 
     --  Higher ambiguities
     let tab = newMemoTable
+        pE :: BNF Char Int
         pE = memo tab ("E" <::=> (\x y z -> x+y+z) <$$> pE <**> pE <**> pE 
                              <||> 1 <$$ char '1'
                              <||> satisfy 0)
@@ -224,6 +245,7 @@
 
     let tab = newMemoTable
         pX = "X" <::=> (+) <$$> pY <**> pA
+        pA :: BNF Char Int
         pA = 1 <$$ char 'a' <** char 'b' <||> satisfy 0
         pY = memo tab ("Y" <::=> satisfy 0 <||> pX)
     test (Just tab) "hidden left-recursion + infinite derivations" pX
@@ -241,12 +263,14 @@
     test Nothing "A>A" pX   [("aaa", ["abb"]),("aa", ["ab"])] 
 
     let pX = "X" <:=> multiple pY
-         where pY = 1 <$$ char '1' <||> 2 <$$ char '1' <** char '1'
+         where pY :: BNF Char Int
+               pY = 1 <$$ char '1' <||> 2 <$$ char '1' <** char '1'
     test Nothing "multiple" pX 
       [("", [[]]), ("1", [[1]]), ("11", [[1,1],[2]]), ("111", [[1,1,1], [2,1], [1,2]])]
 
     let pX = "X" <:=> some pY
-         where pY = 1 <$$ char '1' <||> 2 <$$ char '1' <** char '1'
+         where pY :: BNF Char Int
+               pY = 1 <$$ char '1' <||> 2 <$$ char '1' <** char '1'
     test Nothing "some" pX 
       [("", [[]]), ("1", [[1]]), ("11", [[2]]), ("111", [[2,1]])]
 
@@ -259,7 +283,8 @@
 -}
 
     let pX = "X" <:=> many pY
-         where pY = 1 <$$ char '1' <||> 2 <$$ char '1' <** char '1'
+         where pY :: BNF Char Int 
+               pY = 1 <$$ char '1' <||> 2 <$$ char '1' <** char '1'
     test Nothing "many" pX 
       [("", [[]]), ("1", [[1]]), ("11", [[1,1]]), ("111", [[1,1,1]])]
  
diff --git a/src/GLL/Combinators/Test/Interface.hs b/src/GLL/Combinators/Test/Interface.hs
--- a/src/GLL/Combinators/Test/Interface.hs
+++ b/src/GLL/Combinators/Test/Interface.hs
@@ -51,6 +51,7 @@
                 j <- readIORef subcount
                 modifyIORef subcount succ
                 let parse_res   = parseWithParseOptions [noSelectTest] [useMemoisation] p str
+                    norm  :: (Eq a, Ord a) => [a] -> [a]
                     norm        = take 100 . sort . nub
                     norm_p_res  = norm parse_res
                     b           = norm_p_res == norm res
@@ -91,7 +92,8 @@
     test Nothing "<::=> <||>" pX [("ac", "a"), ("bc", "b")]
 
     --  (Right) Recursion
-    let pX = "X" <::=> (+1) <$$ char 'a' <**> pX <||> satisfy 0 
+    let pX :: BNF Char Int
+        pX = "X" <::=> (+1) <$$ char 'a' <**> pX <||> satisfy 0 
     test Nothing "rec1" pX [("", [0]), ("aa",[2]), (replicate 42 'a', [42]), ("bbb", [])]
 
     --  EBNF
@@ -102,7 +104,8 @@
     test Nothing "<||> optional" (pX <** optional (char 'z'))
                 [("az", "a"), ("bz", "b"), ("z", []), ("b", "b"), ("a", "a")]
 
-    let pX = "X" <::=> (1 <$$ optional (char 'a') <||> 2 <$$ optional (char 'b'))
+    let pX :: BNF Char Int
+        pX = "X" <::=> (1 <$$ optional (char 'a') <||> 2 <$$ optional (char 'b'))
     test Nothing "optional-ambig" (pX <** optional (char 'z'))
                 [("az", [1]), ("bz", [2]), ("z", [1,2]), ("b", [2]), ("a", [1])]
 
@@ -116,7 +119,8 @@
     let pX = "X" <::=> length <$$> multiple1 (char '1')
     test Nothing "multiple1" pX [("", []), ("11", [2]), (replicate 12 '1', [12])]
 
-    let pX = "X" <::=> 1 <$$ multiple (char 'a') <||> 2 <$$ multiple (char 'b')
+    let pX :: BNF Char Int
+        pX = "X" <::=> 1 <$$ multiple (char 'a') <||> 2 <$$ multiple (char 'b')
     test Nothing "(multiple <||> multiple) <**> optional" (pX <** optional (char 'z'))
                 [("az", [1]), ("bz", [2]), ("z", [1,2])
                 ,("", [1,2]), ("b", [2]), ("a", [1])]
@@ -130,7 +134,8 @@
             ]
 
     -- multiple with nullable argument
-    let pX = 1 <$$ char '1' <||> satisfy 0
+    let pX :: AltExprs Char Int
+        pX = 1 <$$ char '1' <||> satisfy 0
     test Nothing "multiple (nullable arg)" 
         (multiple pX) [("11", [[1,1]]), ("",[[]]), ("e", [])]
 
@@ -142,25 +147,29 @@
                     ,("aa", ["ab"])]
 
     let pX = (\x y -> [x,y]) <$$ char 'a' <**> pL <**> pL <** char 'e'
-        pL =    1 <$$ char 'b'
+        pL :: AltExprs Char Int
+        pL =     1 <$$ char 'b'
             <||> 2 <$$ char 'b' <** char 'c'
             <||> 3 <$$ char 'c' <** char 'd'
             <||> 4 <$$ char 'd'
     test Nothing "longambig" pX [("abcde", [[1,3],[2,4]]), ("abcdd", [])]
 
-    let pX = "X" <::=> (1 <$$ multiple1 (char 'a') <||> 2 <$$ multiple (char 'b'))
+    let pX :: BNF Char Int
+        pX = "X" <::=> (1 <$$ multiple1 (char 'a') <||> 2 <$$ multiple (char 'b'))
         pY = "Y" <::=> (+) <$$> pX <**> pY
                    <||> satisfy 0
     test Nothing "multiple1 & multiple & recursion + ambiguities" pY
         [("ab", [3]),("aa", [1,2]), (replicate 10 'a', [1..10])]
 
-    let pX = "X" <::=>  1 <$$ char 'a' <||> satisfy 0
+    let pX :: BNF Char Int
+        pX = "X" <::=>  1 <$$ char 'a' <||> satisfy 0
         pY = "Y" <::=> (+) <$$> pX <**> pY
     -- shouldn't this be 1 + infinite 0's?
     test Nothing "no parse infinite rec?" pY 
         [("a", [])]
 
-    let pS = "S" <::=> ((\x y -> x+y+1) <$$ char '1' <**> pS <**> pS) <||> satisfy 0    
+    let pS :: BNF Char Int
+        pS = "S" <::=> ((\x y -> x+y+1) <$$ char '1' <**> pS <**> pS) <||> satisfy 0    
     test Nothing "aho_S" pS [("", [0]), ("1", [1]), (replicate 5 '1', [5])]
 
 
@@ -168,7 +177,8 @@
     test Nothing "aho_S" pS [("", ["0"]), ("1", ["100"]), ("11", ["10100", "11000"])
                     ,(replicate 5 '1', aho_S_5)]
 
-    let pE = "E" <::=> (\x y z -> x+y+z) <$$> pE <**> pE <**> pE 
+    let pE :: BNF Char Int
+        pE = "E" <::=> (\x y z -> x+y+z) <$$> pE <**> pE <**> pE 
                              <||> 1 <$$ char '1'
                              <||> satisfy 0
     test Nothing "EEE" pE [("", [0]), ("1", [1]), ("11", [2])
@@ -180,19 +190,23 @@
     test Nothing "EEE ambig" pE [("", ["0"]), ("1", ["1"])
                         ,("11", ["110", "011", "101"]), ("111", _EEE_3)]
 
-    let pX = "X" <::=>  maybe 0 (const 1) <$$> optional (char 'z') 
+    let pX :: BNF Char Int
+        pX = "X" <::=>  maybe 0 (const 1) <$$> optional (char 'z') 
                     <||> (+1) <$$> pX <** char '1'
     test Nothing "simple left-recursion" pX [("", [0]), ("z11", [3]), ("z", [1])
                                     ,(replicate 100 '1', [100])]
 
-    let pX = "X" <::=> satisfy 0 
+    let pX :: BNF Char Int
+        pX = "X" <::=> satisfy 0 
                     <||> (+1) <$$ pB <**> pX <** char '1'
+        pB :: AltExpr Char Int
         pB = maybe 0 (const 0) <$$> optional (char 'z')
     test Nothing "hidden left-recursion" pX 
         [("", [0]), ("zz11", [2]), ("z11", [2]), ("11", [2])
         ,(replicate 100 '1', [100])]
 
     let pX = "X" <::=> (+) <$$> pY <**> pA
+        pA :: AltExprs Char Int
         pA = 1 <$$ char 'a' <** char 'b' <||> satisfy 0
         pY = "Y" <::=> satisfy 0 <||> pX 
     test Nothing "hidden left-recursion + infinite derivations" pX
@@ -201,6 +215,7 @@
     putStrLn "Tests that use memoisation"
 
     let tab = newMemoTable
+        pX :: BNF Char Int
         pX = "X" <::=> (1 <$$ multiple1 (char 'a') <||> 2 <$$ multiple (char 'b'))
         pY = memo tab ("Y" <::=> (+) <$$> pX <**> pY
                    <||> satisfy 0)
@@ -208,6 +223,7 @@
         [("ab", [3]),("aa", [1,2]), (replicate 10 'a', [1..10])]
 
     let tab = newMemoTable 
+        pX :: BNF Char Int
         pX = "X" <::=>  1 <$$ char 'a' <||> satisfy 0
         pY = memo tab ("Y" <::=> (+) <$$> pX <**> pY)
     -- shouldn't this be 1 + infinite 0's?
@@ -216,6 +232,7 @@
 
     --  Higher ambiguities
     let tab = newMemoTable
+        pE :: BNF Char Int
         pE = memo tab ("E" <::=> (\x y z -> x+y+z) <$$> pE <**> pE <**> pE 
                              <||> 1 <$$ char '1'
                              <||> satisfy 0)
@@ -224,6 +241,7 @@
 
     let tab = newMemoTable
         pX = "X" <::=> (+) <$$> pY <**> pA
+        pA :: AltExprs Char Int
         pA = 1 <$$ char 'a' <** char 'b' <||> satisfy 0
         pY = memo tab ("Y" <::=> satisfy 0 <||> pX)
     test (Just tab) "hidden left-recursion + infinite derivations" pX
@@ -241,12 +259,14 @@
     test Nothing "A>A" pX   [("aaa", ["abb"]),("aa", ["ab"])] 
 
     let pX = "X" <:=> multiple pY
-         where pY = 1 <$$ char '1' <||> 2 <$$ char '1' <** char '1'
+         where pY :: AltExprs Char Int
+               pY = 1 <$$ char '1' <||> 2 <$$ char '1' <** char '1'
     test Nothing "multiple" pX 
       [("", [[]]), ("1", [[1]]), ("11", [[1,1],[2]]), ("111", [[1,1,1], [2,1], [1,2]])]
 
     let pX = "X" <:=> some pY
-         where pY = 1 <$$ char '1' <||> 2 <$$ char '1' <** char '1'
+         where pY :: AltExprs Char Int
+               pY = 1 <$$ char '1' <||> 2 <$$ char '1' <** char '1'
     test Nothing "some" pX 
       [("", [[]]), ("1", [[1]]), ("11", [[2]]), ("111", [[2,1]])]
 
@@ -259,7 +279,8 @@
 -}
 
     let pX = "X" <:=> many pY
-         where pY = 1 <$$ char '1' <||> 2 <$$ char '1' <** char '1'
+         where pY :: AltExprs Char Int
+               pY = 1 <$$ char '1' <||> 2 <$$ char '1' <** char '1'
     test Nothing "many" pX 
       [("", [[]]), ("1", [[1]]), ("11", [[1,1]]), ("111", [[1,1,1]])]
  
diff --git a/src/GLL/Combinators/Visit/Join.hs b/src/GLL/Combinators/Visit/Join.hs
--- a/src/GLL/Combinators/Visit/Join.hs
+++ b/src/GLL/Combinators/Visit/Join.hs
@@ -2,7 +2,6 @@
 
 module GLL.Combinators.Visit.Join where
 
-import GLL.Types.Derivations
 import GLL.Types.Grammar
 import GLL.Combinators.Visit.Sem
 import GLL.Combinators.Visit.Grammar
diff --git a/src/GLL/Combinators/Visit/Sem.hs b/src/GLL/Combinators/Visit/Sem.hs
--- a/src/GLL/Combinators/Visit/Sem.hs
+++ b/src/GLL/Combinators/Visit/Sem.hs
@@ -7,7 +7,6 @@
 
 import Control.Monad (forM)
 import qualified Data.Array as A
-import qualified Data.IntMap as IM
 import qualified Data.Set as S
 
 type Sem_Symb t a = PCOptions -> Ancestors t 
diff --git a/src/GLL/Parser.hs b/src/GLL/Parser.hs
--- a/src/GLL/Parser.hs
+++ b/src/GLL/Parser.hs
@@ -177,7 +177,6 @@
 
 import Data.Foldable hiding (forM_, toList, sum)
 import Prelude  hiding (lookup, foldr, fmap, foldl, elem, any, concatMap)
-import Control.Applicative 
 import Control.Monad
 import qualified Data.IntMap as IM
 import qualified Data.Map as M
@@ -325,11 +324,10 @@
 
 instance Applicative (GLL t) where
     (<*>) = ap
-    pure  = return
+    pure v = GLL $ \_ p -> (v, p)
 instance Functor (GLL t) where
     fmap  = liftM
 instance Monad (GLL t) where
-    return a = GLL $ \_ p -> (a, p)
     (GLL m) >>= f  = GLL $ \o p -> let (a, p')  = m o p
                                        (GLL m') = f a
                                     in m' o p'
@@ -372,6 +370,7 @@
 gll flags m debug (start, prods) input = 
     (runGLL (pLhs (start, 0)) flags context, selects, follows)
  where 
+    context :: (Ord t) => Mutable t 
     context = Mutable emptySPPF [] IM.empty IM.empty IM.empty IM.empty counters
     counters = Counters 0 0
 
@@ -452,7 +451,8 @@
                       | otherwise = True
     altsOf x          = prodMap M.! x
     merge m1 m2 = IM.unionWith inner m1 m2
-     where inner  = IM.unionWith S.union 
+     where inner :: (Ord t) => IM.IntMap (S.Set t) -> IM.IntMap (S.Set t) -> IM.IntMap (S.Set t)
+           inner  = IM.unionWith S.union  
 
 count_pnode :: GLL t ()
 count_pnode = GLL $ \flags mut -> 
diff --git a/src/GLL/Types/Grammar.hs b/src/GLL/Types/Grammar.hs
--- a/src/GLL/Types/Grammar.hs
+++ b/src/GLL/Types/Grammar.hs
@@ -4,7 +4,7 @@
 -- UUAGC 0.9.52.1 (src/GLL/Types/Abstract.ag)
 module GLL.Types.Grammar where
 
-import Data.Text
+import Data.Text hiding (show)
 
 -- | Identifier for nonterminals.
 type Nt  = Text 
diff --git a/src/GLL/Types/TypeCompose.hs b/src/GLL/Types/TypeCompose.hs
--- a/src/GLL/Types/TypeCompose.hs
+++ b/src/GLL/Types/TypeCompose.hs
@@ -6,7 +6,7 @@
 
 import Control.Arrow (Arrow(..))
 import Control.Category (Category(..))
-import Control.Applicative (liftA, liftA2)
+import Control.Applicative (liftA)
 
 -- | Composition of type constructors: unary with binary.  Called
 -- "StaticArrow" in [1].
