Commit 2f111381 authored by Peter Simons's avatar Peter Simons
Browse files

haskell-mueval has been fixed upstream.

parent 26a9fcdf
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -781,9 +781,6 @@ self: super: {
  # Patch to consider NIX_GHC just like xmonad does
  dyre = appendPatch super.dyre ./dyre-nix.patch;

  # https://github.com/gwern/mueval/issues/9
  mueval = appendPatch (appendPatch super.mueval ./mueval-fix.patch) ./mueval-nix.patch;

  # Test suite won't compile against tasty-hunit 0.9.x.
  zlib = dontCheck super.zlib;

+0 −90
Original line number Diff line number Diff line
diff --git a/Mueval/ArgsParse.hs b/Mueval/ArgsParse.hs
index 05c8fd9..0c32e27 100644
--- a/Mueval/ArgsParse.hs
+++ b/Mueval/ArgsParse.hs
@@ -1,10 +1,9 @@
+{-# LANGUAGE CPP #-}
 module Mueval.ArgsParse (Options(..), interpreterOpts, getOptions) where
 
 import Control.Monad (liftM)
 import System.Console.GetOpt
 
-import qualified Codec.Binary.UTF8.String as Codec (decodeString)
-
 import Mueval.Context (defaultModules, defaultPackages)
 
 -- | See the results of --help for information on what each option means.
@@ -98,4 +97,11 @@ header = "Usage: mueval [OPTION...] --expression EXPRESSION..."
 -- | Just give us the end result options; this parsing for
 --   us. Bonus points for handling UTF.
 getOptions :: [String] -> Either (Bool, String) Options
-getOptions = interpreterOpts . map Codec.decodeString
\ No newline at end of file
+getOptions = interpreterOpts . map decodeString
+
+decodeString :: String -> String
+#if __GLASGOW_HASKELL__ >= 702
+decodeString = id
+#else
+decodeString = Codec.decodeString
+#endif
diff --git a/Mueval/Context.hs b/Mueval/Context.hs
index 78925cf..548514c 100644
--- a/Mueval/Context.hs
+++ b/Mueval/Context.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE CPP #-}
 module Mueval.Context (
   cleanModules,
   defaultModules,
@@ -32,7 +33,9 @@ defaultModules = ["Prelude",
                   "Control.Monad.Error",
                   "Control.Monad.Fix",
                   "Control.Monad.Identity",
+#if !MIN_VERSION_base(4,7,0)
                   "Control.Monad.Instances",
+#endif
                   "Control.Monad.RWS",
                   "Control.Monad.Reader",
                   "Control.Monad.State",
diff --git a/Mueval/Interpreter.hs b/Mueval/Interpreter.hs
index 29b771f..6c39482 100644
--- a/Mueval/Interpreter.hs
+++ b/Mueval/Interpreter.hs
@@ -1,4 +1,5 @@
 {-# LANGUAGE PatternGuards #-}
+{-# LANGUAGE FlexibleContexts #-}
 -- TODO: suggest the convenience functions be put into Hint proper?
 module Mueval.Interpreter where
 
@@ -12,8 +13,6 @@ import System.Exit (exitFailure)
 import System.FilePath.Posix (takeFileName)
 import qualified Control.Exception.Extensible as E (evaluate,catch,SomeException(..))
 
-import qualified System.IO.UTF8 as UTF (putStrLn)
-
 import Language.Haskell.Interpreter (eval, set, reset, setImportsQ, loadModules, liftIO,
                                      installedModulesInScope, languageExtensions,
                                      typeOf, setTopLevelModules, runInterpreter, glasgowExtensions,
@@ -100,7 +99,7 @@ mvload lfl = do canonfile <- makeRelativeToCurrentDirectory lfl
 -- flooding. Lambdabot has a similar limit.
 sayIO :: String -> IO ()
 sayIO str = do (out,b) <- render 1024 str
-               UTF.putStrLn out
+               putStrLn out
                when b exitFailure
 
 -- | Oh no, something has gone wrong. If it's a compilation error pretty print
diff --git a/mueval.cabal b/mueval.cabal
index 3f9406d..b86d796 100644
--- a/mueval.cabal
+++ b/mueval.cabal
@@ -32,7 +32,7 @@ library
         exposed-modules:     Mueval.Parallel, Mueval.Context, Mueval.Interpreter,
                              Mueval.ArgsParse, Mueval.Resources
         build-depends:       base>=4 && < 5, containers, directory, mtl>2, filepath, unix, process,
-                             hint>=0.3.1, show>=0.3, utf8-string, Cabal, extensible-exceptions, simple-reflect
+                             hint>=0.3.1, show>=0.3, Cabal, extensible-exceptions, simple-reflect
         ghc-options:         -Wall -static
 
 executable mueval-core
+0 −23
Original line number Diff line number Diff line
diff --git a/Mueval/Interpreter.hs b/Mueval/Interpreter.hs
index 29b771f..6360ee3 100644
--- a/Mueval/Interpreter.hs
+++ b/Mueval/Interpreter.hs
@@ -8,6 +8,7 @@ import Control.Monad.Writer (Any(..),runWriterT,tell)
 import Data.Char (isDigit)
 import Data.List (stripPrefix)
 import System.Directory (copyFile, makeRelativeToCurrentDirectory, removeFile, setCurrentDirectory)
+import System.Environment (lookupEnv)
 import System.Exit (exitFailure)
 import System.FilePath.Posix (takeFileName)
 import qualified Control.Exception.Extensible as E (evaluate,catch,SomeException(..))
@@ -47,6 +48,10 @@ interpreter Options { extensions = exts, namedExtensions = nexts,
                                   -- Explicitly adding ImplicitPrelude because of
                                   -- http://darcsden.com/jcpetruzza/hint/issue/1
                                   unless (null lexts) $ set [languageExtensions := (UnknownExtension "ImplicitPrelude" : lexts)]
+                                  pkgs' <- liftIO $ lookupEnv "NIX_GHC_LIBDIR"
+                                  case pkgs' of
+                                    Just pkgs -> unsafeSetGhcOption ("-package-db " ++ pkgs ++ "/package.conf.d")
+                                    Nothing -> return ()
                                   when trust $ do
                                     unsafeSetGhcOption "-fpackage-trust"
                                     forM_ (trustPkgs >>= words) $ \pkg ->