Send Beginners mailing list submissions to
        beginners@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-requ...@haskell.org

You can reach the person managing the list at
        beginners-ow...@haskell.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."


Today's Topics:

   1. Re:  which typefor this FFI call (PICCA Frederic-Emmanuel)
   2. Re:  which typefor this FFI call (Sylvain Henry)
   3. Re:  which typefor this FFI call (PICCA Frederic-Emmanuel)
   4.  tail recursion optimizations and monads (Silent Leaf)
   5.  where do non-beginners haskellers go to expose   code to the
      community? (Silent Leaf)
   6. Re:  where do non-beginners haskellers go to expose code to
      the community? (Francesco Ariis)
   7. Re:  where do non-beginners haskellers go to expose code to
      the community? (Silent Leaf)


----------------------------------------------------------------------

Message: 1
Date: Wed, 28 Jun 2017 13:27:02 +0000
From: PICCA Frederic-Emmanuel
        <frederic-emmanuel.pi...@synchrotron-soleil.fr>
To: "The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell" <beginners@haskell.org>
Subject: Re: [Haskell-beginners] which typefor this FFI call
Message-ID:
        
<a2a20ec3b8560d408356cac2fc148e53bb385...@sun-dag3.synchrotron-soleil.fr>
        
Content-Type: text/plain; charset="gb2312"

Hello, I end up with this and it works :) thanks

type H5Iterate a = HId_t -> CString -> In H5L_info_t -> InOut a -> IO HErr_t

foreign import ccall "wrapper" mkOp :: H5Iterate a -> IO (FunPtr (H5Iterate a))

nxEntries ∷ FilePath → IO [String]
nxEntries f = withH5File f $ \h → do
  state <- newIORef []
  statePtr <- newStablePtr state
  let opData = InOut $ castStablePtrToPtr statePtr
  let startIndex = Nothing
  let indexType = ByName
  let order = Native
  iop <- mkOp callback
  _ <- withInOut_ (maybe 0 hSize startIndex) $ \ioStartIndex ->
      h5l_iterate (hid h) (indexTypeCode indexType) (iterOrderCode order) 
ioStartIndex iop opData
              
  freeHaskellFunPtr iop
  freeStablePtr statePtr

  -- retrieve the final state
  readIORef state
    where
      callback ∷ H5Iterate a
      callback _g n _i (InOut dataptr) =
          do
            let opData = castWrappedPtr dataptr
            -- get the state
            stRef <- deRefStablePtr (castPtrToStablePtr opData)
            st <- readIORef stRef

            -- compute the new state
            name <- peekCString n
            let newSt = st ++ [name]
            print st
            print name
            print newSt
                                                            
            -- store the new state
            writeIORef stRef newSt
            return $ HErr_t 0


BUT I lose the type checking at the callback interface.
the ffi call of the h5l_iterate method is

#ccall H5Literate, <hid_t> -> <H5_index_t> -> <H5_iter_order_t> -> InOut 
<hsize_t> -> H5L_iterate_t a -> InOut a -> IO <herr_t>


where H5L_iterate_t a = H5Iterate

So the call back should keep the information of the type via a


my question is, when I write this

  let opData = InOut $ castStablePtrToPtr statePtr

I have InOut (Ptr ()) is it possible to have somthing more like InOut (Ptr a) 
instead ?

Thanks

Fred

------------------------------

Message: 2
Date: Wed, 28 Jun 2017 16:24:49 +0200
From: Sylvain Henry <sylv...@haskus.fr>
To: beginners@haskell.org
Subject: Re: [Haskell-beginners] which typefor this FFI call
Message-ID: <14138a68-a608-194e-b94a-1f0e09dc6...@haskus.fr>
Content-Type: text/plain; charset=utf-8; format=flowed

On 28/06/2017 15:27, PICCA Frederic-Emmanuel wrote:
> my question is, when I write this
>
>    let opData = InOut $ castStablePtrToPtr statePtr
>
> I have InOut (Ptr ()) is it possible to have somthing more like InOut (Ptr a) 
> instead ?
>

Yes it's strange that `castStablePtrToPtr` returns `Ptr ()` instead of 
`Ptr a`. You can use `castPtr` to get the type back:

   let opData = InOut $ castPtr $ castStablePtrToPtr statePtr


https://www.stackage.org/haddock/lts-8.20/base-4.9.1.0/Foreign-Ptr.html#v:castPtr

-Sylvain


------------------------------

Message: 3
Date: Wed, 28 Jun 2017 14:48:56 +0000
From: PICCA Frederic-Emmanuel
        <frederic-emmanuel.pi...@synchrotron-soleil.fr>
To: "The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell" <beginners@haskell.org>
Subject: Re: [Haskell-beginners] which typefor this FFI call
Message-ID:
        
<a2a20ec3b8560d408356cac2fc148e53bb385...@sun-dag3.synchrotron-soleil.fr>
        
Content-Type: text/plain; charset="us-ascii"

> Yes it's strange that `castStablePtrToPtr` returns `Ptr ()` instead of
> `Ptr a`. You can use `castPtr` to get the type back:

the type signature of castStablePtrTOPtr  is :: StablePtr a -> Ptr ()

So yes we loose the type. 

I will check if this work

>   let opData = InOut $ castPtr $ castStablePtrToPtr statePtr

Thanks

Frederic

ps: 
http://hackage.haskell.org/package/base-4.9.1.0/docs/Foreign-StablePtr.html#v:castStablePtrToPtr

------------------------------

Message: 4
Date: Wed, 28 Jun 2017 22:01:10 +0200
From: Silent Leaf <silent.le...@gmail.com>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <beginners@haskell.org>
Subject: [Haskell-beginners] tail recursion optimizations and monads
Message-ID:
        <CAGFccjNiW6=GX+Gdz+qyZtwzOPbNMjo=dom6xjnegagus4q...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Hi,

If i do this:
f :: (Monad m) => a -> m a
f a = ma >>= f

 or maybe this:
f :: (Monad m) => Foo -> m a
f foo = mb >>= \foo' -> mc >> f foo'


can i be sure it's tail recursive (as in, with optimization)? is it in fact
ever the case? does it depend on the monad? esp obviously i'm very
interested in the IO monad in those cases. esp, even if it's tail recursive
on the level of haskell, does it entail an execution of the underlying IO
action in any way tail-recursively optimized? or does it not even matter
because at the level of the execution of the IO value, there's no recursion
to speak of anymore? just wondering.

thanks in advance!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20170628/cea0fcd9/attachment-0001.html>

------------------------------

Message: 5
Date: Thu, 29 Jun 2017 12:12:07 +0200
From: Silent Leaf <silent.le...@gmail.com>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <beginners@haskell.org>
Subject: [Haskell-beginners] where do non-beginners haskellers go to
        expose  code to the community?
Message-ID:
        <cagfccjmpwjv4yp9xe6jkbvtswhh1bbbqjbqhw_afdioh6cf...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

hi,

let's say i'm a real-deal but typically open-source/not-employed haskeller,
i have a really well-done library/program. i want to publish it so it's
available, but i also want to just broadcast to at least a part of the
haskell community basically saying "hiya, made that cool code, go check it
out". both to get returns and ideas, but not so much for code-review, since
it's about reviewing a finished product, or at least an alpha/beta version.
where would i go to do that? (again, it's hypothetical, i'm not real-deal
yet)

i mean what's the point of coding if nobody knows what you do, right? (of
course the question is not serious, but still, it must count for a bit
right? if you don't get paid or you don't sell your code and it's not only
for your own usage?)

but maybe there are ways by which most haskellers go check the latest
published packages? or maybe the community is not that tight-knit?
or maybe it does not depend on the language, and there are places where to
make your code known to potential users? i admit i don't actually know how
someone with an opensource program would go to advertize it. even creating
a website for it does not tell anybody that it exists.

was just wondering. it'd be somewhat good if there were a centralized place
where to review any package published on official repositories, both wrt
the code and the functionalities. a kind of message board automatically
plugged to the flux of published packages.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20170629/aea90010/attachment-0001.html>

------------------------------

Message: 6
Date: Thu, 29 Jun 2017 12:54:06 +0200
From: Francesco Ariis <fa...@ariis.it>
To: beginners@haskell.org
Subject: Re: [Haskell-beginners] where do non-beginners haskellers go
        to expose code to the community?
Message-ID: <20170629105406.ld5gmdrsbc7js...@x60s.casa>
Content-Type: text/plain; charset=us-ascii

On Thu, Jun 29, 2017 at 12:12:07PM +0200, Silent Leaf wrote:
> hi,
> 
> let's say i'm a real-deal but typically open-source/not-employed haskeller,
> i have a really well-done library/program. i want to publish it so it's
> available, but i also want to just broadcast to at least a part of the
> haskell community basically saying "hiya, made that cool code, go check it
> out". both to get returns and ideas, but not so much for code-review, since
> it's about reviewing a finished product, or at least an alpha/beta version.
> where would i go to do that? (again, it's hypothetical, i'm not real-deal
> yet)

Hello Silent Leaf,
    usually I keep up with the Haskellers in 3 ways:

    1. by checking the `Haskell Communities and Activities Report` [1]
    2. by being subscribed to Haskell announce [2]
    3. by subscribing to the "uploaded recently" RSS feed [3]

If I want to broadcast a release and get feedback, writing to
haskell-announce and haskell-cafe is the way to go.

[1] https://wiki.haskell.org/Haskell_Communities_and_Activities_Report
[2] https://mail.haskell.org/mailman/listinfo/haskell
[3] https://hackage.haskell.org/packages/recent.rss


------------------------------

Message: 7
Date: Thu, 29 Jun 2017 13:55:24 +0200
From: Silent Leaf <silent.le...@gmail.com>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <beginners@haskell.org>
Subject: Re: [Haskell-beginners] where do non-beginners haskellers go
        to expose code to the community?
Message-ID:
        <CAGFccjOcgUtLhP5=Lzc29Jarbgu-0D=90sogzvcm_873pxe...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

great, that's what i was looking for! thanks :)
maybe in several months i'll be good enough for publishing :)

2017-06-29 12:54 GMT+02:00 Francesco Ariis <fa...@ariis.it>:

> On Thu, Jun 29, 2017 at 12:12:07PM +0200, Silent Leaf wrote:
> > hi,
> >
> > let's say i'm a real-deal but typically open-source/not-employed
> haskeller,
> > i have a really well-done library/program. i want to publish it so it's
> > available, but i also want to just broadcast to at least a part of the
> > haskell community basically saying "hiya, made that cool code, go check
> it
> > out". both to get returns and ideas, but not so much for code-review,
> since
> > it's about reviewing a finished product, or at least an alpha/beta
> version.
> > where would i go to do that? (again, it's hypothetical, i'm not real-deal
> > yet)
>
> Hello Silent Leaf,
>     usually I keep up with the Haskellers in 3 ways:
>
>     1. by checking the `Haskell Communities and Activities Report` [1]
>     2. by being subscribed to Haskell announce [2]
>     3. by subscribing to the "uploaded recently" RSS feed [3]
>
> If I want to broadcast a release and get feedback, writing to
> haskell-announce and haskell-cafe is the way to go.
>
> [1] https://wiki.haskell.org/Haskell_Communities_and_Activities_Report
> [2] https://mail.haskell.org/mailman/listinfo/haskell
> [3] https://hackage.haskell.org/packages/recent.rss
> _______________________________________________
> Beginners mailing list
> Beginners@haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20170629/9dd42cac/attachment.html>

------------------------------

Subject: Digest Footer

_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners


------------------------------

End of Beginners Digest, Vol 108, Issue 22
******************************************

Reply via email to