Search Haskell Channel Logs

Friday, March 3, 2017

#haskell channel featuring EvanR, dramforever, baasvik, dmwit, _sras_, mbw,

mbw 2017-03-03 13:45:10
Ok, so how I understand it, the #alignment keyword is used for computing the alignment of a given C struct, taking padding into account. However according to the documentation, the #type keyword is restricted to C's POD types. On the other hand, in the FFI example for interfacing with Gsl on the HaskellWiki, they define their own Storable class, which mandates specifying an alignment. So I guess there are
mbw 2017-03-03 13:45:16
these three ways: 1. Allocate normaly, assuming natural alignment. Then send an offset pointer to C. 2. Call a C allocation function. 3. . The hsc2hs documentation isn't really conclusive for me.
mbw 2017-03-03 13:46:27
1. is not entirely correct, since I would need to figure out the actuall address (which is probably possible).
mbw 2017-03-03 13:47:33
Since I don't have _that_ much with Haskell's FFI (and hsc2hs, inline-c and ...) yet, I guess I better post-pone this and just assume it's possible.
mbw 2017-03-03 13:47:56
Anyway, thanks ezyang and geekosaur.
mbw 2017-03-03 13:48:10
*that much experience
baasvik 2017-03-03 13:48:35
Here's what I'm trying to do http://lpaste.net/7137326431440207872
baasvik 2017-03-03 13:48:42
I'm trying to fetch Haskell stack sources
baasvik 2017-03-03 13:48:57
and the sources for dependencies inside a cabal sandbox without building anything
geekosaur 2017-03-03 13:49:33
short version is you use hsc2hs when building direct FFI bindings to functions, and Storable when the FFI interface exclusively uses pointers to arrays
geekosaur 2017-03-03 13:50:17
you *can* do arrays via hsc2hs, but you are limited to what Foreign.Marshal.Array can do... Storable is a later and more complete interface, and gives you access to things like Storable Vectors
geekosaur 2017-03-03 13:51:44
so unless you're doing something very simple, you may want to focus on Storable and ignore Foreign.Marshal.Array. note that Storable also replaces hsc2hs's struct support in this case
mbw 2017-03-03 13:52:15
So with storable, the focus is on *exclusively*, and a function like void do_stuff(double *a, size_t n); does *not* apply?
dmwit 2017-03-03 13:53:03
ongy: You have a question about new-exec/new-run?
dmwit 2017-03-03 13:53:52
ongy: Oh, just about the existence? https://github.com/dmwit/cabal/tree/feature/new-run
dmwit 2017-03-03 13:54:42
ongy: And yeah, new-exec can run things you've built, but will not build them if you haven't already. new-run does
dmwit 2017-03-03 13:57:06
(new-exec never builds, but will happily execute any command; new-run always builds and only works for executables in your dependency tree)
monochrom 2017-03-03 13:57:38
So there is a new-* series of commands, new-build, new-run, etc?
dmwit 2017-03-03 13:57:49
yep
monochrom 2017-03-03 13:57:56
Is there also a new-fangle?
dmwit 2017-03-03 13:58:01
=D
monochrom 2017-03-03 13:58:42
Actually is there a reason they are all called new-*?
dmwit 2017-03-03 13:59:04
Yes. They're a big breaking change to the way you use cabal.
dmwit 2017-03-03 13:59:24
And they're not finished/well-tested yet, so it's premature to just drop them on people for sure.
dmwit 2017-03-03 14:00:20
(Disclaimer: This is my outsider understanding of the current state. IANACD)
dramforever 2017-03-03 14:02:56
I hope this isn't off-topic, but: {Where can I find|Are there any} implementations of 'Okasakian' persistent data structures in 'mainstream' languages?
dramforever 2017-03-03 14:03:34
mainstream, like for example C
geekosaur 2017-03-03 14:04:20
mbw, the question is about how you use it from Haskell, not from C. the Haksell side interface for hsc2hs is Foreign.Marshal. the Haskell side interface for Storable is the type's Storable instance
geekosaur 2017-03-03 14:06:09
and, if you use Storable you can take advantage of anything that supports a Storable instance. with Foreign.Marshal you basically get whatever you write in the hsc file, and would have to reinvent much of Storable if you wanted to use it
EvanR 2017-03-03 14:16:05
dramforever: they are rewritten from scratch each time
EvanR 2017-03-03 14:16:18
in C
mbw 2017-03-03 14:18:46
Realistically speaking, I think the use case is probably not realistic, anyway. To have a function set up in a way that certain alignment conditions stricter than natural alignment are fulfilled, makes sense if the function is called a lot of times and doesn't do much work. Otherwise, the usual autovectorized code that jumps around between vectorized/unvectorized parts is fine. The former case is probably
mbw 2017-03-03 14:18:52
not realistic, since I wouldn't want to call into C from Haskell a large number of times and I *presume* their is no portable way to inline a foreign function.
dramforever 2017-03-03 14:18:53
EvanR: Okay, I don't think I'll be using one, but I would be happy to see one
mbw 2017-03-03 14:27:34
Anyway, thanks for your help.
_sras_ 2017-03-03 14:31:25
How can I use postgresql's hstore type with Opaleye. What are the respective Opaleye types?
NextHendrix 2017-03-03 14:35:09
hi, the docs for lambdabot are severely lacking, are there any better ones hiding away
NextHendrix 2017-03-03 14:35:13
ie not the wiki or on github