lambdabot-haskell-plugins 5.0.1 → 5.0.2
raw patch · 5 files changed
+50/−19 lines, 5 filesdep ~lambdabot-trustedPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: lambdabot-trusted
API changes (from Hackage documentation)
Files
- lambdabot-haskell-plugins.cabal +2/−2
- src/Lambdabot/Plugin/Haskell/Check.hs +1/−1
- src/Lambdabot/Plugin/Haskell/Eval.hs +41/−12
- src/Lambdabot/Plugin/Haskell/Instances.hs +3/−2
- src/Lambdabot/Plugin/Haskell/Type.hs +3/−2
lambdabot-haskell-plugins.cabal view
@@ -1,5 +1,5 @@ name: lambdabot-haskell-plugins-version: 5.0.1+version: 5.0.2 license: GPL license-file: LICENSE@@ -119,7 +119,7 @@ data-memocombinators >= 0.4, hoogle >= 4.2, IOSpec >= 0.2,- lambdabot-trusted >= 5 && < 5.1,+ lambdabot-trusted >= 5.0.2 && < 5.1, logict >= 0.5, MonadRandom >= 0.1, mueval >= 0.9,
src/Lambdabot/Plugin/Haskell/Check.hs view
@@ -24,7 +24,7 @@ check src = case Hs.parseExp src of Hs.ParseFailed l e -> return (Hs.prettyPrint l ++ ':' : e)- Hs.ParseOk{} -> postProcess `fmap` runGHC ("myquickcheck (" ++ src ++ ") `seq` hsep[]")+ Hs.ParseOk{} -> postProcess `fmap` runGHC ("text (myquickcheck (" ++ src ++ "))") postProcess xs = let (first, rest) = splitAt 1 (map (unwords . words) (lines xs))
src/Lambdabot/Plugin/Haskell/Eval.hs view
@@ -1,8 +1,10 @@+{-# LANGUAGE CPP #-}+ -- Copyright (c) 2004-6 Donald Bruce Stewart - http://www.cse.unsw.edu.au/~dons -- GPL version 2 or later (see http://www.gnu.org/copyleft/gpl.html) -- | A Haskell evaluator for the pure part, using mueval-module Lambdabot.Plugin.Haskell.Eval (evalPlugin, runGHC) where+module Lambdabot.Plugin.Haskell.Eval (evalPlugin, runGHC, findL_hs) where import Lambdabot.Config.Haskell import Lambdabot.Plugin@@ -42,7 +44,7 @@ , process = \s -> if null s then do- reset+ resetL_hs say "Undefined." else say "There's currently no way to undefine just one thing. Say @undefine (with no extra words) to undefine everything." }@@ -73,7 +75,7 @@ runGHC :: MonadLB m => String -> m String runGHC src = do- load <- lb (findOrCreateLBFile "L.hs")+ load <- findL_hs binary <- getConfig muevalBinary exts <- getConfig languageExts trusted <- getConfig trustedPackages@@ -81,8 +83,8 @@ case (out,err) of ([],[]) -> return "Terminated\n" _ -> do- let o = mungeEnc out- e = mungeEnc err+ let o = munge out+ e = munge err return $ case () of {_ | null o && null e -> "Terminated\n" | null o -> e@@ -99,7 +101,7 @@ let mode = Hs.defaultParseMode{ Hs.extensions = map Hs.classifyExtension exts } case Hs.parseModuleWithMode mode (decodeString src) of Hs.ParseOk srcModule -> do- l <- lb (findOrCreateLBFile "L.hs")+ l <- findL_hs res <- io (Hs.parseFile l) case res of Hs.ParseFailed loc err -> return (Hs.prettyPrint loc ++ ':' : err)@@ -148,7 +150,7 @@ -- careful with timeouts here. need a wrapper. trusted <- getConfig trustedPackages let ghcArgs = concat- [ ["-O", "-v0", "-c", "-Werror", "-fpackage-trust"]+ [ ["-O", "-v0", "-c", "-Werror", "-fpackage-trust", "-dynamic"] , concat [["-trust", pkg] | pkg <- trusted] , [".L.hs"] ]@@ -201,10 +203,37 @@ ------------------------------ -- reset all bindings -reset :: MonadLB m => m ()-reset = do- -- Note: We use `findOrCreateLBFile` instead of `findLBFileForReading`- -- here to make @Pristine.hs@ easier to find.- p <- lb (findOrCreateLBFile "Pristine.hs")+resetL_hs :: MonadLB m => m ()+resetL_hs = do+ p <- findPristine_hs l <- lb (findLBFileForWriting "L.hs") io (copyFile p l)++-- find Pristine.hs; if not found, we try to install a compiler-specific+-- version from lambdabot's data directory, and finally the default one.+findPristine_hs :: MonadLB m => m FilePath+findPristine_hs = do+ p <- lb (findLBFileForReading "Pristine.hs")+ case p of+ Nothing -> do+ p <- lb (findOrCreateLBFile "Pristine.hs")+ p0 <- lb (findLBFileForReading ("Pristine.hs." ++ show __GLASGOW_HASKELL__))+ p0 <- case p0 of+ Nothing -> lb (findLBFileForReading "Pristine.hs.default")+ p0 -> return p0+ case p0 of+ Just p0 -> do+ p <- lb (findLBFileForWriting "Pristine.hs")+ io (copyFile p0 p)+ _ -> return ()+ return p+ Just p -> return p++-- find L.hs; if not found, we copy it from Pristine.hs+findL_hs :: MonadLB m => m FilePath+findL_hs = do+ file <- lb (findLBFileForReading "L.hs")+ case file of+ -- if L.hs+ Nothing -> resetL_hs >> lb (findOrCreateLBFile "L.hs")+ Just file -> return file
src/Lambdabot/Plugin/Haskell/Instances.hs view
@@ -23,6 +23,7 @@ import Lambdabot.Config.Haskell import Lambdabot.Plugin import Lambdabot.Util+import Lambdabot.Plugin.Haskell.Eval (findL_hs) import Control.Applicative ((*>)) import Control.Monad@@ -134,13 +135,13 @@ -- the parser. fetchInstances' :: MonadLB m => String -> [ModuleName] -> m String fetchInstances' cls mdls = do- load <- lb $ findOrCreateLBFile "L.hs"+ load <- findL_hs let s = unlines $ map unwords [ [":l", load] , ":m" : "+" : mdls , [":i", cls] ]- + ghci <- getConfig ghciBinary (_, out, err) <- io $ readProcessWithExitCode ghci ["-ignore-dot-ghci","-fglasgow-exts"] s let is = getInstances out cls
src/Lambdabot/Plugin/Haskell/Type.hs view
@@ -21,6 +21,7 @@ import Lambdabot.Config.Haskell import Lambdabot.Plugin import Lambdabot.Util+import Lambdabot.Plugin.Haskell.Eval (findL_hs) import Codec.Binary.UTF8.String import Data.Char@@ -57,7 +58,7 @@ -- the hard work! To get the type of foo, pipe theCommand :: [Char] -> [Char] -> [Char]-theCommand cmd foo = cmd ++ " " ++ foo+theCommand cmd foo = cmd ++ " (" ++ foo ++ ")" -- into GHCi and send any line matching @@ -126,7 +127,7 @@ -- query_ghci :: MonadLB m => String -> String -> m String query_ghci cmd expr = do- l <- lb $ findOrCreateLBFile "L.hs"+ l <- findL_hs exts <- getConfig languageExts let context = ":load "++l++"\n:m *L\n" -- using -fforce-recomp to make sure we get *L in scope instead of just L extFlags = ["-X" ++ ext | ext <- exts]