Re: [Haskell-cafe] question regarding Data.Array.Accelerate

2012-02-12 Thread Philipp
Nevermind, I just realised I got something mixed up. Sorry to bother you. -- View this message in context: http://haskell.1045720.n5.nabble.com/question-regarding-Data-Array-Accelerate-tp5476144p5476586.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

[Haskell-cafe] Stable pointers: use of cast to/from Ptr

2012-02-12 Thread Yves Parès
Hello, According to the documentation ( http://hackage.haskell.org/packages/archive/base/4.5.0.0/doc/html/Foreign-StablePtr.html), StablePtrs aims at being opaque on C-side. But they provide functions to be casted to/from regular *void**'s. Does that mean if for instance you have a StablePtr CInt

Re: [Haskell-cafe] Stable pointers: use of cast to/from Ptr

2012-02-12 Thread Antoine Latter
On Sun, Feb 12, 2012 at 8:18 AM, Yves Parès yves.pa...@gmail.com wrote: Hello, According to the documentation (http://hackage.haskell.org/packages/archive/base/4.5.0.0/doc/html/Foreign-StablePtr.html), StablePtrs aims at being opaque on C-side. But they provide functions to be casted to/from

Re: [Haskell-cafe] ANN: stm-conduit-0.2.1

2012-02-12 Thread Clark Gaebel
I added that after reading his feedback, and seeing the flaw in using TMChans. On Sun, Feb 12, 2012 at 1:47 AM, wren ng thornton w...@freegeek.org wrote: On 2/9/12 2:29 PM, Felipe Almeida Lessa wrote: Your package uses TMChans which AFAIK are unbounded. That means that if the writer is

Re: [Haskell-cafe] Stable pointers: use of cast to/from Ptr

2012-02-12 Thread Albert Y. C. Lai
On 12-02-12 09:18 AM, Yves Parès wrote: According to the documentation (http://hackage.haskell.org/packages/archive/base/4.5.0.0/doc/html/Foreign-StablePtr.html), StablePtrs aims at being opaque on C-side. The doc multiply warns again and again that StablePtr, as well as whatever Ptr you get

Re: [Haskell-cafe] Stable pointers: use of cast to/from Ptr

2012-02-12 Thread Yves Parès
Yes, but from C side, a StablePtr* is **already a **void**. (See HsFFI.h which typedefs HsStablePtr to void*) So its sufficient for a use as an opaque pointer, no need to cast it. So what is the use of casting it to a Ptr () if this doesn't allow to access the memory space addressed? 2012/2/12

Re: [Haskell-cafe] Stable pointers: use of cast to/from Ptr

2012-02-12 Thread Yves Parès
Thanks for your explanation Albert, it makes things clearer. So StablePtrs are just useful so that C code can: 1) call back into Haskell (through a foreign exported function like doSomethingWithTheObjectIGaveYou :: StablePtr MyObjectType - Stuff - IO ()) 2) store them to return them later to

Re: [Haskell-cafe] Stable pointers: use of cast to/from Ptr

2012-02-12 Thread Antoine Latter
On Sun, Feb 12, 2012 at 3:09 PM, Yves Parès yves.pa...@gmail.com wrote: But then, In use case 1), how can a Haskell function modify the data addressed? http://hackage.haskell.org/packages/archive/base/latest/doc/html/Foreign-StablePtr.html#v:deRefStablePtr Antoine

Re: [Haskell-cafe] Some thoughts on Type-Directed Name Resolution -record update

2012-02-12 Thread Evan Laforge
OK, we could implement lenses, make `tempo' a lens instead of a selector, desugar the update syntax to call the update 'method' out of the lens, ... And of course somehow arrange the sugar that when `tempo' appears in other contexts we take the select 'method'. implement lenses - Done, of

Re: [Haskell-cafe] Stable pointers: use of cast to/from Ptr

2012-02-12 Thread Donn Cave
Quoth Yves Pares, ... If StablePtrs cannot have their pointed value modified (either C or Haskell-side), that mostly limits their interest, doesn't it? I'm not sure I follow what's happening in the two cases you mention, but in case it helps, I use StablePtr as a way to smuggle Haskell values

Re: [Haskell-cafe] Stable pointers: use of cast to/from Ptr

2012-02-12 Thread John Meacham
No, you can do nothing with the pointer on the C side other than pass it back into haskell. It may not even be a pointer, it may be an index into an array deep within the RTS for instance. The reason they can be cast to void *'s is so you can store them in C data structures that don't know about

[Haskell-cafe] ghc-mod v1.10.3

2012-02-12 Thread 山本和彦
Hello, I have just released ghc-mod v1.10.3. C-cC-t of this version was powered by Hideyuki Tanaka. The old implementation just show the type of the current expression on Emacs. Howver, the new implementation first show the type of the current expression and the expression is highlighted. If

Re: [Haskell-cafe] Stable pointers: use of cast to/from Ptr

2012-02-12 Thread Yves Parès
You mean I have to use a type like StablePtr (IORef Stuff)? Because there I can only peek (deRefStablePtr) the pointer, not poke it. I take it I should return to C a StablePtr to the new value if I don't want to use IORefs... Or else I have to use regular Ptrs with Foreign.Marshall.Alloc.malloc