Skip to content

Commit

Permalink
make getHintInternals pure
Browse files Browse the repository at this point in the history
  • Loading branch information
Carl Howells committed Dec 23, 2010
1 parent 9ee6142 commit 7e10297
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
10 changes: 6 additions & 4 deletions src/Snap/Extension.hs
Expand Up @@ -414,10 +414,12 @@ getHintInternals :: Initializer s
-- ^ The Initializer value
-> SnapExtend s ()
-- ^ An action in your application's monad.
-> IO HintInternals
getHintInternals i se = do
(action, cleanup, _) <- runInitializer True i se
return $ makeHintInternals (return ()) (const cleanup) (const action)
-> HintInternals
getHintInternals i se = makeHintInternals runInit getCleanup getAction
where
runInit = runInitializer True i se
getAction (action, _, _) = action
getCleanup (_, cleanup, _) = cleanup


------------------------------------------------------------------------------
Expand Down
12 changes: 5 additions & 7 deletions src/Snap/Extension/Loader/Devel.hs
Expand Up @@ -9,8 +9,6 @@ module Snap.Extension.Loader.Devel
( loadSnapTH
) where

import Control.Monad (join)

import Data.List (groupBy, intercalate, isPrefixOf, nub)
import Data.Maybe (catMaybes)
import Data.Time.Clock (diffUTCTime, getCurrentTime)
Expand Down Expand Up @@ -123,19 +121,19 @@ hintSnap opts modules initialization handler = do
]
interpreter = do
loadModules . nub $ modules
let imports = "Prelude" : "Snap.Extension" :
let imports = "Snap.Extension" :
"Snap.Extension.Loader.Devel.Evaluator" :
modules
setImports . nub $ imports

interpret action (as :: IO HintInternals)
interpret action (as :: HintInternals)

loadInterpreter = unsafeRunInterpreterWithArgs opts interpreter

formatError (Left err) = error $ format err
formatError (Right a) = a
formatOnError (Left err) = error $ format err
formatOnError (Right a) = a

loader = join $ formatError `fmap` protectHandlers loadInterpreter
loader = formatOnError `fmap` protectHandlers loadInterpreter

test prevTime = do
now <- getCurrentTime
Expand Down

0 comments on commit 7e10297

Please sign in to comment.