Tuplanolla 2017-02-02 08:45:24
At least one of the problems is that you call `printf` on the C side while going through `unsafePerformIO`, recursion-ninja.
Tuplanolla 2017-02-02 08:45:34
That's not necessarily going to work.
recursion-ninja 2017-02-02 08:46:22
Tuplanolla: I can remove the printf(0 from C and it still segfaults though.
ertes 2017-02-02 08:46:46
recursion-ninja: it would be helpful to show the 'foreign' declaration as well
recursion-ninja 2017-02-02 08:46:52
Tuplanolla: The hope was just to "see" if it was making it to the C code executing.
ertes 2017-02-02 08:46:52
and the C code
ertes 2017-02-02 08:47:02
at least the prototype
recursion-ninja 2017-02-02 08:47:29
ertes: It's a gaint nightmare, do you want me to post all of that?
sssilver_ 2017-02-02 08:47:38
Cale do you mean advise against implicit arguments?
ertes 2017-02-02 08:47:40
recursion-ninja: just the prototype should be enough
sssilver_ 2017-02-02 08:48:08
Cale or against ReaderT
sssilver_ 2017-02-02 08:48:14
I don't really know much about ReaderT
sssilver_ 2017-02-02 08:48:15
so I'm confused
lpaste 2017-02-02 08:48:56
recursion-ninja revised "segfaults all the time": "segfaults all the time" at http://lpaste.net/351998
recursion-ninja 2017-02-02 08:49:35
ertes: I modified the lpaste to include the foreign declaration and the struct
lpaste 2017-02-02 08:51:11
recursion-ninja pasted "Segfaulting C code without the plethora of transitively dependant functions" at http://lpaste.net/352000
ertes 2017-02-02 08:51:46
recursion-ninja: as far as i see only size and alignment are used from the Storable instance, right? you're not actually reading/writing any struct members on the haskell side?
ertes 2017-02-02 08:52:04
recursion-ninja: and have you tested that the Storable instance actually works? because it looks highly suspicious
recursion-ninja 2017-02-02 08:52:32
ertes: Probably, I didn't write a lot of the FFI binding myself.
ertes 2017-02-02 08:52:48
recursion-ninja: ah, no, i'm wrong… Storable is used on line 6
recursion-ninja 2017-02-02 08:53:05
ertes: I have no idea if the Storable instance works or how to test it. Any suggestions on that front?
ertes 2017-02-02 08:53:08
recursion-ninja: you should test the crap out of that Storable instance
ertes 2017-02-02 08:53:24
recursion-ninja: yes, create an array and see if you can peek/poke it properly
recursion-ninja 2017-02-02 08:54:06
geekosaur: The `malloc` and `unsafePerformIO` might be bad juju. The idea is to offload some memoization work to C.
recursion-ninja 2017-02-02 08:55:03
ertes: Thanks for the idea. I'll see if I can get that to work in a GHCI session.
recursion-ninja 2017-02-02 08:56:46
GHCI says: ghc: panic! (the 'impossible' happened) when I tried to load the mosules with `stack ghci`
ertes 2017-02-02 09:05:45
recursion-ninja: check if the FFI call is even the culprit… see if this code still segfaults without it
tsahyt 2017-02-02 09:08:01
recursion-ninja: about all these bangs, you don't need them
flxw 2017-02-02 09:08:25
Hi. Conal Elliot mentions in some of his talks, that none of the existing FRP implementations are truely implementing his theory. Which of the haskell FRP implementations would come closest to his denotational semantics? (... well, I should probably ask him)
tsahyt 2017-02-02 09:08:38
you're in IO after all, so unless you have unsafeInterleaveIO somewhere in there, you don't need to force strictness
tsahyt 2017-02-02 09:08:49
flxw: his own implementation I think
tsahyt 2017-02-02 09:09:04
but that was last updated in 2011
tsahyt 2017-02-02 09:09:07
http://hackage.haskell.org/package/reactive
flxw 2017-02-02 09:10:10
tsahyt: ah, thank you.
ertes 2017-02-02 09:11:39
flxw: reflex and reactive-banana implement a subset
tsahyt 2017-02-02 09:11:57
ertes: how does wires compare?
recursion-ninja 2017-02-02 09:12:05
ertes: That's a wonderful idea, checking if the call is actually causing the segfault. I'm going to try it. Can't beleive I didn't think of that!
ertes 2017-02-02 09:12:11
tsahyt: it doesn't… it's AFRP
tsahyt 2017-02-02 09:12:47
ah, I didn't realize that being arrowized already removes it that far
tsahyt 2017-02-02 09:13:00
semantically that is
sm 2017-02-02 09:13:39
recursion-ninja: I call this the "debug by stupid text reduction" technique, it's great :)
ertes 2017-02-02 09:14:01
tsahyt: wires tries to stay as close to FRP semantics as possible, but as an AFRP implementation takes a few compromises
recursion-ninja 2017-02-02 09:14:05
sm: If it was less effective, we'd do something else ;)
ertes 2017-02-02 09:14:22
tsahyt: in a list of true FRP systems (if even just a subset), i wouldn't even mention it
ertes 2017-02-02 09:14:38
neither its predecessor netwire or any of the other AFRP systems available, most notably Yampa
tsahyt 2017-02-02 09:14:57
interesting. I should probably make something with reactive-banana then, because wires is really all I ever used. just to see what the differences are.
tsahyt 2017-02-02 09:15:05
other than the obvious difference of an arrow interface I mean
osa1 2017-02-02 09:15:23
does swapTMVar ever block?
osa1 2017-02-02 09:15:37
what happens if var is empty?
ertes 2017-02-02 09:15:37
tsahyt: yeah, reactive-banana is a great library… also look at reflex, which is maybe a bit more practical in scenarios where you're under control of the main loop
tsahyt 2017-02-02 09:16:00
I've only ever heard reflex mentioned in the context of ghcjs and web things
ertes 2017-02-02 09:16:27
tsahyt: yeah, its most common use case is reflex-dom, but the reflex library is completely agnostic
ertes 2017-02-02 09:17:14
tsahyt: it's also pretty simple, if you can wrap your head around DSum =)
tsahyt 2017-02-02 09:17:28
what would be the criteria to choose an AFRP library over say reactive-banana and vice versa?
ertes 2017-02-02 09:17:45
tsahyt: right now? real-time stuff: simulations, real-time games
ertes 2017-02-02 09:17:47
animations
ertes 2017-02-02 09:17:49
etc.
tsahyt 2017-02-02 09:18:10
as opposed to things like GUIs I suppose?
ertes 2017-02-02 09:18:41
tsahyt: as opposed to things that really take advantage of event push and, well, not being real-time
ertes 2017-02-02 09:19:26
anything that requires predictable performance, lots of random numbers and large dynamic collections currently benefits from AFRP
tsahyt 2017-02-02 09:19:40
why "currently"?
ertes 2017-02-02 09:20:06
tsahyt: because i'm working on something that may eventually become a new reflex host to fix all of these =)
ertes 2017-02-02 09:20:46
the goal is to make AFRP obsolete… and make conal happy be bringing back continuous behaviours and integration =)
ertes 2017-02-02 09:20:55
s/ be / by /
tsahyt 2017-02-02 09:21:53
that sounds interesting
tsahyt 2017-02-02 09:21:57
what will happen to wires then?
tsahyt 2017-02-02 09:22:34
also about "making AFRP obsolete", with my very limited experience I actually found arrows to be a rather adequate interface
ertes 2017-02-02 09:22:35
a note in the README: "AFRP is obsolete now… use this new thing instead: [link]" =)
ertes 2017-02-02 09:23:05
arrows are a terrible interface… what is great is the underlying automaton-based implementation, because it's so delightfully cheap
ertes 2017-02-02 09:23:44
i've tried for years to retain the automaton approach while getting rid of the A, but never succeeded
fuzzyhorns 2017-02-02 09:29:24
dumb question im sure but, i am using trace in a program im running through stack test, but i dont see any output
fuzzyhorns 2017-02-02 09:29:41
i thought id get stderr out without needing to do anything, but i guess not?
tsahyt 2017-02-02 09:30:34
ertes: how are arrows a terrible interface? as I said I don't have much experience with AFRP or FRP overall actually.
ertes 2017-02-02 09:32:43
tsahyt: with all inputs forcefully explicit and the inability to use regular function arguments you need awkward special syntax for a lot of things from basics (passing stuff around) to more complicated cases like rewrapping the inputs of a combinator (notably the scary (| banana bracket |) syntax and its complicated semantics), and everything becomes slower, because you need to create tuple-based side channels all the time
sm 2017-02-02 09:32:51
I think stack test hides some output by default - check for a verbose/debug flag, or run the test executable it builds directly
tsahyt 2017-02-02 09:33:49
TIL about banana brackets
tsahyt 2017-02-02 09:34:13
as I was going over my asteroids clone again, I did notice that I use tuples an awful lot though, so I guess you have a good point there
ertes 2017-02-02 09:35:10
tsahyt: the Monad interface is better in every way i can think of
tsahyt 2017-02-02 09:35:45
I thought allowing a Monad interface opens the door to all kinds of performance problems though?
ertes 2017-02-02 09:36:07
tsahyt: Monad is just an interface… if you have a monad, you should use it
ertes 2017-02-02 09:37:09
tsahyt: now if you take a pure automaton type (non-monadic), then it is actually also a monad, but unfortunately its (>>=) is linear in the number of frames computed so far
ertes 2017-02-02 09:37:27
in other words: the cost of each next frame will be one step more than the current frame
ertes 2017-02-02 09:37:44
that's why Arrow (or Applicative+Category) is necessary for automata
tsahyt 2017-02-02 09:38:10
I see, so that's why AFRP came to be
ertes 2017-02-02 09:38:43
if the automaton type supports effects (as e.g. Wire does), then it's no longer a proper monad at all
ertes 2017-02-02 09:39:35
Yampa could *in principle* provide a monadic interface, but it would be useless for the reason above
wayne 2017-02-02 09:41:21
hi
wayne 2017-02-02 09:41:27
i have `data Direction = North | East | South | West`
wayne 2017-02-02 09:41:43
how can i do something like `incr North` to get East?
ertes 2017-02-02 09:42:01
wayne: add: deriving (Enum)
ertes 2017-02-02 09:42:09
then 'incr' is 'succ'
wayne 2017-02-02 09:42:19
ah, that was it!
ertes 2017-02-02 09:42:20
however, succ West = undefined
wayne 2017-02-02 09:42:23
thanks i forgot about succ
wayne 2017-02-02 09:42:27
what could getting West back to North?
tsahyt 2017-02-02 09:42:30
ertes: from what I've seen reactive-banana does use a monadic interface though. At least it has this MomentMonad or so. I suppose that only works because of a different model underneath then?
wayne 2017-02-02 09:42:32
s/could/about/
wayne 2017-02-02 09:43:05
i hope i don't have to figure out CircularEnum
ertes 2017-02-02 09:43:06
wayne: here is a horrible idea: \x -> toEnum (mod (fromEnum x + 1) 4)
wayne 2017-02-02 09:43:17
yeah...thanks for the inspiration though
kadoban 2017-02-02 09:43:24
wayne: You'd probably want to implement your own function really, not use succ Yeah, that ^
mizu_no_oto_work 2017-02-02 09:43:25
http://stackoverflow.com/questions/5684049/is-there-some-way-to-define-an-enum-in-haskell-that-wraps-around
wayne 2017-02-02 09:43:40
oh amazing googlefu mizu_no_oto_work
wayne 2017-02-02 09:43:45
thanks
mizu_no_oto_work 2017-02-02 09:43:48
np
ertes 2017-02-02 09:43:53
tsahyt: all of them use a monadic interface, because they don't use the automaton approach
tsahyt 2017-02-02 09:44:06
ertes: where can I read more about this automaton approach?
ertes 2017-02-02 09:44:33
tsahyt: one option is the original AFRP paper… see the Yampa docs, they should have a link
wayne 2017-02-02 09:44:36
okay. another question...what's the best way to take [a -> b] and apply the function in order?
wayne 2017-02-02 09:44:42
functions in the list, that is
ertes 2017-02-02 09:44:51
tsahyt: another option is to implement it yourself: newtype Auto a b = Auto { stepAuto :: a -> (b, Auto a b) }
wayne 2017-02-02 09:45:00
[f1, f2, f3] to f3(f2(f1(v)))