Permalink
Browse files

conduit: this is broken.

  • Loading branch information...
1 parent 1782864 commit e50d1e7311d18214ec0e94270e085ca2370d082e @kazu-yamamoto committed Feb 7, 2012
Showing with 9 additions and 36 deletions.
  1. +0 −30 Process.hs
  2. +6 −5 VerDB.hs
  3. +3 −1 cab.cabal
View
@@ -1,30 +0,0 @@
-{-# LANGUAGE CPP #-}
-
-module Process (
- Iteratee, infoFromProcess
- ) where
-
-import Data.Enumerator (Iteratee, run_, ($$))
-import Data.Enumerator.Binary (enumHandle)
-import System.Process
-import System.IO
-import Data.ByteString (ByteString)
-
-infoFromProcess :: String -> Iteratee ByteString IO a -> IO a
-infoFromProcess shellCommand parser = do
- (Nothing, Just hdl, Nothing, _) <- createProcess proSpec
- hSetEncoding hdl latin1
- run_ (enumHandle 4096 hdl $$ parser)
- where
- proSpec = CreateProcess {
- cmdspec = ShellCommand shellCommand
- , cwd = Nothing
- , env = Nothing
- , std_in = Inherit
- , std_out = CreatePipe
- , std_err = Inherit
- , close_fds = True
-#if __GLASGOW_HASKELL__ >= 702
- , create_group = True
-#endif
- }
View
@@ -7,12 +7,13 @@ module VerDB (
import Control.Applicative
import Control.Arrow (second)
import Data.Attoparsec.ByteString.Char8
-import Data.Attoparsec.Enumerator
import Data.ByteString (ByteString)
+import Data.Conduit
+import Data.Conduit.Attoparsec
+import Data.Conduit.Process
import Data.Map (Map)
import qualified Data.Map as M
import Data.Maybe
-import Process
----------------------------------------------------------------
@@ -31,7 +32,7 @@ getVerAlist installedOnly = justOnly <$> verInfos
script = if installedOnly
then "cabal list --installed"
else "cabal list"
- verInfos = infoFromProcess script cabalListParser
+ verInfos = runResourceT $ sourceCmd script $$ cabalListParser
justOnly = map (second fromJust) . filter (isJust . snd)
----------------------------------------------------------------
@@ -41,8 +42,8 @@ lookupLatestVersion pkgid (VerDB db) = M.lookup pkgid db
----------------------------------------------------------------
-cabalListParser :: Iteratee ByteString IO [VerInfo]
-cabalListParser = iterParser verinfos
+cabalListParser :: Sink ByteString IO [VerInfo]
+cabalListParser = sinkParser verinfos
verinfos :: Parser [VerInfo]
verinfos = many1 verinfo
View
@@ -26,13 +26,16 @@ Executable cab
Build-Depends: base >= 4.0 && < 5
, Cabal
, attoparsec >= 0.10.0.0
+ , attoparsec-conduit
, attoparsec-enumerator
, bytestring
+ , conduit
, containers
, directory
, enumerator
, filepath
, process
+ , process-conduit
if os(windows)
Build-Depends:
else
@@ -42,7 +45,6 @@ Executable cab
Env
GenPaths
PkgDB
- Process
Program
Types
Utils

0 comments on commit e50d1e7

Please sign in to comment.