Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org
You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than "Re: Contents of Beginners digest..." Today's Topics: 1. Re: How to call popCnt64#? (Michael Snoyman) 2. Using Cassava with medium sized files (~50MB) (Antoine Genton) ---------------------------------------------------------------------- Message: 1 Date: Sun, 20 Mar 2016 16:12:42 +0200 From: Michael Snoyman <mich...@snoyman.com> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: Re: [Haskell-beginners] How to call popCnt64#? Message-ID: <CAKA2Jg+ErxaadU3V=xku-9ikxvkebbshrf6+uoo2mgrhmkj...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" Here's an example: {-# LANGUAGE MagicHash #-} import GHC.Prim import GHC.Types import Data.Word main :: IO () main = do let word = 5 :: Word res = case word of W# w -> W# (popCnt64# w) print res On Sun, Mar 20, 2016 at 12:19 PM, John Ky <newho...@gmail.com> wrote: > Hello Haskellers, > > Does anyone know how to call popCnt64# from the GHC.Prim module? > > This was my failed attempt: > > ?> popCnt64# 1 > > > <interactive>:14:11: > Couldn't match kind ?*? with ?#? > When matching types > a0 :: * > Word# :: # > Expected type: Integer -> Word# > Actual type: Integer -> a0 > In the first argument of ?popCnt64#?, namely ?1? > In the expression: popCnt64# 1 > In an equation for ?it?: it = popCnt64# 1 > > -John > > > _______________________________________________ > Beginners mailing list > Beginners@haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.haskell.org/pipermail/beginners/attachments/20160320/8eb9396c/attachment-0001.html> ------------------------------ Message: 2 Date: Sun, 20 Mar 2016 11:21:11 -0400 From: Antoine Genton <genton.anto...@gmail.com> To: beginners@haskell.org Subject: [Haskell-beginners] Using Cassava with medium sized files (~50MB) Message-ID: <CAPiy-ruEMayhrNTZd7aWnkx6sDTkypWXy_ZG=-qleyx+msy...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" Hello, I tried to load a ~50MB csv file in memory with cassava but found that my program was incredibly slow. After doing some profiling, I realized that it used an enormous amount of memory in the heap: 24,626,540,552 bytes allocated in the heap 6,946,460,688 bytes copied during GC 2,000,644,712 bytes copied maximum residency (14 sample(s)) 319,728,944 bytes maximum slop 3718 MB total memory in use (0MB lost due to fragmentation) ... %GC time 84.0% (94.3% elapsed) Seeing that, I have the feeling that my program lacks strictness and accumulates thunks in memory. I tried two versions, on using Data.Csv, and one using Data.Csv.Streaming. Both are giving the same result. What am I doing wrong? Here are the two sources: 1/ import Data.Csv import Data.ByteString.Lazy as BL import qualified Data.Vector as V main :: IO () main = do csv <- BL.readFile "tt.csv" let !res = case decode NoHeader csv of Right q -> q :: V.Vector(V.Vector(ByteString)) print $ res V.! 0 -------------------------------- 2/ import Data.Csv.Streaming import Data.ByteString.Lazy as BL import qualified Data.Vector as V import Data.Foldable main :: IO () main = do csv <- BL.readFile "tt.csv" let !a = decode NoHeader csv :: Records(V.Vector(ByteString)) let !xx = V.fromList $ [V.fromList([])] :: V.Vector(V.Vector(ByteString)) let !res = Data.Foldable.foldr' V.cons xx a print $ res V.! 0 The goal of the program is ultimately to have the csv loaded in memory as a Vector of Vector of ByteString for further processing later on. Thank you for your help, Antoine -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.haskell.org/pipermail/beginners/attachments/20160320/aa7b728e/attachment-0001.html> ------------------------------ Subject: Digest Footer _______________________________________________ Beginners mailing list Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners ------------------------------ End of Beginners Digest, Vol 93, Issue 14 *****************************************