Skip to content

Instantly share code, notes, and snippets.

@zsol
Created February 14, 2013 08:20
Show Gist options
  • Save zsol/4951308 to your computer and use it in GitHub Desktop.
Save zsol/4951308 to your computer and use it in GitHub Desktop.
{-
you need the memoize cabal package to use this.
http://hackage.haskell.org/package/memoize-0.3
-}
import System.IO.Unsafe
import System.Posix.Files
import System.Posix.Types
import Data.Function.Memoize
import Debug.Trace
mtime' :: String -> EpochTime
mtime' = (trace "now executing") . modificationTime . unsafePerformIO . getFileStatus
mtime = memoize mtime'
@zsol
Copy link
Author

zsol commented Feb 14, 2013

*Main> mtime "Memo.hs"
now executing
1360829955
*Main> mtime "Memo.hs"
1360829955

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment