From traqueofziche at gmail.com Tue Sep 3 08:52:59 2019 From: traqueofziche at gmail.com (=?UTF-8?B?6bKN5Yev5paH?=) Date: Tue, 3 Sep 2019 01:52:59 -0700 Subject: [Haskell-beginners] how to convert an array of foreignPtr a into a list of Ptr a In-Reply-To: References: Message-ID: Hi Frederic, I tried writing my thoughts on your question in this gist here: https://gist.github.com/darcykimball/74dd7973b2dbad22b7091135a3b9d472. There's probably much more to it than what I wrote, but I'm figuring that stuff out the more I think about it. I'll try to add more when I'm convinced I get it. Best, Kevin On Tue, Aug 27, 2019 at 5:56 AM wrote: > Send Beginners mailing list submissions to > beginners at 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-request at haskell.org > > You can reach the person managing the list at > beginners-owner at haskell.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of Beginners digest..." > > > Today's Topics: > > 1. how to convert an array of foreignPtr a into a list of Ptr a > (PICCA Frederic-Emmanuel) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Tue, 27 Aug 2019 07:19:25 +0000 > From: PICCA Frederic-Emmanuel > > To: "The Haskell-Beginners Mailing List - Discussion of primarily > beginner-level topics related to Haskell" > Subject: [Haskell-beginners] how to convert an array of foreignPtr a > into a list of Ptr a > Message-ID: > < > A2A20EC3B8560D408356CAC2FC148E53016CF535AB at SUN-DAG3.synchrotron-soleil.fr> > > Content-Type: text/plain; charset="us-ascii" > > Hello, I am writing some code whcih use FFI. > > one of my C functions has an array of pointer has imput > > extern HklBinocularsCube *hkl_binoculars_cube_new(int32_t n_spaces, > > const HklBinocularsSpace **spaces); > > > from Haskell, I have a list of ForeignPtr > so my question how can I have something like withForeignPtr for an array > of ForeignPtr > > [ForeignPtr a] -> ([Ptr a] -> IO b) -> IO b > > Thanks for your help. > > Frederic > > ------------------------------ > > Subject: Digest Footer > > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > > ------------------------------ > > End of Beginners Digest, Vol 134, Issue 4 > ***************************************** > -------------- next part -------------- An HTML attachment was scrubbed... URL: From frederic-emmanuel.picca at synchrotron-soleil.fr Tue Sep 3 09:01:21 2019 From: frederic-emmanuel.picca at synchrotron-soleil.fr (PICCA Frederic-Emmanuel) Date: Tue, 3 Sep 2019 09:01:21 +0000 Subject: [Haskell-beginners] how to convert an array of foreignPtr a into a list of Ptr a In-Reply-To: References: , Message-ID: thanks you very much. it is a very helpfull explaination. Cheers, Frederic From jcg.sturdy at gmail.com Thu Sep 26 13:53:23 2019 From: jcg.sturdy at gmail.com (John Sturdy) Date: Thu, 26 Sep 2019 14:53:23 +0100 Subject: [Haskell-beginners] Import errors from a very simple program Message-ID: Hi, I'm right at the start of learning Haskell, and I decided to jump from reading LYAH to writing a simple real-world program. It's based very closely on https://github.com/haskell-hvr/cassava/blob/master/examples/NamedBasedGeneric.hs (I removed the bit that constructs the test file, as I already have a file), and I've done "cabal install cassava", first as root, and then when I first go the error, as myself using the sandbox (which didn't change the output). I first tried this with running ghc directly, and then followed the instructions on https://wiki.haskell.org/How_to_write_a_Haskell_program, and all these get the same errors: Main.hs:4:1: error: Could not find module ‘Data.Csv’ Locations searched: Data/Csv.hs Data/Csv.lhs Data/Csv.hsig Data/Csv.lhsig | 4 | import Data.Csv | ^^^^^^^^^^^^^^^ Main.hs:6:1: error: Could not find module ‘Data.Vector’ Perhaps you meant Data.Functor (from base-4.11.1.0) Locations searched: Data/Vector.hs Data/Vector.lhs Data/Vector.hsig Data/Vector.lhsig | 6 | import qualified Data.Vector as V | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ I don't understand the connection between the name "cassava" and "Data/Csv", although looking around in the directories that have been produced, I see that Data/Csv is within the cassava directories. I'd like not only to know how to fix this, but also a pointer for what I should look at to understand what is going on. This is on a Debian system. thanks, __John (completely new to Haskell, experienced in C, Lisp, Python and others, if that helps to pitch the level of answers) -------------- next part -------------- An HTML attachment was scrubbed... URL: From fa-ml at ariis.it Thu Sep 26 14:15:40 2019 From: fa-ml at ariis.it (Francesco Ariis) Date: Thu, 26 Sep 2019 16:15:40 +0200 Subject: [Haskell-beginners] Import errors from a very simple program In-Reply-To: References: Message-ID: <20190926141540.lajv5celof4jh437@x60s.casa> Hello John, On Thu, Sep 26, 2019 at 02:53:23PM +0100, John Sturdy wrote: > Hi, > > I'm right at the start of learning Haskell, and I decided to jump from > reading LYAH to writing a simple real-world program. > > It's based very closely on > https://github.com/haskell-hvr/cassava/blob/master/examples/NamedBasedGeneric.hs Cabalising a small project is one way to do it (and a useful skill to learn, too): cd ~/somefolder wget -O Main.hs https://raw.githubusercontent.com/haskell-hvr/cassava/master/examples/NamedBasedGeneric.hs cabal init --is-executable --dependency=base --dependency=bytestring --dependency=vector --dependency=text --dependency=cassava # many questions! There is a non-interactive option. cabal new-repl # ghci repl for your project λ> main Bingo! Read the generated .cabal file to learn more on how it works Does this help? -F From daniel.trstenjak at gmail.com Thu Sep 26 14:18:14 2019 From: daniel.trstenjak at gmail.com (Daniel Trstenjak) Date: Thu, 26 Sep 2019 16:18:14 +0200 Subject: [Haskell-beginners] Import errors from a very simple program In-Reply-To: References: Message-ID: <20190926141814.GA24606@octa> Hi John, if I'm understanding you correctly, you're installing packages by hand with 'cabal install' and then calling 'ghc' by hand for your source file. 'ghc' won't automatically use the packages you've installed with 'cabal install', but you've to add them to the 'ghc' call. Your compile error seems to indicate, that the 'cassava' and 'vector' packages haven't been given to the 'ghc' call. But most likely it isn't worth the hassle doing this and it is a lot easier to just create a default cabal file with 'cabal init'. Then you can add the 'cassava' and 'vector' packages as dependencies and build the packages and your source file with 'cabal new-build'. Greetings, Daniel From jcg.sturdy at gmail.com Thu Sep 26 14:26:22 2019 From: jcg.sturdy at gmail.com (John Sturdy) Date: Thu, 26 Sep 2019 15:26:22 +0100 Subject: [Haskell-beginners] Import errors from a very simple program In-Reply-To: <20190926141814.GA24606@octa> References: <20190926141814.GA24606@octa> Message-ID: On Thu, Sep 26, 2019 at 3:18 PM Daniel Trstenjak wrote: > Hi John, > > 'ghc' won't automatically use the packages you've installed with 'cabal > install', > but you've to add them to the 'ghc' call. > Thanks, that'll be the key to what's going on. I had assumed that installed packages would be automatically available for "import", as they are in Python. (The program I'm writing has the same functionality as a Python program I had written earlier, which probably biased me to thinking that way.) __John -------------- next part -------------- An HTML attachment was scrubbed... URL: