diff --git a/src/Text/RegExp/Matching.hs b/src/Text/RegExp/Matching.hs
--- a/src/Text/RegExp/Matching.hs
+++ b/src/Text/RegExp/Matching.hs
@@ -5,6 +5,10 @@
 import Data.Semiring
 import Text.RegExp.Data
 
+import Text.RegExp.Matching.Leftmost.Type
+import Text.RegExp.Matching.Longest.Type
+import Text.RegExp.Matching.LeftLong.Type
+
 -- |
 -- Checks whether a regular expression matches the given word. For
 -- example, @acceptFull (fromString \"b|abc\") \"b\"@ yields @True@
@@ -47,6 +51,9 @@
 {-# SPECIALIZE fullMatch :: RegExp c -> [c] -> Bool #-}
 {-# SPECIALIZE fullMatch :: RegExp c -> [c] -> Numeric Int #-}
 {-# SPECIALIZE fullMatch :: Num a => RegExp c -> [c] -> Numeric a #-}
+{-# SPECIALIZE fullMatch :: RegExp c -> [(Int,c)] -> Leftmost #-}
+{-# SPECIALIZE fullMatch :: RegExp c -> [c] -> Longest #-}
+{-# SPECIALIZE fullMatch :: RegExp c -> [(Int,c)] -> LeftLong #-}
 
 -- |
 -- Matches a regular expression against substrings of a word computing
@@ -61,6 +68,9 @@
 {-# SPECIALIZE partialMatch :: RegExp c -> [c] -> Bool #-}
 {-# SPECIALIZE partialMatch :: RegExp c -> [c] -> Numeric Int #-}
 {-# SPECIALIZE partialMatch :: Num a => RegExp c -> [c] -> Numeric a #-}
+{-# SPECIALIZE partialMatch :: RegExp c -> [(Int,c)] -> Leftmost #-}
+{-# SPECIALIZE partialMatch :: RegExp c -> [c] -> Longest #-}
+{-# SPECIALIZE partialMatch :: RegExp c -> [(Int,c)] -> LeftLong #-}
 
 matchW :: Semiring w => RegW w c -> [c] -> w
 matchW r []     = empty r
@@ -69,6 +79,9 @@
 {-# SPECIALIZE matchW :: RegW Bool c -> [c] -> Bool #-}
 {-# SPECIALIZE matchW :: RegW (Numeric Int) c -> [c] -> Numeric Int #-}
 {-# SPECIALIZE matchW :: Num a => RegW (Numeric a) c -> [c] -> Numeric a #-}
+{-# SPECIALIZE matchW :: RegW Leftmost (Int,c) -> [(Int,c)] -> Leftmost #-}
+{-# SPECIALIZE matchW :: RegW Longest c -> [c] -> Longest #-}
+{-# SPECIALIZE matchW :: RegW LeftLong (Int,c) -> [(Int,c)] -> LeftLong #-}
 
 shiftW :: Semiring w => w -> RegW w c -> c -> RegW w c
 shiftW w r c | active r || w /= zero = shift w (reg r) c
diff --git a/src/Text/RegExp/Matching/LeftLong.hs b/src/Text/RegExp/Matching/LeftLong.hs
--- a/src/Text/RegExp/Matching/LeftLong.hs
+++ b/src/Text/RegExp/Matching/LeftLong.hs
@@ -1,5 +1,3 @@
-{-# LANGUAGE MultiParamTypeClasses, FlexibleContexts, FlexibleInstances #-}
-
 -- |
 -- Module      : Text.RegExp.Matching.LeftLong
 -- Copyright   : Thomas Wilke, Frank Huch, and Sebastian Fischer
@@ -13,13 +11,16 @@
 -- 
 module Text.RegExp.Matching.LeftLong (
 
-  LeftLong(..), Matching(..),
+  matching, 
 
-  matching, getLeftLong
+  Matching, matchingIndex, matchingLength,
 
+  LeftLong, getLeftLong
+
   ) where
 
 import Text.RegExp
+import Text.RegExp.Matching.LeftLong.Type
 
 -- |
 -- Subwords of words that match a regular expression are represented
@@ -50,40 +51,8 @@
 matching :: RegExp c -> [c] -> Maybe Matching
 matching r = getLeftLong . partialMatch r . zip [(0::Int)..]
 
--- | 
--- Semiring used for leftmost longest matching.
--- 
--- The `LeftLong` type satisfies the distributive laws only with a
--- precondition on all involved multiplications: multiplied matches
--- must be adjacent and the start position must be smaller than the
--- end position. This precondition is satisfied for all
--- multiplications during regular expression matching.
--- 
-data LeftLong = Zero | One | LeftLong !Int !Int
- deriving (Eq,Show)
-
 getLeftLong :: LeftLong -> Maybe Matching
 getLeftLong Zero            =  Nothing
 getLeftLong One             =  Just $ Matching 0 0
 getLeftLong (LeftLong x y)  =  Just $ Matching x (y-x+1)
-
-instance Semiring LeftLong where
-  zero = Zero; one = One
-
-  Zero          .+.  y             =  y
-  x             .+.  Zero          =  x
-  One           .+.  y             =  y
-  x             .+.  One           =  x
-  LeftLong a b  .+.  LeftLong c d
-    | a<c || a==c && b>=d          =  LeftLong a b
-    | otherwise                    =  LeftLong c d
-
-  Zero          .*.  _             =  Zero
-  _             .*.  Zero          =  Zero
-  One           .*.  y             =  y
-  x             .*.  One           =  x
-  LeftLong a _  .*.  LeftLong _ b  =  LeftLong a b
-
-instance Weight c (Int,c) LeftLong where
-  symWeight p (n,c) = p c .*. LeftLong n n
 
diff --git a/src/Text/RegExp/Matching/LeftLong/Type.hs b/src/Text/RegExp/Matching/LeftLong/Type.hs
new file mode 100644
--- /dev/null
+++ b/src/Text/RegExp/Matching/LeftLong/Type.hs
@@ -0,0 +1,39 @@
+{-# LANGUAGE MultiParamTypeClasses, FlexibleInstances #-}
+
+module Text.RegExp.Matching.LeftLong.Type where
+
+import Data.Semiring
+import Text.RegExp.Data
+
+-- | 
+-- Semiring used for leftmost longest matching.
+-- 
+-- The `LeftLong` type satisfies the distributive laws only with a
+-- precondition on all involved multiplications: multiplied matches
+-- must be adjacent and the start position must be smaller than the
+-- end position. This precondition is satisfied for all
+-- multiplications during regular expression matching.
+-- 
+data LeftLong = Zero | One | LeftLong !Int !Int
+ deriving (Eq,Show)
+
+instance Semiring LeftLong where
+  zero = Zero; one = One
+
+  Zero          .+.  y             =  y
+  x             .+.  Zero          =  x
+  One           .+.  y             =  y
+  x             .+.  One           =  x
+  LeftLong a b  .+.  LeftLong c d
+    | a<c || a==c && b>=d          =  LeftLong a b
+    | otherwise                    =  LeftLong c d
+
+  Zero          .*.  _             =  Zero
+  _             .*.  Zero          =  Zero
+  One           .*.  y             =  y
+  x             .*.  One           =  x
+  LeftLong a _  .*.  LeftLong _ b  =  LeftLong a b
+
+instance Weight c (Int,c) LeftLong where
+  symWeight p (n,c) = p c .*. LeftLong n n
+
diff --git a/src/Text/RegExp/Matching/Leftmost.hs b/src/Text/RegExp/Matching/Leftmost.hs
--- a/src/Text/RegExp/Matching/Leftmost.hs
+++ b/src/Text/RegExp/Matching/Leftmost.hs
@@ -1,5 +1,3 @@
-{-# LANGUAGE MultiParamTypeClasses, FlexibleContexts, FlexibleInstances #-}
-
 -- |
 -- Module      : Text.RegExp.Matching.Leftmost
 -- Copyright   : Thomas Wilke, Frank Huch, and Sebastian Fischer
@@ -13,13 +11,16 @@
 -- 
 module Text.RegExp.Matching.Leftmost (
 
-  Leftmost(..), Matching(..),
+  matching, 
 
-  matching, getLeftmost
+  Matching, matchingIndex,
 
+  Leftmost, getLeftmost
+
   ) where
 
 import Text.RegExp
+import Text.RegExp.Matching.Leftmost.Type
 
 -- |
 -- A 'Matching' records the leftmost start index of a matching subword.
@@ -45,30 +46,7 @@
 matching :: RegExp c -> [c] -> Maybe Matching
 matching r = getLeftmost . partialMatch r . zip [(0::Int)..]
 
--- | Semiring used for leftmost matching.
--- 
-data Leftmost = Zero | One | Leftmost !Int
- deriving (Eq,Show)
-
 getLeftmost :: Leftmost -> Maybe Matching
 getLeftmost Zero          =  Nothing
 getLeftmost One           =  Just $ Matching 0 
 getLeftmost (Leftmost x)  =  Just $ Matching x
-
-instance Semiring Leftmost where
-  zero = Zero; one = One
-
-  Zero        .+.  y           =  y
-  x           .+.  Zero        =  x
-  One         .+.  y           =  y
-  x           .+.  One         =  x
-  Leftmost a  .+.  Leftmost b  =  Leftmost (min a b)
-
-  Zero        .*.  _           =  Zero
-  _           .*.  Zero        =  Zero
-  One         .*.  y           =  y
-  x           .*.  One         =  x
-  Leftmost a  .*.  Leftmost b  =  Leftmost (min a b)
-
-instance Weight c (Int,c) Leftmost where
-  symWeight p (n,c) = p c .*. Leftmost n
diff --git a/src/Text/RegExp/Matching/Leftmost/Type.hs b/src/Text/RegExp/Matching/Leftmost/Type.hs
new file mode 100644
--- /dev/null
+++ b/src/Text/RegExp/Matching/Leftmost/Type.hs
@@ -0,0 +1,29 @@
+{-# LANGUAGE MultiParamTypeClasses, FlexibleInstances #-}
+
+module Text.RegExp.Matching.Leftmost.Type where
+
+import Data.Semiring
+import Text.RegExp.Data
+
+-- | Semiring used for leftmost matching.
+-- 
+data Leftmost = Zero | One | Leftmost !Int
+ deriving (Eq,Show)
+
+instance Semiring Leftmost where
+  zero = Zero; one = One
+
+  Zero        .+.  y           =  y
+  x           .+.  Zero        =  x
+  One         .+.  y           =  y
+  x           .+.  One         =  x
+  Leftmost a  .+.  Leftmost b  =  Leftmost (min a b)
+
+  Zero        .*.  _           =  Zero
+  _           .*.  Zero        =  Zero
+  One         .*.  y           =  y
+  x           .*.  One         =  x
+  Leftmost a  .*.  Leftmost b  =  Leftmost (min a b)
+
+instance Weight c (Int,c) Leftmost where
+  symWeight p (n,c) = p c .*. Leftmost n
diff --git a/src/Text/RegExp/Matching/Longest.hs b/src/Text/RegExp/Matching/Longest.hs
--- a/src/Text/RegExp/Matching/Longest.hs
+++ b/src/Text/RegExp/Matching/Longest.hs
@@ -1,4 +1,4 @@
-{-# LANGUAGE MultiParamTypeClasses, FlexibleContexts, FlexibleInstances #-}
+{-# LANGUAGE MultiParamTypeClasses, FlexibleInstances #-}
 
 -- |
 -- Module      : Text.RegExp.Matching.Longest
@@ -13,16 +13,19 @@
 -- 
 module Text.RegExp.Matching.Longest (
 
-  Longest(..), Matching(..),
+  matching, 
 
-  matching, getLongest
+  Matching, matchingLength,
 
+  Longest, getLongest
+
   ) where
 
 import Text.RegExp
+import Text.RegExp.Matching.Longest.Type
 
 -- |
--- A 'Matching' records the leftmost start index of a matching subword.
+-- A 'Matching' records the largest length of a matching subword.
 -- 
 data Matching = Matching {
  
@@ -44,30 +47,7 @@
 matching :: RegExp c -> [c] -> Maybe Matching
 matching r = getLongest . partialMatch r
 
--- | Semiring used for longest matching.
--- 
-data Longest = Zero | One | Longest !Int
- deriving (Eq,Show)
-
 getLongest :: Longest -> Maybe Matching
 getLongest Zero         =  Nothing
 getLongest One          =  Just $ Matching 0 
 getLongest (Longest x)  =  Just $ Matching x
-
-instance Semiring Longest where
-  zero = Zero; one = One
-
-  Zero       .+.  y          =  y
-  x          .+.  Zero       =  x
-  One        .+.  y          =  y
-  x          .+.  One        =  x
-  Longest a  .+.  Longest b  =  Longest (max a b)
-
-  Zero       .*.  _          =  Zero
-  _          .*.  Zero       =  Zero
-  One        .*.  y          =  y
-  x          .*.  One        =  x
-  Longest a  .*.  Longest b  =  Longest (a+b)
-
-instance Weight c c Longest where
-  symWeight p c = p c .*. Longest 1
diff --git a/src/Text/RegExp/Matching/Longest/Type.hs b/src/Text/RegExp/Matching/Longest/Type.hs
new file mode 100644
--- /dev/null
+++ b/src/Text/RegExp/Matching/Longest/Type.hs
@@ -0,0 +1,27 @@
+module Text.RegExp.Matching.Longest.Type where
+
+import Data.Semiring
+import Text.RegExp.Data
+
+-- | Semiring used for longest matching.
+-- 
+data Longest = Zero | One | Longest !Int
+ deriving (Eq,Show)
+
+instance Semiring Longest where
+  zero = Zero; one = One
+
+  Zero       .+.  y          =  y
+  x          .+.  Zero       =  x
+  One        .+.  y          =  y
+  x          .+.  One        =  x
+  Longest a  .+.  Longest b  =  Longest (max a b)
+
+  Zero       .*.  _          =  Zero
+  _          .*.  Zero       =  Zero
+  One        .*.  y          =  y
+  x          .*.  One        =  x
+  Longest a  .*.  Longest b  =  Longest (a+b)
+
+instance Weight c c Longest where
+  symWeight p c = p c .*. Longest 1
diff --git a/src/quickcheck.lhs b/src/quickcheck.lhs
--- a/src/quickcheck.lhs
+++ b/src/quickcheck.lhs
@@ -30,9 +30,12 @@
 
 > import Text.RegExp
 > import Text.RegExp.Data
-> import Text.RegExp.Matching.Leftmost ( Leftmost(..), getLeftmost )
-> import Text.RegExp.Matching.Longest  ( Longest(..), getLongest )
-> import Text.RegExp.Matching.LeftLong ( LeftLong(..), getLeftLong )
+> import Text.RegExp.Matching.Leftmost.Type ( Leftmost(..) )
+> import Text.RegExp.Matching.Longest.Type  ( Longest(..) )
+> import Text.RegExp.Matching.LeftLong.Type ( LeftLong(..) )
+> import Text.RegExp.Matching.Leftmost ( getLeftmost )
+> import Text.RegExp.Matching.Longest  ( getLongest )
+> import Text.RegExp.Matching.LeftLong ( getLeftLong )
 > import qualified Text.RegExp.Matching.Leftmost as Leftmost
 > import qualified Text.RegExp.Matching.Longest  as Longest
 > import qualified Text.RegExp.Matching.LeftLong as LeftLong
diff --git a/weighted-regexp.cabal b/weighted-regexp.cabal
--- a/weighted-regexp.cabal
+++ b/weighted-regexp.cabal
@@ -1,5 +1,5 @@
 Name:          weighted-regexp
-Version:       0.2.0.0
+Version:       0.3.0.0
 Cabal-Version: >= 1.6
 Synopsis:      Weighted Regular Expression Matcher
 Description:
@@ -32,7 +32,10 @@
                         Data.Semiring.Properties
   Other-Modules:        Text.RegExp.Data,
                         Text.RegExp.Parser,
-                        Text.RegExp.Matching
+                        Text.RegExp.Matching,
+                        Text.RegExp.Matching.Leftmost.Type,
+                        Text.RegExp.Matching.Longest.Type,
+                        Text.RegExp.Matching.LeftLong.Type
   Extensions:           RankNTypes,
                         FlexibleContexts,
                         FlexibleInstances,
@@ -56,7 +59,10 @@
                         Data.Semiring.Properties
                         Text.RegExp.Data,
                         Text.RegExp.Parser,
-                        Text.RegExp.Matching
+                        Text.RegExp.Matching,
+                        Text.RegExp.Matching.Leftmost.Type,
+                        Text.RegExp.Matching.Longest.Type,
+                        Text.RegExp.Matching.LeftLong.Type
   Extensions:           RankNTypes,
                         FlexibleContexts,
                         FlexibleInstances,
@@ -84,7 +90,10 @@
                         Data.Semiring,
                         Text.RegExp.Data,
                         Text.RegExp.Parser,
-                        Text.RegExp.Matching
+                        Text.RegExp.Matching,
+                        Text.RegExp.Matching.Leftmost.Type,
+                        Text.RegExp.Matching.Longest.Type,
+                        Text.RegExp.Matching.LeftLong.Type
   Extensions:           RankNTypes,
                         FlexibleContexts,
                         FlexibleInstances,
