diff --git a/Math/MFSolve.hs b/Math/MFSolve.hs
--- a/Math/MFSolve.hs
+++ b/Math/MFSolve.hs
@@ -131,7 +131,7 @@
   Const n
 
 newtype SimpleVar = SimpleVar String
-                  deriving (Eq, Ord, Generic)
+                  deriving (Eq, Ord, Generic, Typeable)
 
 -- | A mathematical expression of several variables. Several Numeric
 -- instances (`Num`, `Floating` and `Fractional`) are provided, so
@@ -589,7 +589,9 @@
 substVarLin :: (Ord v, Num n, Eq n) => (v -> Maybe (LinExpr v n)) -> LinExpr v n -> LinExpr v n
 substVarLin s (LinExpr a terms) =
   let substOne (v, c) =
-        maybe (LinExpr 0 [(v, c)]) (mulLinExpr c) (s v)
+        case s v of
+         Nothing -> LinExpr 0 [(v, c)]
+         Just expr -> mulLinExpr c expr
   in foldr (addLin.substOne) (LinExpr a []) terms
 
 substVarNonLin :: (Ord n, Ord v, Floating n) => (v -> Maybe (LinExpr v n)) -> NonLinExpr v n -> Expr v n
diff --git a/mfsolve.cabal b/mfsolve.cabal
--- a/mfsolve.cabal
+++ b/mfsolve.cabal
@@ -1,5 +1,5 @@
 Name:		mfsolve
-Version: 	0.3.1.0
+Version: 	0.3.1.2
 Synopsis:	Equation solver and calculator à la metafont
 Category: 	Math
 Copyright: 	Kristof Bastiaensen (2015)
@@ -21,7 +21,7 @@
 
 Library
   Ghc-options: -Wall
-  Build-depends: base >= 3 && < 5, unordered-containers > 0.2, hashable >= 0.1.2, mtl >= 2.2.1
+  Build-depends: base >= 3 && < 5, unordered-containers > 0.2, hashable >= 0.1.2, mtl >= 2.1.3
   Exposed-Modules:
     Math.MFSolve
   extensions: DeriveGeneric, PatternGuards, PatternSynonyms
