diff --git a/Changelog.txt b/Changelog.txt
--- a/Changelog.txt
+++ b/Changelog.txt
@@ -1,3 +1,6 @@
+Fri Jan 27 11:07:48 PST 2012  paul@thev.net
+  * merge the source of StateT into Setup.hs since mtl is not a default library; bump up version
+
 Sat Jan 21 01:08:46 PST 2012  paul@thev.net
   * update API doc for windowCloseCallback
 
diff --git a/GLFW.cabal b/GLFW.cabal
--- a/GLFW.cabal
+++ b/GLFW.cabal
@@ -1,5 +1,5 @@
 name:          GLFW
-version:       0.5.0.0
+version:       0.5.0.1
 homepage:      http://haskell.org/haskellwiki/GLFW
 maintainer:    Paul H. Liu <paul@thev.net>, Marc Sunet <jeannekamikaze@gmail.com>
 cabal-version: >= 1.10
diff --git a/Setup.hs b/Setup.hs
--- a/Setup.hs
+++ b/Setup.hs
@@ -1,4 +1,5 @@
 {- source partly taken from http://wewantarock.wordpress.com/tag/cabal/ -}
+{-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies, FlexibleInstances #-}
 module Main (main) where
 
 import Distribution.Simple
@@ -9,15 +10,16 @@
 import Distribution.Verbosity
 import Distribution.PackageDescription
 import Distribution.System
+import System.Exit 
 import System.FilePath
 import System.Directory
-import Control.Monad.State
-import Control.Monad.Trans.Class (lift)
 import System.IO (hClose, hPutStr)
 import System.Cmd (rawSystem)
 import Data.Maybe (fromJust)
 import Foreign (bitSize)
-import System.Exit 
+import Control.Monad (when)
+--import Control.Monad.State 
+--import Control.Monad.Trans.Class (lift)
 
 main :: IO ()
 main = defaultMainWithHooks $ simpleUserHooks 
@@ -226,4 +228,28 @@
             ,"#endif"
             ,"int main() { return 0; }"
             ]
+
+-- Since we cannot specify that only Setup.hs depends on mtl, we include StateT here.
+
+newtype StateT s m a = StateT { runStateT :: s -> m (a,s) }
+execStateT m s = fmap snd $ runStateT m s 
+class (Monad m) => MonadState s m | m -> s where
+    get :: m s
+    put :: s -> m () 
+class MonadTrans t where 
+    lift :: Monad m => m a -> t m a
+modify f = get >>= put . f
+instance (Monad m) => Monad (StateT s m) where
+    return a = StateT $ \s -> return (a, s)
+    m >>= k  = StateT $ \s -> do
+        ~(a, s') <- runStateT m s 
+        runStateT (k a) s'
+    fail str = StateT $ \_ -> fail str 
+instance MonadTrans (StateT s) where
+    lift m = StateT $ \s -> do
+        a <- m
+        return (a, s)
+instance (Monad m) => MonadState s (StateT s m) where
+    get   = StateT $ \s -> return (s, s)                                                                               
+    put s = StateT $ \_ -> return ((), s)
 
