[Haskell-cafe] haskell; json-rpc

2011-07-05 Thread Комар Максим
Apologize in advance for the English language.

I'm working with json-rpc interface (http://json-rpc.org/) via http.
Requests and responses look like this:
- {jsonrpc : 2.0, id : 1, method : user.authenticate, 
params : { user : myUser, password : myPassword }}

-
{jsonrpc:2.0,result:97d4b59d2f2fbf703bb7aa257aae5254,id:1}

- {jsonrpc : 2.0, id : 2, method : user.getObjects, 
auth : 97d4b59d2f2fbf703bb7aa257aae5254, 
params : { alias : myUser }}

-
{jsonrpc:2.0,result:[{userid:3,alias:myUser,name:lala,
surname:lala,passwd:c5aba41f671a02a3c8a6f10a2a7d8a19,
url:myUrl,autologin:1,autologout:0,lang:ru_ru,
refresh:30,type:1,theme:css_bb.css,attempt_failed:0,
attempt_ip:0.0.0.0,attempt_clock:1282502966,
rows_per_page:50}],id:2}


How can i describe in Haskell my task? 

P.S. The first request is required for authentication (field auth in
the following queries). Using the second query, I want to know
userid).

P.P.S. My first approach is to describe rpc query as following:
data RpcQuery = RpcQuery {
rpcVersion :: String,
rpcId :: String,
rpcMethod :: String,
rpcAuth :: String,
rpcParams :: AuthUser
} deriving (Show)

data AuthUser = AuthUser {
authUser :: String,
authPassword :: String
} deriving (Show)

instance JSON AuthUser where
showJSON au = makeObj
[ (user, showJSON $ authUser au)
, (password, showJSON $ authPassword au)
]

readJSON (JSObject obj) = let
jsonObjAssoc = fromJSObject obj
in do   
user - mLookup user jsonObjAssoc = readJSON
password - mLookup password jsonObjAssoc =
readJSON
return $ AuthUser
{ authUser = user
, authPassword = password
}

readJSON _ = fail 

But this scheme is not extended.


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] video for linux two (v4l2) bindings

2011-07-05 Thread Christopher Done
On 3 July 2011 21:46, Daniel Fischer daniel.is.fisc...@googlemail.com wrote:
 On Sunday 03 July 2011, 21:34:17, Christopher Done wrote:
 I just had a quick try with cabal-install and got the below. I'm not
 sure where linux/posix_types is supposed to come from. Is this error
 obvious to you?

 glibc-devel or the equivalent package for your distro, I think.

It turned out that I needed the linux development files from
linux-libc-dev. FWIW to anyone, I'm on Ubuntu. The packages I
installed were:

sudo apt-get install linux-libc-dev
sudo apt-get install libv4l-dev

Then I got this problem:

/home/chris/Programs/bin/ghc --make -o
dist/build/v4l2-capture/v4l2-capture -hide-all-packages
-fbuilding-cabal-package -package-conf dist/package.conf.inplace -i
-idist/build/v4l2-capture/v4l2-capture-tmp -i. -idist/build/autogen
-Idist/build/autogen -Idist/build/v4l2-capture/v4l2-capture-tmp
-optP-include -optPdist/build/autogen/cabal_macros.h -odir
dist/build/v4l2-capture/v4l2-capture-tmp -hidir
dist/build/v4l2-capture/v4l2-capture-tmp -stubdir
dist/build/v4l2-capture/v4l2-capture-tmp -package-id
base-4.2.0.2-5fc3ebcb886ceae9a06b0bab7e8d4680 -package-id
bindings-libv4l2-0.1-8dde216a9ec82cb90bbe93e20783ff8c -package-id
bindings-linux-videodev2-0.1-7a032e0014085bf53e381d004d794b50
-package-id bindings-mmap-0.1-3144f93204d922458a3be21650b85f1f
-package-id bindings-posix-1.2.2-00b879b119996c2d3acc7989dde2ba63
-package-id c-io-0.1.0-dcc629f98d0e4b2e0d55acbaaa6262b6 -package-id
ioctl-0.0.1-60f1d8091a07bb23f1736fec7d2b4dd8 -O -Wall
./src/v4l2-capture.hs
[1 of 1] Compiling Main ( src/v4l2-capture.hs,
dist/build/v4l2-capture/v4l2-capture-tmp/Main.o )
Linking dist/build/v4l2-capture/v4l2-capture ...
/usr/bin/ld: 
/home/chris/.cabal/lib/bindings-posix-1.2.2/ghc-6.12.3/libHSbindings-posix-1.2.2.a(Signal.o):(.text+0x5dfb):
error: undefined reference to 'pthread_kill'
/usr/bin/ld: 
/home/chris/.cabal/lib/bindings-posix-1.2.2/ghc-6.12.3/libHSbindings-posix-1.2.2.a(Signal.o):(.text+0x5ee2):
error: undefined reference to 'pthread_kill'
/usr/bin/ld: 
/home/chris/.cabal/lib/bindings-posix-1.2.2/ghc-6.12.3/libHSbindings-posix-1.2.2.a(Signal.o):(.text+0x5f87):
error: undefined reference to 'pthread_sigmask'
/usr/bin/ld: 
/home/chris/.cabal/lib/bindings-posix-1.2.2/ghc-6.12.3/libHSbindings-posix-1.2.2.a(Signal.o):(.text+0x6092):
error: undefined reference to 'pthread_sigmask'
collect2: ld returned 1 exit status
cabal: Error: some packages failed to install:
v4l2-examples-0.1 failed during the building phase. The exception was:
ExitFailure 1
chris@cn-done:~/v4l2-examples-0.1$

But I solved it by adding -lpthread:

chris@cn-done:~/v4l2-examples-0.1$ /home/chris/Programs/bin/ghc --make
-o dist/build/v4l2-capture/v4l2-capture -hide-all-packages
-fbuilding-cabal-package -package-conf dist/package.conf.inplace -i
-idist/build/v4l2-capture/v4l2-capture-tmp -i. -idist/build/autogen
-Idist/build/autogen -Idist/build/v4l2-capture/v4l2-capture-tmp
-optP-include -optPdist/build/autogen/cabal_macros.h -odir
dist/build/v4l2-capture/v4l2-capture-tmp -hidir
dist/build/v4l2-capture/v4l2-capture-tmp -stubdir
dist/build/v4l2-capture/v4l2-capture-tmp -package-id
base-4.2.0.2-5fc3ebcb886ceae9a06b0bab7e8d4680 -package-id
bindings-libv4l2-0.1-8dde216a9ec82cb90bbe93e20783ff8c -package-id
bindings-linux-videodev2-0.1-7a032e0014085bf53e381d004d794b50
-package-id bindings-mmap-0.1-3144f93204d922458a3be21650b85f1f
-package-id bindings-posix-1.2.2-00b879b119996c2d3acc7989dde2ba63
-package-id c-io-0.1.0-dcc629f98d0e4b2e0d55acbaaa6262b6 -package-id
ioctl-0.0.1-60f1d8091a07bb23f1736fec7d2b4dd8 -O -Wall
./src/v4l2-capture.hs -lpthread
Linking dist/build/v4l2-capture/v4l2-capture ...
chris@cn-done:~/v4l2-examples-0.1$

I guess on Claude's system it's linked to by default. So for guys
trying the examples with that error I'd recommend the following
commandline:

  cabal install v4l2-examples --ghc-option=-lpthread

Can't really play about with the webcam right now but I'd had a small
but cool project I've had in mind for a while that v4l is perfectly
suited for, so I'll get back to you with my experiences. Thanks for
releasing it, Claude. :-)

Ciao!

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Haskell and Databases

2011-07-05 Thread Isak Hansen
On Fri, Jul 1, 2011 at 8:45 PM, Tobias Schoofs tobias.scho...@gmx.net wrote:

 Database programs, usually, do not just issue isolated SQL statements, but
 implement a processing logic with nested queries and DML statements.

Frequently using cursors or issuing queries from a loop often means
you've missed out on the declarative and set based nature of SQL and
databases.

http://www.sqlservercentral.com/articles/T-SQL/66097/
http://stackoverflow.com/questions/287445/why-do-people-hate-sql-cursors-so-much


Granted, you could still argue that it should be supported, for the
few cases where it actually makes sense.


Isak

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Splitting Hackage Packages and re-exporting entire modules (with same module name)

2011-07-05 Thread Antoine Latter
If you give the module a new name in the new package then the old
module can re-export all of the symbols in the new module.

In GHC I don't think there is a way for two packages to export the
same module and have them be recognized as the same thing, as far as I
know.

Antoine

On Tue, Jul 5, 2011 at 12:36 AM, Thomas DuBuisson
thomas.dubuis...@gmail.com wrote:
 All,

 I have decided it would be beneficial to split System.Crypto.Random
 and the rest of crypto-api into different packages.  Is there I way I
 can create a package, entropy, with System.Crypto.Random but
 continue to expose that module from crypto-api (allowing people who
 use that module some time to move)?  If so, how?  If not, does anyone
 else see value in this and how it can be added to the infrastructure?

 Cheers,
 Thomas

 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] NVIDIA's CUDA and Haskell

2011-07-05 Thread Trevor L. McDonell
I should mention that the version of 'accelerate' on hackage is a little old and
unloved at the moment, but the source repo should work:

https://github.com/mchakravarty/accelerate

Also, the CUDA bindings package hasn't yet been tested/updated for the recent
4.0 toolkit release.

-T


On 05/07/2011, at 10:13 AM, Don Stewart wrote:

 There's a lot of active work:
 
 Direct access to CUDA: http://hackage.haskell.org/package/cuda
 CUDA in Haskell: http://hackage.haskell.org/package/language-c-quote
 Direct access to OpenCL: http://hackage.haskell.org/package/OpenCLRaw
 High-level pure data parallelism targetting your GPU:
 http://hackage.haskell.org/package/accelerate
 
 On Mon, Jul 4, 2011 at 8:09 PM, Vasili I. Galchin vigalc...@gmail.com wrote:
 Hi,
 
   NVIDIA's CUDA library seems to be really hot in the massively parallel
 world: http://www.nvidia.com/object/cuda_home_new.html. I realize that given
 CUDA seems to be implemented in an extension of ANSI C that it is pervaded
 by statefulness. However, is there any effort to build a bridge between
 Haskell and CUDA, foreign language bindings or maybe better yet a monad to
 encapsulate state??
 
 Kind regards,
 
 Vasili
 
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe
 
 
 
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] NVIDIA's CUDA and Haskell

2011-07-05 Thread Johannes Waldmann
Trevor L. McDonell tmcdonell at cse.unsw.edu.au writes:

 ... source repo should work:
 https://github.com/mchakravarty/accelerate

I have CUDA in the default location (e.g., /usr/local/cuda/bin/nvcc )
but I can't seem to get the cuda cabal package to build

...
checking cuda.h usability... yes
checking cuda.h presence... yes
checking for cuda.h... yes
checking cuda_runtime_api.h usability... yes
checking cuda_runtime_api.h presence... yes
checking for cuda_runtime_api.h... yes
checking for library containing cuDriverGetVersion... no
configure: error: could not find CUDA driver library

I have nvcc in the PATH, and I also set --extra-include/lib-dirs

I can build and run the NVIDIA_GPU_Computing_SDK examples.




___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Automatic Reference Counting

2011-07-05 Thread Maarten Hazewinkel
On 2 Jul 2011, at 18:35, Thomas Davie wrote:
 
 It's interesting that you cite that GC is both faster and lower memory 
 overhead – Apple's stated reasons for implementing this were that GC was both 
 too slow and too memory intensive to use sensibly on iDevices and that ARC 
 was both faster and less memory intensive.

Reality is probably a little more subtle than this.

In general, and specifically for long-running and memory intensive processes 
(such as used in servers), quality garbage collection (and especially 
compacting garbage collection) are probably more efficient overall.

Apple already supported (and continues to support) garbage collection for 
Objective-C in their desktop systems.

The primary motivation (as I understand it) for developing ARC is to bring 
(mostly) automatic memory management to the iOS platforms. There are 2 reasons 
that I've heard why Apple considers ARC a superior solution for the iOS 
platform:

1. iOS devices are much more resource constrained than a desktop system. 
Therefore the delay that garbage collection causes before memory is available 
for re-allocation can have a much greater effects on application.

2. Running a background garbage collector can introduce unpredictable pauses in 
your application, which would destroy the illusion of immediacy that is one of 
the prime characteristics of good iOS apps.

So for iOS immediate memory release and predictable performance trumps overall 
average performance.


To see if this technique would be at all useful for Haskell, you'll have to 
evaluate these points in the context of a Haskell application and decide which 
trade-off brings you the most benefit.


Maarten
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Searching of several substrings (with Data.Text ?)

2011-07-05 Thread Tillmann Vogt

Hi,

For my font library I need A function that can handle ligatures. It can 
be explained best with an example:


f  [Th, ff, fi, fl, ffi]  The fluffiest bunny

should be evaluated to

[Th, e,  , fl, u, ffi, e, s, t,  , b, u, n, 
n, y ]


I looked at Data.Text 
http://hackage.haskell.org/packages/archive/text/0.5/doc/html/Data-Text.html
and 
http://hackage.haskell.org/packages/archive/stringsearch/0.3.3/doc/html/Data-ByteString-Search.html


but they don't have a function that can search several substrings in one 
run.
I guess that searching a text again and again for every substring is not 
very efficient and it can be done in one run.
Although I may figure this out myself I think such a function could be 
so common that someone has done it or can give me some tips.


Thanks

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Searching of several substrings (with Data.Text ?)

2011-07-05 Thread Johannes Waldmann
 ... a function that can search several substrings in one run.

use regular expressions? (the regexp can be compiled
into a finite automaton that scans the string just once.)




___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Searching of several substrings (with Data.Text ?)

2011-07-05 Thread Daniel Fischer
On Tuesday 05 July 2011, 20:01:26, Tillmann Vogt wrote:
 Hi,
 
 For my font library I need A function that can handle ligatures. It can
 be explained best with an example:
 
 f  [Th, ff, fi, fl, ffi]  The fluffiest bunny
 
 should be evaluated to
 
 [Th, e,  , fl, u, ffi, e, s, t,  , b, u, n,
 n, y ]
 
 I looked at Data.Text
 http://hackage.haskell.org/packages/archive/text/0.5/doc/html/Data-Text.
 html and
 http://hackage.haskell.org/packages/archive/stringsearch/0.3.3/doc/html/
 Data-ByteString-Search.html
 
 but they don't have a function that can search several substrings in one
 run.

Well, Data.ByteString[.Lazy].KarpRabin does provide simultaneous search for 
multiple substrings - it does not, however, provide direct splitting.

But in my tests, unless the number of substrings was large, multiple 
separate (Boyer-Moore) passes with manual merging of the offset lists were 
much faster [there's a possible space leak for lazy ByteStrings if any 
pattern does not appear in a long substring of the source, so that would be 
a point for Data.ByteString.Lazy.KarpRabin], and I didn't know of any real 
use-case, so I did not pursue it further and considered it just an 
interesting curiosity.

I suppose using a regex package as Johannes Waldmann suggested would be the 
easiest way (probably also faster).

If you submit a feature request, however, I would look into expanding the 
offered functionality (but I'll be on vacation soon, so performance would 
have to wait; I suppose something could be gained there).

 I guess that searching a text again and again for every substring is not
 very efficient and it can be done in one run.

Well, it is surprisingly efficient, compared to (my implementation of) the 
Karp-Rabin algorithm at least.

 Although I may figure this out myself I think such a function could be
 so common that someone has done it or can give me some tips.
 
 Thanks

Cheers,
Daniel

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Searching of several substrings (with Data.Text ?)

2011-07-05 Thread Bryan O'Sullivan
On Tue, Jul 5, 2011 at 11:01 AM, Tillmann Vogt tillmann.v...@rwth-aachen.de
 wrote:

 I looked at Data.Text http://hackage.haskell.org/**
 packages/archive/text/0.5/doc/**html/Data-Text.htmlhttp://hackage.haskell.org/packages/archive/text/0.5/doc/html/Data-Text.html
 and http://hackage.haskell.org/**packages/archive/stringsearch/**
 0.3.3/doc/html/Data-**ByteString-Search.htmlhttp://hackage.haskell.org/packages/archive/stringsearch/0.3.3/doc/html/Data-ByteString-Search.html

 but they don't have a function that can search several substrings in one
 run.


Here's what you want:
http://hackage.haskell.org/packages/archive/text-icu/0.6.3.4/doc/html/Data-Text-ICU-Regex.html
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] How to ensure code executes in the context of a specific OS thread?

2011-07-05 Thread Simon Marlow

On 04/07/11 06:02, Jason Dagit wrote:

Hello,

I'm trying to get some GUI code working on OSX and numerous forums
around the internet keep reiterating that on OSX to correctly handle
GUI events you need to use the original thread allocated to your
process to check for events and to call the Cocoa framework
functionality.  Specifically, using a secondary thread (even a bound
thread) is not sufficient with the Cocoa framework.

I looked at the threading documentation in Control.Concurrent for GHC
and it's not clear to me if this is even possible with GHC without
restricting to the non-threaded RTS.  This means that using the GUI
library from GHCI is not an option and using multiple OS threads in
the final application is also not possible.  This means that some FFI
libraries will be unusable.


In a compiled program, the main thread is a bound thread, bound to the 
main OS thread of the process (i.e. the GUI thread in your case).  So 
you can safely make Cocoa calls using the main thread of your compiled 
Haskell program, and from other threads if you add some way to forward 
operations to the main thread, like gtk2hs's postGUI.


In GHCi it's a different matter, because the main thread is running GHCi 
itself, and all the expressions/statements typed at the prompt are run 
in forkIO'd threads (a new one for each statement, in fact).  If you 
want a way to run command-line operations in the main thread, please 
submit a feature request.  I'm not sure it can be done, but I'll look 
into it.


Cheers,
Simon



___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Searching of several substrings (with Data.Text ?)

2011-07-05 Thread Eric Rasmussen
I've been looking into building parsers at runtime (from a config
file), and in my case it's beneficial to fit them into the context of
a larger parser with Attoparsec.Text. This code is untested for
practical use so I doubt you'll see comparable performance to the
aforementioned regex packages, but it could be worth exploring if you
need to mix and match parsers or if the definitions can change
arbitrarily at runtime.

import qualified Data.Text as T
import Data.Attoparsec.Text
import Control.Applicative ((|))

parseLigature x = string (T.pack x)

charToText = do c - anyChar
return (T.singleton c)

buildChain [x]= parseLigature x
buildChain (x:xs) = try (parseLigature x) | buildChain xs

-- ordering matters here, so ffi comes before ff or fi
ligatures = buildChain [ffi, th, ff, fi, fl]

myParser = many (try ligatures | charToText)

-- at ghci prompt: parseOnly myParser (T.pack the fluffiest bunny)
-- Right [th,e, ,fl,u,ffi,e,s,t, ,b,u,n,n,y]




On Tue, Jul 5, 2011 at 12:09 PM, Bryan O'Sullivan b...@serpentine.com wrote:
 On Tue, Jul 5, 2011 at 11:01 AM, Tillmann Vogt
 tillmann.v...@rwth-aachen.de wrote:

 I looked at Data.Text
 http://hackage.haskell.org/packages/archive/text/0.5/doc/html/Data-Text.html
 and
 http://hackage.haskell.org/packages/archive/stringsearch/0.3.3/doc/html/Data-ByteString-Search.html

 but they don't have a function that can search several substrings in one
 run.

 Here's what you want:
 http://hackage.haskell.org/packages/archive/text-icu/0.6.3.4/doc/html/Data-Text-ICU-Regex.html
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe



___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] How to ensure code executes in the context of a specific OS thread?

2011-07-05 Thread Ian Lynagh
On Tue, Jul 05, 2011 at 08:11:21PM +0100, Simon Marlow wrote:
 
 In GHCi it's a different matter, because the main thread is running
 GHCi itself, and all the expressions/statements typed at the prompt
 are run in forkIO'd threads (a new one for each statement, in fact).
 If you want a way to run command-line operations in the main thread,
 please submit a feature request.  I'm not sure it can be done, but
 I'll look into it.

We already have a way: -fno-ghci-sandbox


Thanks
Ian


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] How to ensure code executes in the context of a specific OS thread?

2011-07-05 Thread Jason Dagit
On Tue, Jul 5, 2011 at 12:11 PM, Simon Marlow marlo...@gmail.com wrote:
 On 04/07/11 06:02, Jason Dagit wrote:

 Hello,

 I'm trying to get some GUI code working on OSX and numerous forums
 around the internet keep reiterating that on OSX to correctly handle
 GUI events you need to use the original thread allocated to your
 process to check for events and to call the Cocoa framework
 functionality.  Specifically, using a secondary thread (even a bound
 thread) is not sufficient with the Cocoa framework.

 I looked at the threading documentation in Control.Concurrent for GHC
 and it's not clear to me if this is even possible with GHC without
 restricting to the non-threaded RTS.  This means that using the GUI
 library from GHCI is not an option and using multiple OS threads in
 the final application is also not possible.  This means that some FFI
 libraries will be unusable.

 In a compiled program, the main thread is a bound thread, bound to the main
 OS thread of the process (i.e. the GUI thread in your case).  So you can
 safely make Cocoa calls using the main thread of your compiled Haskell
 program, and from other threads if you add some way to forward operations to
 the main thread, like gtk2hs's postGUI.

Is my understanding correct that this is only the case for the
non-threaded RTS?  If so, what do you do when you need to use the
threaded RTS?  My test was to check if the main thread was bound when
compiling with -threaded.  I got the impression that I couldn't
guarantee that the code was running on the original thread.


 In GHCi it's a different matter, because the main thread is running GHCi
 itself, and all the expressions/statements typed at the prompt are run in
 forkIO'd threads (a new one for each statement, in fact).  If you want a way
 to run command-line operations in the main thread, please submit a feature
 request.  I'm not sure it can be done, but I'll look into it.

I'll try Ian's suggestion of -fno-ghci-sandbox when I get a chance.

Thanks,
Jason

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] ANNOUNCE: test-framework-doctest 0.1

2011-07-05 Thread Sakari Jokinen
test-framework-doctest [1] provides a wrapper for running doctests [2]
in test-framework [3].
This uses the newly minted API exposed by doctest 0.4 that Simon
Hengel just announced [4].

The current incarnation of the package is a very rudimentary. Patches
are more than welcome [5].

Many thanks to Simon Hengel for working with me on this.

[1] http://hackage.haskell.org/package/test-framework-doctest
[2] http://hackage.haskell.org/package/doctest-0.4.0
[3] http://hackage.haskell.org/package/test-framework-0.4.0
[4] http://www.haskell.org/pipermail/haskell-cafe/2011-July/093748.html
[5] https://github.com/sakari/test-framework-doctest

Sakari

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] ANN: Monad.Reader Issue 18

2011-07-05 Thread Brent Yorgey
I am pleased to announce that Issue 18 of The Monad.Reader is now
available [1].

Issue 18 consists of the following three articles:

  * MapReduce as a Monad by Julian Porter

  * Fun with Parallel Monad Comprehensions by Tomas Petricek

  * Attributed Variables: Their Uses and One Implementation by
Douglas M. Auclair

Feel free to browse the source files. You can check out the entire
repository using darcs (or simply visit the below URL in your
browser):

  darcs get http://code.haskell.org/~byorgey/TMR/Issue18

Enjoy!

[1] http://themonadreader.files.wordpress.com/2011/07/issue18.pdf

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Searching of several substrings (with Data.Text ?)

2011-07-05 Thread Tillmann Vogt

Am 05.07.2011 21:29, schrieb Eric Rasmussen:

I've been looking into building parsers at runtime (from a config
file), and in my case it's beneficial to fit them into the context of
a larger parser with Attoparsec.Text. This code is untested for
practical use so I doubt you'll see comparable performance to the
aforementioned regex packages, but it could be worth exploring if you
need to mix and match parsers or if the definitions can change
arbitrarily at runtime.

import qualified Data.Text as T
import Data.Attoparsec.Text
import Control.Applicative ((|))

parseLigature x = string (T.pack x)

charToText = do c- anyChar
 return (T.singleton c)

buildChain [x]= parseLigature x
buildChain (x:xs) = try (parseLigature x)|  buildChain xs

-- ordering matters here, so ffi comes before ff or fi
ligatures = buildChain [ffi, th, ff, fi, fl]

myParser = many (try ligatures|  charToText)

-- at ghci prompt: parseOnly myParser (T.pack the fluffiest bunny)
-- Right [th,e, ,fl,u,ffi,e,s,t, ,b,u,n,n,y]


Of course parsec! I should have thought of this.
icu seems to be the best solution (I already considered it for parsing 
character references), but it is not so easy to install on windows. So I 
wait until cabal does this or it is integrated into the haskell platform.


Thank you all for your help (especially the attoparsec example)





On Tue, Jul 5, 2011 at 12:09 PM, Bryan O'Sullivanb...@serpentine.com  wrote:

On Tue, Jul 5, 2011 at 11:01 AM, Tillmann Vogt
tillmann.v...@rwth-aachen.de  wrote:

I looked at Data.Text
http://hackage.haskell.org/packages/archive/text/0.5/doc/html/Data-Text.html
and
http://hackage.haskell.org/packages/archive/stringsearch/0.3.3/doc/html/Data-ByteString-Search.html

but they don't have a function that can search several substrings in one
run.

Here's what you want:
http://hackage.haskell.org/packages/archive/text-icu/0.6.3.4/doc/html/Data-Text-ICU-Regex.html
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe



___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe





___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] How to ensure code executes in the context of a specific OS thread?

2011-07-05 Thread Jason Dagit
On Tue, Jul 5, 2011 at 12:33 PM, Ian Lynagh ig...@earth.li wrote:
 On Tue, Jul 05, 2011 at 08:11:21PM +0100, Simon Marlow wrote:

 In GHCi it's a different matter, because the main thread is running
 GHCi itself, and all the expressions/statements typed at the prompt
 are run in forkIO'd threads (a new one for each statement, in fact).
 If you want a way to run command-line operations in the main thread,
 please submit a feature request.  I'm not sure it can be done, but
 I'll look into it.

 We already have a way: -fno-ghci-sandbox

I've removed all my explicit attempts to forkIO/forkOS and passed the
command line flag you mention.  I just tried this but it doesn't
change the behavior in my example.

Jason

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] ANNOUNCE: FunPat 0.1

2011-07-05 Thread Dévai Gergely

Hello,

I've recently uploaded a package that provides some kind of extended 
pattern matching. For example, one can use (abc ++ xs) as a pattern. 
The original motivation was to allow pattern matching on expressions of 
embedded languages in cases when the constructors of the underlying data 
types are hidden.

For more examples, see http://hackage.haskell.org/package/funpat

Feedback is very welcome!

Cheers,
Gergely


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] NVIDIA's CUDA and Haskell

2011-07-05 Thread Trevor L. McDonell
hmm... so libcuda and libcudart are in /usr/local/cuda/lib and the script isn't
finding them?

Any further information on your system / os combination? What version of the
toolkit are you using? I currently use 3.2, haven't tried with 4.x yet.

 $ nvcc --version
 nvcc: NVIDIA (R) Cuda compiler driver
 Copyright (c) 2005-2010 NVIDIA Corporation
 Built on Thu_Nov_11_15:26:50_PST_2010
 Cuda compilation tools, release 3.2, V0.2.1221



On 05/07/2011, at 10:16 PM, Johannes Waldmann wrote:

 Trevor L. McDonell tmcdonell at cse.unsw.edu.au writes:
 
 ... source repo should work:
 https://github.com/mchakravarty/accelerate
 
 I have CUDA in the default location (e.g., /usr/local/cuda/bin/nvcc )
 but I can't seem to get the cuda cabal package to build
 
 ...
 checking cuda.h usability... yes
 checking cuda.h presence... yes
 checking for cuda.h... yes
 checking cuda_runtime_api.h usability... yes
 checking cuda_runtime_api.h presence... yes
 checking for cuda_runtime_api.h... yes
 checking for library containing cuDriverGetVersion... no
 configure: error: could not find CUDA driver library
 
 I have nvcc in the PATH, and I also set --extra-include/lib-dirs
 
 I can build and run the NVIDIA_GPU_Computing_SDK examples.
 
 
 
 
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Automatic Reference Counting

2011-07-05 Thread steffen
The important point about reference counting on idevices is the near 
realtime performance, since stops for collecting garbage are actually very 
short in comparison to collecting compilers (despite more frequent). Some 
compilers, I think it was for the pure functional programming language OPAL 
if I'm not wrong even check at compile time and add code for reusing cells 
instead of freeing them when it is known to be safe. But OPAL has strict 
evaluation and no lazy construct. This it does not allow for cycles unlike 
haskell which makes reference counting a viable and easy implementable 
option for OPAL.

About Apple's ARC. It is actually using the very same mechanisms the clang 
static analyzer uses. That is at a first stage it works with the typical 
Objective-C conventions of object ownership. For example if you have a 
function other than alloc and Co. transferring object ownership to it's 
caller the static analyzer will complain about a possible space leak. In 
this case one has to add an attribute to the function telling the compiler 
that it is intended for the function to work like this. Having a look at the 
ARC docs it seems to be the very same case. That is if you have a function 
like just mentioned you need to add this said attribute to the function 
declaration for ARC to insert correct retains/releases. 

So there is no real magic going on, but one needs to be really aware of it 
or bug hunting (especially for external libraries) may become maybe a 
little less funny...

Additionally clang adds some extra commands into the generated LLVM code 
which LLVM understands. This allows i) for further optimizations at later 
compiling stages and ii) you don't need to send messages to objects anymore 
for reference counting (as long as you don't implement retain/release for 
them by yourself, but by convention you don't do so...), but the counter may 
be accessed directly in memory. That's why ARC (if you follow Apple's 
conventions about object ownership) can be much more efficient than the 
current implementation.

- Steffen
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe