Permalink
Browse files

compile with GHC 7.6.1

  • Loading branch information...
JPMoresmau committed Oct 5, 2012
1 parent c890d44 commit 194329a8942ca514f570ee6cf1a4e6dff42cbc2a
Showing with 476 additions and 474 deletions.
  1. +3 −3 scion-browser.cabal
  2. +50 −50 src/Main.hs
  3. +200 −200 src/Scion/Packages.hs
  4. +222 −220 src/Scion/PersistentBrowser/TempFile.hs
  5. +1 −1 src/Server/PersistentCommands.hs
View
@@ -49,7 +49,7 @@ library
if impl(ghc >= 7.0)
build-depends:
- containers >= 0.2 && < 0.5,
+ containers >= 0.2,
directory >= 1.1,
filepath >= 1.2,
bytestring,
@@ -96,7 +96,7 @@ executable scion-browser
hs-source-dirs: src
main-is: Main.hs
build-depends:
- haskeline >= 0.6 && < 0.7,
+ haskeline >= 0.7,
attoparsec >= 0.10,
base == 4.*,
mtl >= 2,
@@ -128,7 +128,7 @@ executable scion-browser
if impl(ghc >= 7.0)
build-depends:
- containers >= 0.2 && < 0.5,
+ containers >= 0.2,
directory >= 1.1,
filepath >= 1.2,
bytestring,
View
@@ -1,50 +1,50 @@
-{-# LANGUAGE OverloadedStrings, TemplateHaskell #-}
-
-module Main where
-
-import qualified Codec.Compression.Zlib as Zlib
-import Control.Monad.State
-import Data.Aeson
-import qualified Data.Aeson.Types as T
-import qualified Data.Attoparsec.ByteString as Atto
-import qualified Data.ByteString.Lazy.Char8 as LBS
-import qualified Data.ByteString.UTF8 as BSU(fromString)
-import Server.PersistentCommands
-import System.Console.Haskeline
-import System.IO (hFlush, stdout, stderr)
-import System.Environment (getArgs)
-import Data.Version (showVersion)
-import Paths_scion_browser
-import Scion.PersistentBrowser.Util (logToStdout)
-
-import GHC.IO.Handle (hDuplicate,hDuplicateTo)
-
-main :: IO ()
-main = do args <- getArgs
- case args of
- ("--version":_) -> putStrLn ("scion-browser executable, version " ++ (showVersion version))
- _ -> do runStateT (runInputT defaultSettings loop) initialState
- return ()
-
-loop :: InputT BrowserM ()
-loop = do
- maybeLine <- getInputLine ""
- case maybeLine of
- Nothing -> return () -- ctrl+D or EOF
- Just line -> do
- case Atto.parse json (BSU.fromString line) of
- Atto.Fail _ _ e -> (liftIO $ logToStdout ("error in command: " ++ e)) >> loop
- Atto.Partial _ -> (liftIO $ logToStdout ("incomplete data error in command: ")) >> loop
- Atto.Done _ value -> case T.parse parseJSON value of
- Error e -> (liftIO $ logToStdout ("error in command: " ++ e)) >> loop
- Success cmd -> do
- stdout_excl <- liftIO $ hDuplicate stdout
- liftIO $ hDuplicateTo stderr stdout -- redirect stdout to stderr
- (res, continue) <- lift $ executeCommand cmd
- liftIO $ hDuplicateTo stdout_excl stdout -- redirect stdout to original stdout
- let encoded = LBS.append (encode res) "\n"
- compressed = Zlib.compressWith Zlib.defaultCompressParams { Zlib.compressLevel = Zlib.bestSpeed } encoded
- liftIO $ LBS.putStr compressed
- liftIO $ hFlush stdout
- if continue then loop else return ()
-
+{-# LANGUAGE OverloadedStrings, TemplateHaskell #-}
+
+module Main where
+
+import qualified Codec.Compression.Zlib as Zlib
+import Control.Monad.State.Strict
+import Data.Aeson
+import qualified Data.Aeson.Types as T
+import qualified Data.Attoparsec.ByteString as Atto
+import qualified Data.ByteString.Lazy.Char8 as LBS
+import qualified Data.ByteString.UTF8 as BSU(fromString)
+import Server.PersistentCommands
+import System.Console.Haskeline
+import System.IO (hFlush, stdout, stderr)
+import System.Environment (getArgs)
+import Data.Version (showVersion)
+import Paths_scion_browser
+import Scion.PersistentBrowser.Util (logToStdout)
+
+import GHC.IO.Handle (hDuplicate,hDuplicateTo)
+
+main :: IO ()
+main = do args <- getArgs
+ case args of
+ ("--version":_) -> putStrLn ("scion-browser executable, version " ++ (showVersion version))
+ _ -> do runStateT (runInputT defaultSettings loop) initialState
+ return ()
+
+loop :: InputT BrowserM ()
+loop = do
+ maybeLine <- getInputLine ""
+ case maybeLine of
+ Nothing -> return () -- ctrl+D or EOF
+ Just line -> do
+ case Atto.parse json (BSU.fromString line) of
+ Atto.Fail _ _ e -> (liftIO $ logToStdout ("error in command: " ++ e)) >> loop
+ Atto.Partial _ -> (liftIO $ logToStdout ("incomplete data error in command: ")) >> loop
+ Atto.Done _ value -> case T.parse parseJSON value of
+ Error e -> (liftIO $ logToStdout ("error in command: " ++ e)) >> loop
+ Success cmd -> do
+ stdout_excl <- liftIO $ hDuplicate stdout
+ liftIO $ hDuplicateTo stderr stdout -- redirect stdout to stderr
+ (res, continue) <- lift $ executeCommand cmd
+ liftIO $ hDuplicateTo stdout_excl stdout -- redirect stdout to original stdout
+ let encoded = LBS.append (encode res) "\n"
+ compressed = Zlib.compressWith Zlib.defaultCompressParams { Zlib.compressLevel = Zlib.bestSpeed } encoded
+ liftIO $ LBS.putStr compressed
+ liftIO $ hFlush stdout
+ if continue then loop else return ()
+
Oops, something went wrong.

0 comments on commit 194329a

Please sign in to comment.