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: pipe and IO (David McBride) 2. Re: pipe and IO (PICCA Frederic-Emmanuel) 3. Re: How to call popCnt64#? (John Ky) 4. let x = x in x (GHC.Prim) (John Ky) 5. Re: let x = x in x (GHC.Prim) (rahulm...@gmail.com) ---------------------------------------------------------------------- Message: 1 Date: Tue, 22 Mar 2016 13:08:53 -0400 From: David McBride <toa...@gmail.com> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: Re: [Haskell-beginners] pipe and IO Message-ID: <can+tr43kpc5+959shf066rokn-yfvtduv8y+cy_sztwe_5p...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" Yield in your producer is of type DataFrameHkI3D -> Producer DataFrameHkl3D IO () But you are putting an (IO DataFrameHkI3D) in as an argument. You should be able to do something like this: getDataFrameHkl3D :: DataFrameHkl3DH5SixsUhv -> Producer DataFrameHkl3D IO () getDataFrameHkl3D d = do n <- lift $ hkl_h5_len (h5mu d) frames <- forM [0..n] $ \i -> lift (getDataFrameHkl3D' d i) -- :: Producer DataFrameHkl3D IO [DataFrameHkl3D] forM_ frames yield I have a feeling it may be more efficient to yield immediately on each loop as such: getDataFrameHkl3D :: DataFrameHkl3DH5SixsUhv -> Producer DataFrameHkl3D IO () getDataFrameHkl3D d = do n <- lift $ hkl_h5_len (h5mu d) forM_ [0..n] (\i -> lift (getDataFrameHkl3D' d i) >>= yield) You may also substitutde liftIO for lift, if you wish. On Tue, Mar 22, 2016 at 12:37 PM, PICCA Frederic-Emmanuel < frederic-emmanuel.pi...@synchrotron-soleil.fr> wrote: > Hello, > > Still playing with the Pipe module > > here the code I try to write > > getDataFrameHkl3D' :: DataFrameHkl3DH5SixsUhv -> Int -> IO DataFrameHkl3D > getDataFrameHkl3D' d i = do > positions <- get_position (h5mu d) i > return $ DataFrameHkl3D { df_n = i > , df_image = positions > } > > getDataFrameHkl3D :: DataFrameHkl3DH5SixsUhv -> Producer DataFrameHkl3D IO > () > getDataFrameHkl3D d = do > n <- lift $ hkl_h5_len (h5mu d) > forM_ [0..n] $ \i -> yield $ getDataFrameHkl3D' d i > > > but when I compile it I get this error message > > src/hkl3d.hs:274:3: > Couldn't match type `IO DataFrameHkl3D' with `DataFrameHkl3D' > Expected type: Proxy X () () DataFrameHkl3D IO () > Actual type: Proxy X () () (IO DataFrameHkl3D) IO () > In a stmt of a 'do' block: > forM_ [0 .. n] $ \ i -> yield $ getDataFrameHkl3D' d i > In the expression: > do { n <- lift $ hkl_h5_len (h5mu d); > forM_ [0 .. n] $ \ i -> yield $ getDataFrameHkl3D' d i } > In an equation for `getDataFrameHkl3D': > getDataFrameHkl3D d > = do { n <- lift $ hkl_h5_len (h5mu d); > forM_ [0 .. n] $ \ i -> yield $ getDataFrameHkl3D' d i } > > I do not know how to fix my code... > > Frederic > _______________________________________________ > 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/20160322/3ce4c1d8/attachment-0001.html> ------------------------------ Message: 2 Date: Tue, 22 Mar 2016 17:12:22 +0000 From: PICCA Frederic-Emmanuel <frederic-emmanuel.pi...@synchrotron-soleil.fr> To: "The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell" <beginners@haskell.org> Subject: Re: [Haskell-beginners] pipe and IO Message-ID: <a2a20ec3b8560d408356cac2fc148e53b305c...@sun-dag3.synchrotron-soleil.fr> Content-Type: text/plain; charset="us-ascii" > getDataFrameHkl3D :: DataFrameHkl3DH5SixsUhv -> Producer DataFrameHkl3D IO () > getDataFrameHkl3D d = do > n <- lift $ hkl_h5_len (h5mu d) > forM_ [0..n] (\i -> lift (getDataFrameHkl3D' d i) >>= yield) Yes I prefer this one because the getDataFrameHkl3D' will take plenty of memory (big images) thanks a lot Frederic ------------------------------ Message: 3 Date: Tue, 22 Mar 2016 23:03:10 +0000 From: John Ky <newho...@gmail.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: <CAMB4o-DwL2s7kQ_3-t9f8Ts9_YNxk7Eid0fFTh6S8=appcr...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" Hi Marcin, That explanation helps. Thanks! -John On Tue, 22 Mar 2016 at 18:25 Marcin Mrotek <marcin.jan.mro...@gmail.com> wrote: > Hi, > > In general, the problem is that GHCi is attempting to call `show` on the > results of expressions you type in, but `show` (like any other polymorphic > function; though you can look into "levity polymorphism" if you want to > know more) can only accept values of types of kind * (boxed, lifted) - so > it can print Word, but not Word#. > > If you wanted to stay in GHCi, you can do it like: > > Prelude> import GHC.Prim > Prelude GHC.Prim> import GHC.Types > Prelude GHC.Prim GHC.Types> :set -XMagicHash > Prelude GHC.Prim GHC.Types> :t W# > W# :: Word# -> Word > Prelude GHC.Prim GHC.Types> :t popCnt64# > popCnt64# :: Word# -> Word# > Prelude GHC.Prim GHC.Types> let foo = (1 :: Word) > Prelude GHC.Prim GHC.Types> :set -XBangPatterns > Prelude GHC.Prim GHC.Types> let !(W# w) = foo in W# (popCnt64# w) > 1 > > Best regards, > Marcin Mrotek > _______________________________________________ > 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/20160322/2550eb63/attachment-0001.html> ------------------------------ Message: 4 Date: Tue, 22 Mar 2016 23:10:09 +0000 From: John Ky <newho...@gmail.com> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <Beginners@haskell.org> Subject: [Haskell-beginners] let x = x in x (GHC.Prim) Message-ID: <CAMB4o-BrGNfBVEPG=HKAafrUodusyzxLPAuiE6hNMfxdkD=7...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" Hello Haskellers, I'm trying to write a faster popCount function for x86 systems. I tried cloning the ghc-prim package and repurposing it for my own needs, but it isn't working as hoped. In particular, popCnt64# was implemented in GHC.Prim as: popCnt64# = let x = x in x Which shouldn't terminate. Yet when I call it, it magically finds the C implementation in hs_popcnt64 and returns the correct value. My cloned project doesn't behave that way. Instead it doesn't terminate as I would expect. Anyone know what's happening here, if there is a way to make this work or tell me if I'm going about this completely the wrong way? Cheers, -John -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.haskell.org/pipermail/beginners/attachments/20160322/f79083e0/attachment-0001.html> ------------------------------ Message: 5 Date: Wed, 23 Mar 2016 06:37:13 +0530 From: rahulm...@gmail.com To: John Ky <beginners@haskell.org>, The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <Beginners@haskell.org> Subject: Re: [Haskell-beginners] let x = x in x (GHC.Prim) Message-ID: <20160323010713.5902417.30655.15...@gmail.com> Content-Type: text/plain; charset="us-ascii" An HTML attachment was scrubbed... URL: <http://mail.haskell.org/pipermail/beginners/attachments/20160323/3b15dee4/attachment.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 19 *****************************************