diff --git a/shake-ext.cabal b/shake-ext.cabal
--- a/shake-ext.cabal
+++ b/shake-ext.cabal
@@ -1,5 +1,5 @@
 name:                shake-ext
-version:             0.5.0.2
+version:             0.5.0.3
 synopsis:            Helper functions for linting with shake 
 description:         This package provides several linters out of the box, as well as functionality for building ATS source files with [shake](http://shakebuild.com/).
 homepage:            https://hub.darcs.net/vmchale/shake-ext
diff --git a/src/Development/Shake/ATS.hs b/src/Development/Shake/ATS.hs
--- a/src/Development/Shake/ATS.hs
+++ b/src/Development/Shake/ATS.hs
@@ -7,6 +7,7 @@
                              , cgenPretty
                              , cleanATS
                              , atsBin
+                             , lexAts
                              -- * Actions
                              , patsHome
                              -- Types
@@ -59,7 +60,13 @@
         let toLibs = fmap ("-l" <>)
         command [EchoStderr False, AddEnv "PATSHOME" home] "patscc" ([sourceFile, "-atsccomp", "gcc -flto -I/usr/local/lib/ats2-postiats-0.3.8/ccomp/runtime/ -I/usr/local/lib/ats2-postiats-0.3.8/", gcFlag gc, "-o", out, "-cleanaft", "-O2", "-mtune=native", "-flto"] <> toLibs libs)
 
--- atslex  < file.lats > file_lats.dats
+-- | Build a @.lats@ file.
+lexAts :: Rules ()
+lexAts = priority 0.5 $
+    "*.dats" %> \out -> do
+        lats <- liftIO $ readFile (out -<.> "lats")
+        (Stdout contents) <- command [Stdin lats] "atslex" []
+        liftIO $ writeFile out contents
 
 cleanATS :: Rules ()
 cleanATS =
@@ -68,6 +75,7 @@
         cmd_ ["sn", "c"]
         removeFilesAfter "." ["//*.c", "//tags"]
         removeFilesAfter ".shake" ["//*"]
+        removeFilesAfter ".atspkg" ["//*"]
         removeFilesAfter "ats-deps" ["//*"]
 
 -- | This provides rules for generating C code from ATS source files in the
