packages feed

hint 0.3.3.6 → 0.3.3.7

raw patch · 4 files changed

+58/−4 lines, 4 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

Changes view
@@ -1,3 +1,10 @@+- ver 0.3.3.7+ * Fixed a race condition that would happen, for instance, when two process where run+   one next to the other, making them, on some platforms, to get the same random number seed+   (thanks to Mario Pastorelli and Samuel Gélineau)++ * Small fix in documentation (thanks to Daniil Frumin)+ - ver 0.3.3.6  * Works again on GHC 7.2.x (thanks to Björn Peemöller) 
hint.cabal view
@@ -1,5 +1,5 @@ name:                hint-version:             0.3.3.6+version:             0.3.3.7 description:         This library defines an @Interpreter@ monad. It allows to load Haskell         modules, browse them, type-check and evaluate strings with Haskell@@ -68,6 +68,7 @@                       Hint.Base                       Hint.InterpreterT                       Hint.Compat+                      Hint.CompatPlatform                       Hint.Configuration                       Hint.Extension                       Hint.Context
+ src/Hint/CompatPlatform.hs view
@@ -0,0 +1,42 @@+#if defined(mingw32_HOST_OS) || defined(__MINGW32__)+{-# LANGUAGE ForeignFunctionInterface #-}+#endif+module Hint.CompatPlatform+  (+    getPID+  )++where++import Control.Applicative+++#if defined(mingw32_HOST_OS) || defined(__MINGW32__)++import Data.Word++#else++import System.Posix.Process++#endif+++#if defined(mingw32_HOST_OS) || defined(__MINGW32__)+-- This function is not yet in the win32 package, so we have to +-- roll down our own definition.+--+-- Credit goes where it is deserved:+--     http://www.haskell.org/pipermail/haskell-cafe/2009-February/055097.html+foreign import stdcall unsafe "winbase.h GetCurrentProcessId"+    c_GetCurrentProcessId :: IO Word32++getPID :: IO Int+getPID = fromIntegral <$> c_GetCurrentProcessId++#else++getPID :: IO Int+getPID = fromIntegral <$> getProcessID++#endif
src/Hint/Context.hs view
@@ -29,6 +29,7 @@ import Hint.Conversions import qualified Hint.Util   as Util import qualified Hint.Compat as Compat+import qualified Hint.CompatPlatform as Compat  import qualified Hint.GHC as GHC @@ -44,12 +45,15 @@ -- already in-scope. Additionally, since this may be used with sandboxing in -- mind we want to avoid easy-to-guess names. Thus, we do a trick similar -- to the one in safeBndFor, but including a random number instead of an--- additional digit+-- additional digit. Finally, to avoid clashes between two processes+-- that are concurrently running with the same random seed (e.g., initialized+-- with the system time with not enough resolution), we also include the process id newPhantomModule :: MonadInterpreter m => m PhantomModule newPhantomModule =     do n <- liftIO randomIO+       p <- liftIO Compat.getPID        (ls,is) <- allModulesInContext-       let nums = concat [show (abs n::Int), filter isDigit $ concat (ls ++ is)]+       let nums = concat [show (abs n::Int), show p, filter isDigit $ concat (ls ++ is)]        let mod_name = 'M':nums        --        tmp_dir <- liftIO getTemporaryDirectory@@ -220,7 +224,7 @@ -- | Sets the modules whose exports must be in context; some --   of them may be qualified. E.g.: -----   @setImports [("Prelude", Nothing), ("Data.Map", Just "M")]@.+--   @setImportsQ [("Prelude", Nothing), ("Data.Map", Just "M")]@. -- --   Here, "map" will refer to Prelude.map and "M.map" to Data.Map.map. setImportsQ :: MonadInterpreter m => [(ModuleName, Maybe String)] -> m ()