[GHC] #13689: Data.Either doesn't export INLINABLE short functions like "rights"
GHC
ghc-devs at haskell.org
Fri May 12 15:16:44 UTC 2017
#13689: Data.Either doesn't export INLINABLE short functions like "rights"
-------------------------------------+-------------------------------------
Reporter: varosi | Owner: (none)
Type: bug | Status: infoneeded
Priority: normal | Milestone:
Component: Core Libraries | Version: 8.0.2
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: Incorrect API | Unknown/Multiple
annotation | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by varosi):
{{{
{-# LANGUAGE BangPatterns, ScopedTypeVariables, NoMonomorphismRestriction
#-}
import Control.Monad
import qualified Data.ByteString as B
import Data.Csv.Incremental
import Data.Either (rights)
import System.Exit
import System.IO
import System.Environment (getArgs)
import qualified Data.List as DL
main :: IO ()
main = do
[input] <- getArgs
withFile input ReadMode $ \ csvFile -> do
let loop !acc (Many rs k) = loop (acc + countFields rs) =<< feed
k
loop !acc (Done rs) = print (countFields rs + acc)
loop !_ (Fail _ errMsg) = putStrLn errMsg >> exitFailure
feed k = k <$> B.hGetSome csvFile (16*1024)
loop 0 (decode NoHeader :: Parser [()])
where
countFields = sum . map length . rights
}}}
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13689#comment:2>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list