Search Haskell Channel Logs

Monday, February 27, 2017

#haskell channel featuring peddie, Henson, pikajude, davean, ski, lambdabot,

Forkk 2017-02-27 17:08:59
Is it possible to debug C code called from the FFI using gdb?
ezyang 2017-02-27 17:10:20
yes
ezyang 2017-02-27 17:10:26
just breakpoint on it the usual way
peddie 2017-02-27 17:10:33
Forkk: your call stack may not make sense before you cross the FFI, but the C code should show up like normal
Forkk 2017-02-27 17:10:54
really, because I ran it through gdb and when it segfaulted the backtrace was mostly empty
Forkk 2017-02-27 17:11:05
there was certainly nothing recognizable in it
Forkk 2017-02-27 17:12:18
only thing on the stack is Machine_zdwa_info
Forkk 2017-02-27 17:13:33
maybe it's because I'm running gdb on the test executable?
Forkk 2017-02-27 17:13:45
weirdly it also hides the cursor in my terminal when I run it
Henson 2017-02-27 17:19:05
good evening, everyone. What's a good way to use Haskell to move a file. I can only find "rename" in System.Posix.Files, but it doesn't seem to be able to move the file from one filesystem to another. Is there something that can do that, or do you have to manually copy and delete the file for cross-filesystem moves?
ezyang 2017-02-27 17:20:21
does renameFile in directory's System.Directory really not work?
Forkk 2017-02-27 17:23:07
yeah everytime there's a segfault the only thing on the stack is Machine_zdwa_info
Forkk 2017-02-27 17:23:12
I don't even know what that is
dmwit 2017-02-27 17:23:28
?zdec Machine_zdwa_info
lambdabot 2017-02-27 17:23:29
Unknown command, try @list
Henson 2017-02-27 17:24:31
ezyang: nope: "rename: unsupported operation (Invalid cross-device link)"
dmwit 2017-02-27 17:24:41
Are underscores even allowed in z-encoded names?
pikajude 2017-02-27 17:24:53
i think it's Machine_$wa_info
ezyang 2017-02-27 17:24:57
I guess you have to copy
ezyang 2017-02-27 17:25:21
dmwit: well, if they're not, they must be encoded as zu :)
Forkk 2017-02-27 17:25:30
pikajude: but what is that?
pikajude 2017-02-27 17:25:34
that i don't know
Forkk 2017-02-27 17:25:36
it's not in the C code I'm calling
Forkk 2017-02-27 17:27:14
well the module is called Machine
Forkk 2017-02-27 17:27:29
idk what wa_info is
Forkk 2017-02-27 17:29:18
ezyang: I can't set breakpoints either
pikajude 2017-02-27 17:29:22
i googled $wa_info and got this https://mail.haskell.org/pipermail/ghc-tickets/2014-March/010699.html
Forkk 2017-02-27 17:29:24
gdb says no symbol table is loaded
ezyang 2017-02-27 17:29:41
is the foreign library dynamically loaded?
Forkk 2017-02-27 17:30:00
no
Forkk 2017-02-27 17:30:12
it's a small bit of C code I wrote
Forkk 2017-02-27 17:30:21
just to speed up part of my program
ezyang 2017-02-27 17:30:30
compile it with debug symbols?
Forkk 2017-02-27 17:30:37
I added -d to cc-options
Fylwind 2017-02-27 17:30:46
is there a proper name for newtype L m a = L (m (Maybe (a, L m a)))
Forkk 2017-02-27 17:30:57
wait it's -g isn't it
Fylwind 2017-02-27 17:31:29
it's like a list, but with a monadic action interleaved between each element
ski 2017-02-27 17:31:31
Fylwind : i've called it `List' ..
Fylwind 2017-02-27 17:31:39
ski: creative :P
ski 2017-02-27 17:31:48
`m' could be `IORef' or something else, doesn't have to be a monad
ski 2017-02-27 17:32:13
newtype List ref a = MkList (ref (ListCell ref a))
ski 2017-02-27 17:32:22
data ListCell ref a = Nil
ski 2017-02-27 17:32:32
| Cons a (List ref a)
dmwit 2017-02-27 17:32:34
Fylwind: http://hackage.haskell.org/package/list-t-1/docs/ListT.html
dmwit 2017-02-27 17:33:16
I agree with ski: reusing `Maybe` and `(,)` was a mistake.
ski 2017-02-27 17:33:20
then you could have `freeze :: ListCell IORef a -> IO (ListCell Identity a)'
ski 2017-02-27 17:33:35
er, s/ListCell/List/, there
Forkk 2017-02-27 17:33:57
pikajude: that all looks way over my head
pikajude 2017-02-27 17:34:05
Forkk: yeah, i don't know if it's relevant
Fylwind 2017-02-27 17:34:11
ski, dmwit: ah, ListT, thanks!
pikajude 2017-02-27 17:34:11
$wa might even be randomly generated
Forkk 2017-02-27 17:34:19
:|
Forkk 2017-02-27 17:34:27
I've got breakpoints working
Forkk 2017-02-27 17:34:32
just gonna step through uit
Forkk 2017-02-27 17:37:31
well it's happening after the call to the main C function
Forkk 2017-02-27 17:39:48
yeah the segfault is in haskell code.. I'm not sure how to debug this
davean 2017-02-27 17:40:33
Forkk: you have a segv in haskell code?
davean 2017-02-27 17:40:39
Forkk: is it a Storage instance or something?
Forkk 2017-02-27 17:40:53
it's in a haskell function with a bunch of c2hs stuff in it
Forkk 2017-02-27 17:41:05
for converting from a c struct to a haskell struct
Forkk 2017-02-27 17:41:11
not a storage instance though
ezyang 2017-02-27 17:41:33
Say you have a function that has a number of fiddly parameter knobs. Do you prefer: (1) having an opaque "config" object, with setters to set parameters, or (2) having some monoid-y thing
Forkk 2017-02-27 17:42:42
I've isolated it to this line: ty <- toEnum <$> fromIntegral <$> {#get value->ty#} cv
Forkk 2017-02-27 17:42:57
with everything else commented out but that, it still crashes
davean 2017-02-27 17:43:07
ezyang: situational
davean 2017-02-27 17:43:21
I generally lean towards the monoid, but situational
ezyang 2017-02-27 17:44:01
context: I'm redesigning the API for the "compact normal forms" library (gives you a thing you can put data in, and then we no longer GC it)
Forkk 2017-02-27 17:44:01
where pv is one of these: https://gist.github.com/Forkk/edc651092c8a5e30036f810273c11d4e
ezyang 2017-02-27 17:44:08
and there are some parameters which people might want to tune for perf