Send Beginners mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
        [email protected]

You can reach the person managing the list at
        [email protected]

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


Today's Topics:

   1.  scotty + ffi segfault (Miro Karpis)
   2. Re:  scotty + ffi segfault (Brandon Allbery)
   3. Re:  scotty + ffi segfault (Miro Karpis)
   4.  backtracking search and memory usage (Dennis Raddle)
   5.  Gnome's FLOSS Outreach Program for Women and     Google Summer
      of Code Opportunities (K?ra)
   6. Re:  Gnome's FLOSS Outreach Program for Women and Google
      Summer of Code Opportunities (Mateusz Kowalczyk)


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

Message: 1
Date: Fri, 14 Mar 2014 21:46:48 +0100
From: Miro Karpis <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: [Haskell-beginners] scotty + ffi segfault
Message-ID:
        <CAJnnbxHfMktO8jkDJQRhiNdoX3nFX6=b7nWgfTixVUzmb=3...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

Hi, please can you help me with following?

I'm trying to combine scotty + ffi but it returns 'Segmentation
fault/access violation in generated code'.

The thing is, that when I run only the ffi setmodulestring function,
everything works fine. When I call it from scotty I get the segfault. I
have hardcoded the 'param' and 'value' parameters in setmodulestring
function just to be sure that the input is correct.

scotty code:

main = scotty 3000 $ do
middleware logStdoutDev

post "/setstringtest" $ do
let param = "FilePath"
let value = "C:/dev/misc/haskell/services/FM"
result <- liftIO $ FM.setmodulestring param value
text "done"

ffi code:

setmodulestring :: String -> String -> IO CInt
setmodulestring param value = do
cParam <- newCString param
cValue <- newCString value
let cParamLength = fromIntegral $ length param ::CInt
    cValueLength = fromIntegral $ length value ::CInt
    setVarInArray = (-1)::CInt
result <- c_setmodulestring cParam cParamLength cValue cValueLength
setVarInArray
return result


Any comments/ideas more than appreciated.

Cheers,
Miro
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20140314/d806ec4c/attachment-0001.html>

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

Message: 2
Date: Fri, 14 Mar 2014 16:52:03 -0400
From: Brandon Allbery <[email protected]>
To: Miro Karpis <[email protected]>,  The Haskell-Beginners
        Mailing List - Discussion of primarily beginner-level topics related
        to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] scotty + ffi segfault
Message-ID:
        <CAKFCL4W63NaVXJ9hz7gkSE5=mV-901AfPNOeNm=wW=5thzu...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

On Fri, Mar 14, 2014 at 4:46 PM, Miro Karpis <[email protected]>wrote:

> setmodulestring :: String -> String -> IO CInt
> setmodulestring param value = do
>  cParam <- newCString param
> cValue <- newCString value
> let cParamLength = fromIntegral $ length param ::CInt
>     cValueLength = fromIntegral $ length value ::CInt
>     setVarInArray = (-1)::CInt
> result <- c_setmodulestring cParam cParamLength cValue cValueLength
> setVarInArray
>  return result
>

The path you show earlier looks like Windows; you probably want CWString
for Win32 API functions (so newCWString etc.).

-- 
brandon s allbery kf8nh                               sine nomine associates
[email protected]                                  [email protected]
unix, openafs, kerberos, infrastructure, xmonad        http://sinenomine.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20140314/e6a9ef9a/attachment-0001.html>

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

Message: 3
Date: Fri, 14 Mar 2014 22:21:52 +0100
From: Miro Karpis <[email protected]>
To: Brandon Allbery <[email protected]>
Cc: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] scotty + ffi segfault
Message-ID:
        <cajnnbxeqe5rmotiactr2ssra6i6jy4jwwgedhgzqx1x3wjj...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

thanks, but also after changing my CString/newCString to
CWString/newCWString I'm getting the segfault. As I mentioned if I run
the setmodulestring
function from ghci everyting works fine (I get proper return value). The
problem only comes if I call setmodulestring from the main.

I have simplified the main here:
main = do
let param = "FilePath"
let value = "C:/dev/misc/haskell/services/FM"
result <- liftIO $ FM.setmodulestring param value
return "done"

Another strange thing is that I can call another external function from the
'main' function without problem.


On Fri, Mar 14, 2014 at 9:52 PM, Brandon Allbery <[email protected]>wrote:

> On Fri, Mar 14, 2014 at 4:46 PM, Miro Karpis <[email protected]>wrote:
>
>> setmodulestring :: String -> String -> IO CInt
>> setmodulestring param value = do
>>  cParam <- newCString param
>> cValue <- newCString value
>> let cParamLength = fromIntegral $ length param ::CInt
>>     cValueLength = fromIntegral $ length value ::CInt
>>     setVarInArray = (-1)::CInt
>> result <- c_setmodulestring cParam cParamLength cValue cValueLength
>> setVarInArray
>>  return result
>>
>
> The path you show earlier looks like Windows; you probably want CWString
> for Win32 API functions (so newCWString etc.).
>
> --
> brandon s allbery kf8nh                               sine nomine
> associates
> [email protected]
> [email protected]
> unix, openafs, kerberos, infrastructure, xmonad
> http://sinenomine.net
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20140314/d375885a/attachment-0001.html>

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

Message: 4
Date: Fri, 14 Mar 2014 19:06:36 -0700
From: Dennis Raddle <[email protected]>
To: Haskell Beginners <[email protected]>
Subject: [Haskell-beginners] backtracking search and memory usage
Message-ID:
        <CAKxLvop6usYGV53u06gN1fPW=2mu2d245ai65v_bo7430kk...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

I want to implement backtracking search, but I wonder if I'm going to
immediately run into memory usage problems if I don't use strict evaluation
somewhere. I'm very hazy on how to implement strict evaluation. I'm
thinking of creating a generic algorithm that looks something like the
following.

We have the concept of a data construct that can be built step by step. At
each step are choices. We are investigating all the choices and finding
series of choices that lead to a completed data construct or "solution." We
want to generate a list of all solutions.

(My Haskell syntax is rusty so there may be errors in the following.)


class Construct a where
  enumerateChoices :: a -> [b]
  applyChoice :: a -> b -> a
  isSolution :: a -> Bool

backtrack :: Construct a => a -> [a]
backtrack c
  | isSolution c = [c]
  | otherwise =
     concat . map (backtrack . applyChoice c) . enumerateChoices $ c

So my question is whether this is going to use a lot of memory to run,
maybe by holding all partially solved data? Where would strict evaluation
go?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20140314/1908a961/attachment-0001.html>

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

Message: 5
Date: Sat, 15 Mar 2014 04:52:24 -0400
From: K?ra <[email protected]>
To: [email protected]
Subject: [Haskell-beginners] Gnome's FLOSS Outreach Program for Women
        and     Google Summer of Code Opportunities
Message-ID:
        <CABhyRUjg_m4fP6h9Q18oPvTwX0Kb9vXfMmSGAdXLp=6x-gj...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Are there any participating organizations in OPW or GSoC providing
opportunities to gain Haskell experience? It would be great to see more
Haskell projects participate in this
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20140315/a3f8ebd9/attachment-0001.html>

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

Message: 6
Date: Sat, 15 Mar 2014 10:16:00 +0000
From: Mateusz Kowalczyk <[email protected]>
To: [email protected]
Subject: Re: [Haskell-beginners] Gnome's FLOSS Outreach Program for
        Women and Google Summer of Code Opportunities
Message-ID: <[email protected]>
Content-Type: text/plain; charset=UTF-8

On 15/03/14 08:52, K?ra wrote:
> Are there any participating organizations in OPW or GSoC providing
> opportunities to gain Haskell experience? It would be great to see more
> Haskell projects participate in this
> 
> 
> 
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
> 

Haskell is part of GSoC this year if that's what you're asking. We're
currently at the proposal stage. No idea about OPW.

-- 
Mateusz K.


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

Subject: Digest Footer

_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners


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

End of Beginners Digest, Vol 69, Issue 18
*****************************************

Reply via email to