diff --git a/Language/Fay/Yesod.hs b/Language/Fay/Yesod.hs
--- a/Language/Fay/Yesod.hs
+++ b/Language/Fay/Yesod.hs
@@ -41,7 +41,7 @@
 -- | A proxy type for specifying what type a command should return. The final
 -- field for each data constructor in a command datatype should be @Returns@.
 data Returns a = Returns
-    deriving (Show, Read, Data, Typeable)
+    deriving (Eq, Show, Read, Data, Typeable)
 
 -- | Call a command.
 call :: (Returns a -> command)
diff --git a/Yesod/Fay.hs b/Yesod/Fay.hs
--- a/Yesod/Fay.hs
+++ b/Yesod/Fay.hs
@@ -319,24 +319,25 @@
         Right s -> do
             s' <- qRunIO $ yfsPostProcess settings s
             let contents = fromText (pack s') <> jsMainCall (not exportRuntime) name
-            external <-
-                case yfsExternal settings of
-                    Nothing -> return [|Nothing|]
-                    Just (fp', exp') -> do
-                        let name' = concat ["faygen-", hash, ".js"]
-                            hash = base64md5 contents'
-                            contents' = TLE.encodeUtf8 $ toLazyText contents
-                        qRunIO $ L.writeFile (concat [fp', "/", name']) contents'
-                        return [| Just ($(return exp'), name') |]
 
-            [| do
-                maybeRequireJQuery needJQuery
-                $(requireFayRuntime settings)
-                case $external of
-                    Nothing -> toWidget $ const $ Javascript $ fromText $ pack
-                               $(return $ LitE $ StringL $ TL.unpack $ toLazyText contents)
-                    Just (constructor, name') -> addScript $ constructor $ StaticRoute [name'] []
-                |]
+            case yfsExternal settings of
+                Nothing ->
+                    [| do
+                        maybeRequireJQuery needJQuery
+                        $(requireFayRuntime settings)
+                        toWidget $ const $ Javascript $ fromText $ pack
+                          $(return $ LitE $ StringL $ TL.unpack $ toLazyText contents)
+                    |]
+                Just (fp', exp') -> do
+                    let name' = concat ["faygen-", hash, ".js"]
+                        hash = base64md5 contents'
+                        contents' = TLE.encodeUtf8 $ toLazyText contents
+                    qRunIO $ L.writeFile (concat [fp', "/", name']) contents'
+                    [| do
+                        maybeRequireJQuery needJQuery
+                        $(requireFayRuntime settings)
+                        addScript $ $(return exp') $ StaticRoute [pack name'] []
+                        |]
   where
     name = yfsModuleName settings
     exportRuntime = isNothing (yfsSeparateRuntime settings)
diff --git a/yesod-fay.cabal b/yesod-fay.cabal
--- a/yesod-fay.cabal
+++ b/yesod-fay.cabal
@@ -2,7 +2,7 @@
 -- documentation, see http://haskell.org/cabal/users-guide/
 
 name:                yesod-fay
-version:             0.4.0
+version:             0.4.0.1
 synopsis:            Utilities for using the Fay Haskell-to-JS compiler with Yesod.
 description:         For initial discussion, see <http://www.yesodweb.com/blog/2012/10/yesod-fay-js>. This is a work-in-progress.
 homepage:            https://github.com/snoyberg/yesod-fay
