Re: [Haskell-cafe] number-parameterized types and heterogeneous lists

2008-06-24 Thread Harald ROTTER

Hello Anton,

thanks for your enlightening piece of code. "foldD" does exactly what I was
hoping for.
Now it becomes very obvious to me that the positions of the forall's in the
Digit definition are crucial.

Thanks a lot to Alfonso, Luke and Ryan as well. Haskell Cafe is a really
good place to learn new things :-)

Harald.



" Ce courriel et les documents qui y sont attaches peuvent contenir des 
informations confidentielles. Si vous n'etes  pas le destinataire escompte, 
merci d'en informer l'expediteur immediatement et de detruire ce courriel  
ainsi que tous les documents attaches de votre systeme informatique. Toute 
divulgation, distribution ou copie du present courriel et des documents 
attaches sans autorisation prealable de son emetteur est interdite." 

" This e-mail and any attached documents may contain confidential or 
proprietary information. If you are not the intended recipient, please advise 
the sender immediately and delete this e-mail and all attached documents from 
your computer system. Any unauthorised disclosure, distribution or copying 
hereof is prohibited."
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] sdl-mixer loading issue

2008-06-24 Thread Luke Palmer
On Tue, Jun 24, 2008 at 11:16 PM, Luke Palmer <[EMAIL PROTECTED]> wrote:
> On Tue, Jun 24, 2008 at 6:34 PM, Norbert Wojtowicz
> <[EMAIL PROTECTED]> wrote:
>>> Attached is a patched version of SDL_mixer 0.5.2 with a C wrapper
>>> for this macro. I'm now able to run loadWAV in ghci.
>>
>> Works for me, thanks!
>>
>> Now I just need to learn how to make my WAVs sound not like
>> computer-generated children voices. For example, using the hback wav
>> files and this:
>>
>> import Control.Concurrent (threadDelay)
>> import Graphics.UI.SDL.Mixer.General
>> import Graphics.UI.SDL.Mixer.Music
>>
>> main = do
>>  openAudio 22050 AudioS16Sys 2 4096
>
> This is probably the issue.  Most wavs are sampled at 44100, not
> 22050, and I think you have to ask mplayer specifically to downsample.

Er, ask sdl-mixer specifically... you knew what I meant.

>  Changing this to
>
>  openAudio 44100 AudioS16Sys 2 4096
>
> should do the trick.
>
> Luke
>
>>  w <- loadMUS "c.wav"
>>  playMusic w 1
>>  threadDelay 200
>>  freeMusic w
>>  closeAudio
>>
>> It plays (which is an immense improvement), but I can't get it to
>> sound the way it does from eg. mplayer. I have almost no knowledge of
>> the inner workings of computer sound drivers, so if there is something
>> obvious I'm missing please do speak up.
>>
>> - Norbert
>> ___
>> 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] sdl-mixer loading issue

2008-06-24 Thread Luke Palmer
On Tue, Jun 24, 2008 at 6:34 PM, Norbert Wojtowicz
<[EMAIL PROTECTED]> wrote:
>> Attached is a patched version of SDL_mixer 0.5.2 with a C wrapper
>> for this macro. I'm now able to run loadWAV in ghci.
>
> Works for me, thanks!
>
> Now I just need to learn how to make my WAVs sound not like
> computer-generated children voices. For example, using the hback wav
> files and this:
>
> import Control.Concurrent (threadDelay)
> import Graphics.UI.SDL.Mixer.General
> import Graphics.UI.SDL.Mixer.Music
>
> main = do
>  openAudio 22050 AudioS16Sys 2 4096

This is probably the issue.  Most wavs are sampled at 44100, not
22050, and I think you have to ask mplayer specifically to downsample.
 Changing this to

  openAudio 44100 AudioS16Sys 2 4096

should do the trick.

Luke

>  w <- loadMUS "c.wav"
>  playMusic w 1
>  threadDelay 200
>  freeMusic w
>  closeAudio
>
> It plays (which is an immense improvement), but I can't get it to
> sound the way it does from eg. mplayer. I have almost no knowledge of
> the inner workings of computer sound drivers, so if there is something
> obvious I'm missing please do speak up.
>
> - Norbert
> ___
> 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] Why the exception?

2008-06-24 Thread skynare
Probably you need to implement coarbitrary, too.
My ghci session for your code:

$ ghci
GHCi, version 6.8.2: http://www.haskell.org/ghc/  :? for help
Loading package base ... linking ... done.
Prelude> :l t.hs
[1 of 1] Compiling Main ( t.hs, interpreted )

t.hs:4:0:
Warning: No explicit method nor default method for `coarbitrary'
In the instance declaration for `Arbitrary L.ByteString'
Ok, modules loaded: Main.
*Main> quickCheck prop_LPS
Loading package array-0.1.0.0 ... linking ... done.
Loading package bytestring-0.9.0.1 ... linking ... done.
Loading package old-locale-1.0.0.0 ... linking ... done.
Loading package old-time-1.0.0.0 ... linking ... done.
Loading package random-1.0.0.0 ... linking ... done.
Loading package QuickCheck-1.1.0.0 ... linking ... done.
OK, passed 100 tests.




On 6/24/08, Thomas M. DuBuisson <[EMAIL PROTECTED]> wrote:
> Cafe
> I'm a bit lost on this exception and curious about what's going on.  Is
> there a valid reason for this exception that I am missing?  Note the
> hard-coded [0..100] could be any Word8 list you want (generated via
> arbitrary, [], or other) and it gives the same result.
>
> Load the module and perform:
>   :break prop_LPS
>   quickCheck prop_LPS
>   :step
>   :force ps
>  *** Exception: Prelude.head: empty list
>
>> import qualified Data.ByteString as L
>> import Test.QuickCheck
>>
>> instance Arbitrary L.ByteString where
>> arbitrary = do
>> return $ L.pack [0..100]
>>
>> prop_LPS :: L.ByteString -> Bool
>> prop_LPS ps = ps `seq` True
>
> P.S. Same result with GHCi 6.8.2 and 6.8.3.
>
> ___
> 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] Fwd: Cabalized, Self-Demoing, HStringTemplate-using HAppS Tutorial

2008-06-24 Thread Thomas Hartman
... cabal install version _working_ as well...

(v0.2)

2008/6/24 Thomas Hartman <[EMAIL PROTECTED]>:
> Uy.
>
> I think I got the cabal install version as well, but I had to specify
> a mess of files manually.
>
> So I'll probably be using darcs tag for future release if there are any ;)
>
> thomas.
>
> 2008/6/24 tphyahoo <[EMAIL PROTECTED]>:
>>
>>
>>
>> -- Forwarded message --
>> From: tphyahoo <[EMAIL PROTECTED]>
>> Date: Jun 24, 7:46 pm
>> Subject: Cabalized, Self-Demoing, HStringTemplate-using HAppS Tutorial
>> To: HAppS
>>
>>
>> There are some issues with the cabalized project -- templates are
>> missing. Doh.
>>
>> Use darcs for now.
>>
>> Thomas.
>>
>> On Jun 24, 7:26 pm, tphyahoo <[EMAIL PROTECTED]> wrote:
>>
>>> Hello HAppSers!
>>
>>> I have created a self-demoing, HStringTemplate-using intro to HAppS.
>>
>>> There is a live demo at
>>
>>>http://rippledeals.com:5001
>>
>>> It is cabalized at
>>
>>>http://hackage.haskell.org/cgi-bin/hackage-scripts/package/happs-tuto...
>>
>>> and should install fine with sudo cabal install happs-tutorial.
>>
>>> There is a darcs repo at
>>
>>>http://code.haskell.org/happs-examples
>>
>>> And a google project at
>>
>>>http://code.google.com/p/happs-tutorial/
>>
>>> which currently isn't used, but who knows, maybe for the wiki or issue
>>> tracking. (I started at google hosting before migrating to darcs.)
>>
>>> I have all kinds of additional lessons planned, but under the release
>>> early/release often motto I'm letting it out in its embryonic state.
>>
>>> Enjoy!
>>
>>> 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] Fwd: Cabalized, Self-Demoing, HStringTemplate-using HAppS Tutorial

2008-06-24 Thread Thomas Hartman
Uy.

I think I got the cabal install version as well, but I had to specify
a mess of files manually.

So I'll probably be using darcs tag for future release if there are any ;)

thomas.

2008/6/24 tphyahoo <[EMAIL PROTECTED]>:
>
>
>
> -- Forwarded message --
> From: tphyahoo <[EMAIL PROTECTED]>
> Date: Jun 24, 7:46 pm
> Subject: Cabalized, Self-Demoing, HStringTemplate-using HAppS Tutorial
> To: HAppS
>
>
> There are some issues with the cabalized project -- templates are
> missing. Doh.
>
> Use darcs for now.
>
> Thomas.
>
> On Jun 24, 7:26 pm, tphyahoo <[EMAIL PROTECTED]> wrote:
>
>> Hello HAppSers!
>
>> I have created a self-demoing, HStringTemplate-using intro to HAppS.
>
>> There is a live demo at
>
>>http://rippledeals.com:5001
>
>> It is cabalized at
>
>>http://hackage.haskell.org/cgi-bin/hackage-scripts/package/happs-tuto...
>
>> and should install fine with sudo cabal install happs-tutorial.
>
>> There is a darcs repo at
>
>>http://code.haskell.org/happs-examples
>
>> And a google project at
>
>>http://code.google.com/p/happs-tutorial/
>
>> which currently isn't used, but who knows, maybe for the wiki or issue
>> tracking. (I started at google hosting before migrating to darcs.)
>
>> I have all kinds of additional lessons planned, but under the release
>> early/release often motto I'm letting it out in its embryonic state.
>
>> Enjoy!
>
>> 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


[Haskell-cafe] Fwd: Cabalized, Self-Demoing, HStringTemplate-using HAppS Tutorial

2008-06-24 Thread tphyahoo



-- Forwarded message --
From: tphyahoo <[EMAIL PROTECTED]>
Date: Jun 24, 7:46 pm
Subject: Cabalized, Self-Demoing, HStringTemplate-using HAppS Tutorial
To: HAppS


There are some issues with the cabalized project -- templates are
missing. Doh.

Use darcs for now.

Thomas.

On Jun 24, 7:26 pm, tphyahoo <[EMAIL PROTECTED]> wrote:

> Hello HAppSers!

> I have created a self-demoing, HStringTemplate-using intro to HAppS.

> There is a live demo at

>http://rippledeals.com:5001

> It is cabalized at

>http://hackage.haskell.org/cgi-bin/hackage-scripts/package/happs-tuto...

> and should install fine with sudo cabal install happs-tutorial.

> There is a darcs repo at

>http://code.haskell.org/happs-examples

> And a google project at

>http://code.google.com/p/happs-tutorial/

> which currently isn't used, but who knows, maybe for the wiki or issue
> tracking. (I started at google hosting before migrating to darcs.)

> I have all kinds of additional lessons planned, but under the release
> early/release often motto I'm letting it out in its embryonic state.

> Enjoy!

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


[Haskell-cafe] Fwd: Cabalized, Self-Demoing, HStringTemplate-using HAppS Tutorial

2008-06-24 Thread tphyahoo
-- Forwarded message --
From: tphyahoo <[EMAIL PROTECTED]>
Date: Jun 24, 7:26 pm
Subject: Cabalized, Self-Demoing, HStringTemplate-using HAppS Tutorial
To: HAppS


Hello HAppSers!

I have created a self-demoing, HStringTemplate-using intro to HAppS.

There is a live demo at

http://rippledeals.com:5001

It is cabalized at

http://hackage.haskell.org/cgi-bin/hackage-scripts/package/happs-tuto...

and should install fine with sudo cabal install happs-tutorial.

There is a darcs repo at

http://code.haskell.org/happs-examples

And a google project at

http://code.google.com/p/happs-tutorial/

which currently isn't used, but who knows, maybe for the wiki or issue
tracking. (I started at google hosting before migrating to darcs.)

I have all kinds of additional lessons planned, but under the release
early/release often motto I'm letting it out in its embryonic state.

Enjoy!

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


[Haskell-cafe] Why the exception?

2008-06-24 Thread Thomas M. DuBuisson
Cafe
I'm a bit lost on this exception and curious about what's going on.  Is
there a valid reason for this exception that I am missing?  Note the
hard-coded [0..100] could be any Word8 list you want (generated via
arbitrary, [], or other) and it gives the same result.

Load the module and perform:
  :break prop_LPS
  quickCheck prop_LPS
  :step
  :force ps
 *** Exception: Prelude.head: empty list

> import qualified Data.ByteString as L
> import Test.QuickCheck
>
> instance Arbitrary L.ByteString where
> arbitrary = do
> return $ L.pack [0..100]
>
> prop_LPS :: L.ByteString -> Bool
> prop_LPS ps = ps `seq` True

P.S. Same result with GHCi 6.8.2 and 6.8.3.

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


[Haskell-cafe] Re: Bug in Emacs Haskell Mode

2008-06-24 Thread Stefan Monnier
> Emacs Haskell Mode has the following useful feature: when "Haskell ->
> Load File" is used to load a file into GHCi from Emacs, Haskell Mode
> automatically looks for a "*.cabal" file in an attempt to find the
> project directory.

I'm truly sorry about the fact that I only release new versions
rather rarely.  I recommend you use the CVS version, where this bug was
fixed a few months ago.


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


[Haskell-cafe] Re: Haskell on ARM (was Re: ANN: Topkata)

2008-06-24 Thread Braden Shepherdson

Jeremy Shaw wrote:

If any does attempt to build for the ARM, please, please, please,
document what you do in the wiki. And, if you do, edit the wiki as you
go, you definitely won't be able to remember what you did after the
fact. (Or, at the very least, use some program to capture everything
you do so that you can refer to it later).

And, finally, I heard vague rumors a while ago that made me think that
GHC 6.10 might have a pure ANSI-C backend? Is there any truth to this?
That would make porting much easier if it meant you did not have to do
steps 1-4.

j.  


ps. I would be happy to try to answer any questions if someone tries a
port. I would still like to run GHC on my 770, and I hope to own an
iPhone if they fix a few ommisions (bluetooth keyboard support, and
similar stuff).




I recently acquired the ARM-based Nokia N810 (and <3 it), powered by 
Maemo. Running a uname -a on it:


Linux Nokia-N810-42-19 2.6.21-omap1 #2 Fri Nov 16 16:24:58 EET 2007 
armv6l unknown


I would love a working GHC implementation on it, if for nothing else 
than how awesome it would be. Whether that means using a C back-end or 
native compilation doesn't matter to me so much.


I might be one to attempt this, as I know C and ARM-ish asm decently 
well and have a powerful desktop to compile on. I have no familiarity
with GHC internals, though. Lastly, I won't have anything like the time 
to attempt this seriously until mid-September or so.



Braden Shepherdson
shepheb

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


Re: [Haskell-cafe] sdl-mixer loading issue

2008-06-24 Thread Norbert Wojtowicz
> Attached is a patched version of SDL_mixer 0.5.2 with a C wrapper
> for this macro. I'm now able to run loadWAV in ghci.

Works for me, thanks!

Now I just need to learn how to make my WAVs sound not like
computer-generated children voices. For example, using the hback wav
files and this:

import Control.Concurrent (threadDelay)
import Graphics.UI.SDL.Mixer.General
import Graphics.UI.SDL.Mixer.Music

main = do
 openAudio 22050 AudioS16Sys 2 4096
 w <- loadMUS "c.wav"
 playMusic w 1
 threadDelay 200
 freeMusic w
 closeAudio

It plays (which is an immense improvement), but I can't get it to
sound the way it does from eg. mplayer. I have almost no knowledge of
the inner workings of computer sound drivers, so if there is something
obvious I'm missing please do speak up.

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


Re: [Haskell-cafe] sdl-mixer loading issue

2008-06-24 Thread Don Stewart
wojtowicz.norbert:
> >> SDL-mixer does not support the most recent SDL version.  The problem is
> >> that in SDL now Mix_LoadWAV is a macro.
> 
> I've tried it with SDL-0.5.2 from hackage as well with the same
> problem. (Unless you mean an earlier version of the actual SDL
> library?)
> 
> > Ah ha, so it needs a cbits wrapper over the macro.
> 
> This is above my head. If we know what the problem is, will this by
> any chance hit someone's todo list soon or is this a big hurdle?
> 
> Are there any other cross-platform (windows + linux at the minimum)
> ways of playing sounds that anyone can recommend?

Attached is a patched version of SDL_mixer 0.5.2 with a C wrapper
for this macro. I'm now able to run loadWAV in ghci.

We need to have the maintainer upload the amended version to Hackage,
or to give me leave to do so.

-- Don


SDL-mixer-0.5.2.1.tar.gz
Description: GNU Zip compressed data
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] sdl-mixer loading issue

2008-06-24 Thread Norbert Wojtowicz
>> SDL-mixer does not support the most recent SDL version.  The problem is
>> that in SDL now Mix_LoadWAV is a macro.

I've tried it with SDL-0.5.2 from hackage as well with the same
problem. (Unless you mean an earlier version of the actual SDL
library?)

> Ah ha, so it needs a cbits wrapper over the macro.

This is above my head. If we know what the problem is, will this by
any chance hit someone's todo list soon or is this a big hurdle?

Are there any other cross-platform (windows + linux at the minimum)
ways of playing sounds that anyone can recommend?

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


Re: [Haskell-cafe] Access to Oracle database from Haskell

2008-06-24 Thread Daniil Elovkov

Henning Thielemann wrote:


On Sat, 21 Jun 2008, Lanny Ripple wrote:


I had luck with this the other day using Database.HDBC.ODBC.  For
Ubuntu's Hardy I found that Oracle's 10.2.0.3 worked best.
(10.2.0.4 and 11 seemed to have problems for me at least.)

http://www.oracle.com/technology/software/tech/oci/instantclient/htdocs/linuxsoft.html 



Grab the basic (not basic-lite), odbc, and sqlplus (to test) zips.
The odbc_update_ini.sh should be run from inside the
instantclient_10_2 directory as root

 sudo /bin/sh odbc_update_ini.sh /

(assuming a standard unixODBC install.)  You'll also need a
tnsnames.ora file to describe your connection(s) to the DB(s).
You'll also need to define some environment variables to run against
all this.  I use a small script:

 #!/bin/sh
 oracle_home=/opt/lib/oracle/instantclient_10_2
 export TNS_ADMIN=$oracle_home
 export LD_LIBRARY_PATH=$oracle_home
 [ $# = 0 ] && exit 1
 exec "$@"


Thank you for the detailed hints! However, I tried a lot of this and 
that, but without a possibility to track down what went wrong, the ways 
to fix the probable problems are unbounded. Finally I get 'Driver's 
SQLAllocHandle on SQL_HANDLE_HENV failed' when I start 'isql' and that's 
where systematic error analysis stops and wild guessing starts. Since 
OCI and sqlplus work on my machine, I'll try to follow this way.


There are also

Database.HSQL
Database.HSQL.Oracle

It works through OCI as well.

It's not clear (to me at least) if it is/will be supported.
It has back-ends for multiple DBs (is Takusen only for Oracle?)
It doesn't take the typeful approach, that Takusen takes (may be a plus 
in some situations)



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


[Haskell-cafe] Bug in Emacs Haskell Mode

2008-06-24 Thread Ronald Guida
Emacs Haskell Mode has the following useful feature: when "Haskell ->
Load File" is used to load a file into GHCi from Emacs, Haskell Mode
automatically looks for a "*.cabal" file in an attempt to find the
project directory.

When Haskell Mode finds the *.cabal file, it fails to check whether it
has found a file or a folder.  As a result, if I want to load a
Haskell file that has no corresponding .cabal file, then Haskell Mode
locates my "~/.cabal" *folder* and assumes that it's my project
directory.

I have a "~/.cabal" folder because Cabal-Install puts it there.
Cabal-Install is part of Haskell's new package management system.

Now I don't know very much Emacs Lisp, but I figured out a fix for the
problem.  In Haskell-Mode-2.4, in the file haskell-cabal.el, I changed
the function "haskell-cabal-find-file" so that it explicitly checks to
make sure that any *.cabal file is in fact a file and not a folder.

I don't know if comparing the first letter of the file mode string to
'd' is the right way to diferentiate a folder from a file, but so far
it appears to work for me, so I thought I'd share it.

(defun haskell-cabal-find-file ()
  "Return a buffer visiting the cabal file of the current directory, or nil."
  (catch 'found
(let ((user (nth 2 (file-attributes default-directory)))
  ;; Abbreviate, so as to stop when we cross ~/.
  (root (abbreviate-file-name default-directory))
  files)
  (while (and root (equal user (nth 2 (file-attributes root
(let ((files (directory-files root 'full "\\.cabal\\'")))
  (if (and files
   (not (equal 100 (aref (nth 8
   (file-attributes (car files))) 0
  (throw 'found (find-file-noselect (car files)))
(if (equal root
   (setq root (file-name-directory
   (directory-file-name root
(setq root nil
nil
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Access to Oracle database from Haskell

2008-06-24 Thread Alistair Bayley
>> 2008/6/24 Henning Thielemann <[EMAIL PROTECTED]>:
>>>
>> When you run configure, you should get output that says:
>> Using Oracle: 
>>
>> What is ?
>
> I don't get these questions.

Sorry. I was really asking (not very clearly): what is the output from
"runhaskell Setup.hs configure -foracle" ? You've answered that below.


> Ah, I must have set ORACLE_HOME for the Takusen installation ... should be
> documented. However in my case, this doesn't change the path used by
> Takusen's Setup/install.

Well, you don't actually need it set for the Takusen install (it
doesn''t use it). But $ORACLE_HOME/bin should be in your path. And it
needs to contain the executable sqlplus. Can you run sqlplus? It looks
as though you don't have it.

If sqlplus is not in my path then I get this error in the configure
step, because I have specified sqlplus as a buildtool in
Takusen.cabal:

  > setup configure -foracle
  Configuring Takusen-0.8.2...
  setup: sqlplus is required but it could not be found.

Note: sqlplus isn't really needed to build; this is just a validation
step, to check you have $ORACLE_HOME/bin in your path.


> $ echo $ORACLE_HOME
> /usr/lib/oracle/10.2.0.4/client
> $ ls $ORACLE_HOME
> bin  lib
> $ ll $ORACLE_HOME/lib
> ...
> I assume that libociei.so is the library I need.

Actually it's libclntsh.so. You need to change the oracle section in
Takusen.cabal to this:

  If flag(oracle)
Exposed-modules:
Database.Oracle.Enumerator
  , Database.Oracle.OCIConstants
  , Database.Oracle.OCIFunctions
Build-Tools: sqlplus
If os(windows)
  Extra-Libraries: oci
Else
  Extra-Libraries: clntsh

Your $ORACLE_HOME installation looks fairly normal, if somewhat
minimal. I would normally expect to see sqlplus, and maybe some other
executables, like tnsping. And a folder $ORACLE_HOME/oci/include,
which contains the OCI header files. Perhaps you could also install
the sqplus and SDK packages, as Lanny Ripple suggested, although I
suspect they may not be strictly necessary, as you can apparently
successfully compile, as evidenced below.

> $ runhaskell Setup.hs configure --user -f oracle
> Configuring Takusen-0.8.2...

Here, I would expect to see "Using Oracle: /usr/lib/oracle/10.2.0.4/client"

After setup configure you can say:
  $ runhaskell Setup.hs register --gen-pkg-config

and then take a look at the generated Takusen-0.8.2.conf. Check the
library-dirs and include-dirs fields.

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


Re: [Haskell-cafe] Two questions regarding Alex/Parsec

2008-06-24 Thread Don Stewart
nielsadb:
> Hello Haskellers,
> 
> As an experiment I'm writing a parser for MediaWiki language. I'm using
> the Alex lexer and Parsec. I have novice two questions.

Just a quick question, did you try using the pandoc markdown parser?


http://hackage.haskell.org/packages/archive/pandoc/0.46/doc/html/Text-Pandoc-Readers-Markdown.html

It'd be useful to know if that was enough for printing and generation
of wiki content. Though being GPLd, it'd also be nice to have a BSD-ish
licensed wiki parser/pretty printer.

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


[Haskell-cafe] Two questions regarding Alex/Parsec

2008-06-24 Thread Niels Aan de Brugh
Hello Haskellers,

As an experiment I'm writing a parser for MediaWiki language. I'm using
the Alex lexer and Parsec. I have novice two questions.

(I've tried using Happy but I was unable to get a grammar file to
compile, which must be because I have no real experience using Yacc and
the like. I've also attempted to write an ad-hoc recursive descent
parser, but that become too complex to be fun very quickly.)

== SourcePos and AlexPosn ==

My first question is about Parsec's SourcePos. I have a definition like:

  type LexToken = (AlexPosn, Token)

  type MWP a = GenParser LexToken () a

  toSourcePos :: AlexPosn -> SourcePos
  toSourcePos (AlexPn _ line col) = undefined

  mwtok :: (Token -> Maybe a) -> MWP a
  mwtok test = token showToken posToken posTest
 where
   showToken = show . snd
   posToken = toSourcePos . fst
   posTest = test . snd

The definition of toSourcePos isn't 100% satisfactory. The constructor
SourcePos is hidden, so I cannot simply use (SourcePos line col). Is
there a way to convert an AlexPosn value to a SourcePos?

== Data Constructors as Parameters and Tags ==

Secondly, I frequently encounter the pattern where I try to match a
token, return Just some result if it matches, and Nothing otherwise. So
I tried to fix this pattern in a nice reusable function.

  onTok0 :: Token -> a -> MWP a
  onTok0 t x = mwtok (\tok -> if tok `isTok` t then Just x else Nothing)

This seems to work, but I'd also like a definition for data constructors
taking one parameter:

  onTok1 :: (a -> Token) -> (a -> b) -> MWP b
  onTok1 t f = mwtok (\tok -> case tok of
   (t n) = Just $ f n
   _ = Nothing)

This doesn't work, the pattern match (t n) fails, which is
understandable: n is used as a parameter to t and a matched result,
which looks like a paradox. t is a function (constructor) but also a
tag. Is it possible to pass a tag as an argument? Or is there another
way to extract this pattern?

Regards,
Niels


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


Re: [Haskell-cafe] Access to Oracle database from Haskell

2008-06-24 Thread Henning Thielemann


On Sat, 21 Jun 2008, Lanny Ripple wrote:


I had luck with this the other day using Database.HDBC.ODBC.  For
Ubuntu's Hardy I found that Oracle's 10.2.0.3 worked best.
(10.2.0.4 and 11 seemed to have problems for me at least.)

http://www.oracle.com/technology/software/tech/oci/instantclient/htdocs/linuxsoft.html

Grab the basic (not basic-lite), odbc, and sqlplus (to test) zips.
The odbc_update_ini.sh should be run from inside the
instantclient_10_2 directory as root

 sudo /bin/sh odbc_update_ini.sh /

(assuming a standard unixODBC install.)  You'll also need a
tnsnames.ora file to describe your connection(s) to the DB(s).
You'll also need to define some environment variables to run against
all this.  I use a small script:

 #!/bin/sh
 oracle_home=/opt/lib/oracle/instantclient_10_2
 export TNS_ADMIN=$oracle_home
 export LD_LIBRARY_PATH=$oracle_home
 [ $# = 0 ] && exit 1
 exec "$@"


Thank you for the detailed hints! However, I tried a lot of this and that, 
but without a possibility to track down what went wrong, the ways to fix 
the probable problems are unbounded. Finally I get 'Driver's 
SQLAllocHandle on SQL_HANDLE_HENV failed' when I start 'isql' and that's 
where systematic error analysis stops and wild guessing starts. Since OCI 
and sqlplus work on my machine, I'll try to follow this way.

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


Re: [Haskell-cafe] Access to Oracle database from Haskell

2008-06-24 Thread Henning Thielemann


On Tue, 24 Jun 2008, Alistair Bayley wrote:


2008/6/24 Henning Thielemann <[EMAIL PROTECTED]>:


(Btw. Takusen should be split into
several packages for all database backends because Cabal flags must not
influence the package interface.)


I don't understand this (cabal flags must not influence package
interface). I thought that was the point of cabal flags? I wanted to
have a single package installation, and this seems like the best way.


No, if a package imports Takusen - how can it be assert that it can import 
the Oracle back-end? It can't because it can reference the Takusen package 
only by its name and a version. Flags are there to make a package appear 
consistent under different circumstances (e.g. Windows and Unix, or 
GHC-6.4 and GHC-6.8). If the back-end modules would not be exported, then 
the API would remain the same for different back-ends and that would be 
ok.



But on installation Cabal complains about missing /usr/oci directory.


When you run configure, you should get output that says:
Using Oracle: 

What is ?


I don't get these questions.


The Setup.hs assumes the entire Oracle installation is under a single
root folder ($ORACLE_HOME); is this not true on Linux?


Ah, I must have set ORACLE_HOME for the Takusen installation ... should be 
documented. However in my case, this doesn't change the path used by 
Takusen's Setup/install.



$ echo $ORACLE_HOME
/usr/lib/oracle/10.2.0.4/client
$ ls $ORACLE_HOME
bin  lib
$ ll $ORACLE_HOME/lib
-rw-r--r-- 1 root root 1525 17. Feb 09:58 glogin.sql
lrwxrwxrwx 1 root root   17 24. Jun 15:36 libclntsh.so -> libclntsh.so.10.1
-rw-r--r-- 1 root root 19076649 17. Feb 09:57 libclntsh.so.10.1
-rw-r--r-- 1 root root  5656445 17. Feb 09:57 libnnz10.so
lrwxrwxrwx 1 root root   15 24. Jun 15:36 libocci.so -> libocci.so.10.1
-rw-r--r-- 1 root root  1398244 17. Feb 09:57 libocci.so.10.1
-rw-r--r-- 1 root root 72698427 17. Feb 09:57 libociei.so
-rw-r--r-- 1 root root   120443 17. Feb 09:57 libocijdbc10.so
-rw-r--r-- 1 root root  1434263 17. Feb 09:58 libsqlplusic.so
-rw-r--r-- 1 root root  1069221 17. Feb 09:58 libsqlplus.so
-rw-r--r-- 1 root root   781311 17. Feb 09:58 libsqora.so.10.1
-rw-r--r-- 1 root root  1555682 17. Feb 09:57 ojdbc14.jar

I assume that libociei.so is the library I need.


$ runhaskell Setup.hs configure --user -f oracle
Configuring Takusen-0.8.2...
$ runhaskell Setup.hs build && runhaskell Setup.hs haddock
Preprocessing library Takusen-0.8.2...
Building Takusen-0.8.2...
/usr/bin/ar: creating dist/build/libHSTakusen-0.8.2.a
Preprocessing library Takusen-0.8.2...
Running Haddock for Takusen-0.8.2...
Preprocessing library Takusen-0.8.2...
...
Documentation created: dist/doc/html/Takusen/index.html
$ runhaskell Setup.hs install
Installing:
[...]/lib/Takusen-0.8.2/ghc-6.8.2
Registering Takusen-0.8.2...
Reading package info from "dist/installed-pkg-config" ... done.
ghc-pkg: /usr/oci doesn't exist or isn't a directory (use --force to override)




Once I will get Takusen running with OCI - how would I use it? Is there a
minimal example which connects to an Oracle database, performing a very
simple query?


There's an example in the README.txt, which I've tweaked here for Oracle:

{-# OPTIONS -fglasgow-exts #-}
{-# OPTIONS -fallow-overlapping-instances #-}
module Main where
import Database.Oracle.Enumerator
import Control.Monad.Trans (liftIO)
main = flip catchDB reportRethrow $
 withSession (connect "user" "pswd" "dbname") (do
   let iter (s::String) (_::String) = result s
   result <- doQuery (sql "select 'Hello world.' from dual") iter ""
   liftIO (putStrLn result)
   )


Thanks for the adapted example!
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] sdl-mixer loading issue

2008-06-24 Thread Don Stewart
marcot:
> Em Ter, 2008-06-24 às 14:57 -0500, Norbert Wojtowicz escreveu:
> > Prelude> import Graphics.UI.SDL.Mixer.Music
> > Prelude Graphics.UI.SDL.Mixer.Music> loadMUS "test.wav"
> > Loading package SDL-0.5.4 ... linking ... done.
> > Loading package SDL-mixer-0.5.2 ... linking ... :
> > /home/norbert/bin/lib/SDL-mixer-0.5.2/ghc-6.8.2/HSSDL-mixer-0.5.2.o:
> > unknown symbol `Mix_LoadWAV'
> > ghc-6.8.2: unable to load package `SDL-mixer-0.5.2'
> 
> Hello.
> 
> SDL-mixer does not support the most recent SDL version.  The problem is
> that in SDL now Mix_LoadWAV is a macro.

Ah ha, so it needs a cbits wrapper over the macro.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] sdl-mixer loading issue

2008-06-24 Thread Marco Túlio Gontijo e Silva
Em Ter, 2008-06-24 às 14:57 -0500, Norbert Wojtowicz escreveu:
> Prelude> import Graphics.UI.SDL.Mixer.Music
> Prelude Graphics.UI.SDL.Mixer.Music> loadMUS "test.wav"
> Loading package SDL-0.5.4 ... linking ... done.
> Loading package SDL-mixer-0.5.2 ... linking ... :
> /home/norbert/bin/lib/SDL-mixer-0.5.2/ghc-6.8.2/HSSDL-mixer-0.5.2.o:
> unknown symbol `Mix_LoadWAV'
> ghc-6.8.2: unable to load package `SDL-mixer-0.5.2'

Hello.

SDL-mixer does not support the most recent SDL version.  The problem is
that in SDL now Mix_LoadWAV is a macro.

-- 
Marco Túlio Gontijo e Silva
Página: http://marcotmarcot.googlepages.com/
Blog: http://marcotmarcot.wordpress.com/
Correio: [EMAIL PROTECTED]
XMPP: [EMAIL PROTECTED]
IRC: [EMAIL PROTECTED]
Telefone: 25151920
Celular: 98116720
Endereço:
 Rua Turfa, 639/701
 Prado 30410-370
 Belo Horizonte/MG Brasil


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


Re: [Haskell-cafe] sdl-mixer loading issue

2008-06-24 Thread Don Stewart
lemming:
> 
> On Tue, 24 Jun 2008, Norbert Wojtowicz wrote:
> 
> >Hello,
> >
> >I am trying to use the SDL-mixer bindings to play wav files. I've hit
> >a wierd error and I can't figure out how to solve it:
> >
> >Prelude> import Graphics.UI.SDL.Mixer.Music
> >Prelude Graphics.UI.SDL.Mixer.Music> loadMUS "test.wav"
> 
> Is the package installed? Otherwise you may have to give an -lSDL_mixer 
> option when starting ghci.

That's not enough, for some reason:

$ ghci -lSDL_mixer
Prelude>  import Graphics.UI.SDL.Mixer.Music
Prelude Graphics.UI.SDL.Mixer.Music> loadMUS "test.wav"
:
/home/dons/.cabal/lib/SDL-mixer-0.5.2/ghc-6.8.2/HSSDL-mixer-0.5.2.o:
unknown symbol `Mix_LoadWAV'
ghc-6.8.2: unable to load package `SDL-mixer-0.5.2'

Despite it being defined in 

$ grep Mix_LoadWAV /usr/lib/*  
Binary file /usr/lib/libSDL_mixer-1.2.so.0 matches
Binary file /usr/lib/libSDL_mixer-1.2.so.0.2.6 matches
Binary file /usr/lib/libSDL_mixer.a matches
Binary file /usr/lib/libSDL_mixer.so matches

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


Re: [Haskell-cafe] sdl-mixer loading issue

2008-06-24 Thread Don Stewart
wojtowicz.norbert:
> Hello,
> 
> I am trying to use the SDL-mixer bindings to play wav files. I've hit
> a wierd error and I can't figure out how to solve it:
> 
> Prelude> import Graphics.UI.SDL.Mixer.Music
> Prelude Graphics.UI.SDL.Mixer.Music> loadMUS "test.wav"
> Loading package SDL-0.5.4 ... linking ... done.
> Loading package SDL-mixer-0.5.2 ... linking ... :
> /home/norbert/bin/lib/SDL-mixer-0.5.2/ghc-6.8.2/HSSDL-mixer-0.5.2.o:
> unknown symbol `Mix_LoadWAV'
> ghc-6.8.2: unable to load package `SDL-mixer-0.5.2'
> 
> I've looked up the source code; Mix_LoadWAV seems to be #defined, so I
> suspect it's some kind of library path issue but I don't grok the
> whole system well enough to figure it out; maybe someone could point
> me in the right direction?
> 
> Have the issue now on Ubuntu 8.04 and previously had the same issue
> when I tested it on a FreeBSD box. I did install all of the
> "libsdl-*-dev" in the Ubuntu repo.

Ah, well spotted. I get the same issue on Arch, in ghci:

Prelude> import Graphics.UI.SDL.Mixer.Music
Prelude Graphics.UI.SDL.Mixer.Music> loadMUS
"/usr/share/hback-0.0.3/sounds/t.wav"
: /usr/lib/SDL-mixer-0.5.2/ghc-6.8.2/HSSDL-mixer-0.5.2.o:
unknown symbol `Mix_LoadWAV'
ghc-6.8.2: unable to load package `SDL-mixer-0.5.2'

Looking in the source we see:

foreign import ccall unsafe "Mix_LoadWAV"
mixLoadWAV :: CString -> IO (Ptr ChunkStruct)
 
Lemmih, any ideas? -lSDL and -lSDL_mixer seem to be there.

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


Re: [Haskell-cafe] sdl-mixer loading issue

2008-06-24 Thread Henning Thielemann


On Tue, 24 Jun 2008, Norbert Wojtowicz wrote:


Hello,

I am trying to use the SDL-mixer bindings to play wav files. I've hit
a wierd error and I can't figure out how to solve it:

Prelude> import Graphics.UI.SDL.Mixer.Music
Prelude Graphics.UI.SDL.Mixer.Music> loadMUS "test.wav"


Is the package installed? Otherwise you may have to give an -lSDL_mixer 
option when starting ghci.


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


[Haskell-cafe] sdl-mixer loading issue

2008-06-24 Thread Norbert Wojtowicz
Hello,

I am trying to use the SDL-mixer bindings to play wav files. I've hit
a wierd error and I can't figure out how to solve it:

Prelude> import Graphics.UI.SDL.Mixer.Music
Prelude Graphics.UI.SDL.Mixer.Music> loadMUS "test.wav"
Loading package SDL-0.5.4 ... linking ... done.
Loading package SDL-mixer-0.5.2 ... linking ... :
/home/norbert/bin/lib/SDL-mixer-0.5.2/ghc-6.8.2/HSSDL-mixer-0.5.2.o:
unknown symbol `Mix_LoadWAV'
ghc-6.8.2: unable to load package `SDL-mixer-0.5.2'

I've looked up the source code; Mix_LoadWAV seems to be #defined, so I
suspect it's some kind of library path issue but I don't grok the
whole system well enough to figure it out; maybe someone could point
me in the right direction?

Have the issue now on Ubuntu 8.04 and previously had the same issue
when I tested it on a FreeBSD box. I did install all of the
"libsdl-*-dev" in the Ubuntu repo.

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


Re: [Haskell-cafe] Template Haskell ListT wrinkle

2008-06-24 Thread Neil Mitchell
Hi Robert,

The derive program [http://www.cs.york.ac.uk/~ndm/derive] works
extensively with Template Haskell, and has come across loads of
instances where you get either AppT or ListT, and similarly where you
get either ListE or AppE - and I seem to remember ListP as well. I
think the same also holds for TupT/TupE/TupP My advice is to treat
them all the same, and if it matters to you, normalise them before you
start work. I think the pretty printer may print them differently, but
otherwise they are equivalent. For example derive has:

peep (AppE (AppE cons x) nil)
| cons ~= ":" && nil ~= "[]" = ListE [x]

i.e. if you have a list using cons, change it to a list using the list notation.

Thanks

Neil


On 6/24/08, Robert Greayer <[EMAIL PROTECTED]> wrote:
>
>  In messing around with TH, I noticed (what I consider
>  to be an) odd wrinkle in the handling of list types
>  within TH's syntax meta-data.  For example, given the
>  program at the end of this email, which prints out the
>  TH representation of the types 'Ints' and '[Int]',
>  where 'Ints' is just a type-alias for '[Int]', the
>  following results are generated:
>
>  Ints is: AppT (ConT GHC.Base.[]) (ConT GHC.Base.Int)
>  [Int] is: AppT ListT (ConT GHC.Base.Int)
>
>  type0, 'Ints' resolves to the application of the named
>  type constructor "GHC.Base.[]" to the named type
>  constructor "GHC.Base.Int" (which makes perfect
>  sense).  type1, '[Int]' resolves to the application of
>  the 'built-in' ListT type constructor to the named
>  type constructor "GHC.Base.Int" (which also makes
>  perfect sense).  What's odd (to me) is that in one
>  situation, the 'named' constructor 'GHC.Base.[]'
>  appears, and in the other, the 'built-in' constructor
>  appears.
>
>  Does anyone have insight into why this might be?
>  (These results were obtained with GHC 6.8.2, btw).
>
>  > {-# OPTIONS_GHC -XTemplateHaskell #-}
>  > module Main where
>  > import Language.Haskell.TH
>  >
>  > type Ints = [Int]
>  >
>  > type0 = $( reify ''Ints >>= (\ (TyConI (TySynD _ _
>  t)) -> return $ show t) >>= \s -> [| s |])
>  > type1 = $( [t| [Int] |] >>= return . show >>= \s ->
>  [| s |])
>  >
>  > main = do
>  >putStrLn ("Ints is: " ++ type0)
>  >putStrLn ("[Int] is: " ++ type1)
>
>  Thanks
>  rcg
>
>
>
>  ___
>  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] Template Haskell ListT wrinkle

2008-06-24 Thread Robert Greayer

In messing around with TH, I noticed (what I consider
to be an) odd wrinkle in the handling of list types
within TH's syntax meta-data.  For example, given the
program at the end of this email, which prints out the
TH representation of the types 'Ints' and '[Int]',
where 'Ints' is just a type-alias for '[Int]', the
following results are generated:

Ints is: AppT (ConT GHC.Base.[]) (ConT GHC.Base.Int)
[Int] is: AppT ListT (ConT GHC.Base.Int)

type0, 'Ints' resolves to the application of the named
type constructor "GHC.Base.[]" to the named type
constructor "GHC.Base.Int" (which makes perfect
sense).  type1, '[Int]' resolves to the application of
the 'built-in' ListT type constructor to the named
type constructor "GHC.Base.Int" (which also makes
perfect sense).  What's odd (to me) is that in one
situation, the 'named' constructor 'GHC.Base.[]'
appears, and in the other, the 'built-in' constructor
appears.

Does anyone have insight into why this might be? 
(These results were obtained with GHC 6.8.2, btw).

> {-# OPTIONS_GHC -XTemplateHaskell #-}
> module Main where
> import Language.Haskell.TH
>
> type Ints = [Int]
>
> type0 = $( reify ''Ints >>= (\ (TyConI (TySynD _ _
t)) -> return $ show t) >>= \s -> [| s |])
> type1 = $( [t| [Int] |] >>= return . show >>= \s ->
[| s |])
>
> main = do
>putStrLn ("Ints is: " ++ type0)
>putStrLn ("[Int] is: " ++ type1)

Thanks
rcg


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


Re: [Haskell-cafe] safe vs unsafe

2008-06-24 Thread Adam Langley
On Tue, Jun 24, 2008 at 12:08 PM, Galchin, Vasili <[EMAIL PROTECTED]> wrote:
> yes I am invoking a callback function written in Haskell.

Then you should just need to remove the "unsafe" from the foreign
import decl which leads to the callback getting called.


AGL

-- 
Adam Langley [EMAIL PROTECTED] http://www.imperialviolet.org
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] safe vs unsafe

2008-06-24 Thread Galchin, Vasili
yes I am invoking a callback function written in Haskell.



On Tue, Jun 24, 2008 at 12:03 PM, Adam Langley <[EMAIL PROTECTED]>
wrote:

> 2008/6/23 Galchin, Vasili <[EMAIL PROTECTED]>:
> > aio: schedule: re-entered unsafely.
> >Perhaps a 'foreign import unsafe' should be 'safe'?
> >
> > I want to understand from an implementation viewpoint .. deeper. This is
> a
> > GC issue yes?
>
> Are you reentering Haskell on a path which involves an unsafe FFI
> call? e.g. you enter C land via an unsafe FFI call and, on the same
> call path, reenter Haskell with a callback?
>
> http://www.cse.unsw.edu.au/~chak/haskell/ffi/ffi/ffise3.html#x6-130003.3says:
>
> "Optionally, an import declaration can specify, after the calling
> convention, the safety level that should be used when invoking an
> external entity. A safe call is less efficient, but guarantees to
> leave the Haskell system in a state that allows callbacks from the
> external code. In contrast, an unsafe call, while carrying less
> overhead, must not trigger a callback into the Haskell system. If it
> does, the system behaviour is undefined. The default for an invocation
> is to be safe. Note that a callback into the Haskell system implies
> that a garbage collection might be triggered after an external entity
> was called, but before this call returns. Consequently, objects other
> than stable pointers (cf. Section 5.6) may be moved or garbage
> collected by the storage manager."
>
> --
> Adam Langley [EMAIL PROTECTED] http://www.imperialviolet.org
>
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: Haskell on ARM (was Re: [Haskell-cafe] ANN: Topkata)

2008-06-24 Thread Jeremy Shaw
Hello,

I have, on two occasions made an *unregisterised* of GHC for the ARM
(specifically the Maemo on Nokia 770). Mostly I just followed the
unregisterised porting directions in the GHC user manual.

I documented one attempt here:

http://hackage.haskell.org/trac/ghc/wiki/ArmLinuxGhc

Note: This procedure is for building a version of GHC that runs on ARM
and generates ARM code. So, it is not build a cross-compiler, just a
native ARM compiler.

The unregisterised build is not that useful because:

 1. no FFI
 2. uses trampolining for tail calls
 3. no threads I think
 4. some other stuff I have forgotten

So, the next step is to registerise the build. This is online a few
lines a code. Basically stuff like:

 1. add ARM support to the evil mangler (basically, a few regexps to
 strip prolog and epilogue stuff from the ASM)

 2. #define which registers exist and what they should be used for

 3. implement the tail call ASM

 4. define some aspects of the C calling convention

 5. (Optional), implement native assembly generation

This is not a lot of code. However, it is very low-level code.

I think that doing a registerised build is pretty easy, the *second*
time you do it. The big problem is that there is pretty much no
documentation on how to do it. (The porting guide does tell you, very
generally, what needs to be done).

Also, running GHC on an emulated ARM processor is slow. I think it
took GHC 6.4 8+ hours to build. 

Now that many of the extra libs have been split out into the extra
libs package, that should help significantly with the build time.

If any does attempt to build for the ARM, please, please, please,
document what you do in the wiki. And, if you do, edit the wiki as you
go, you definitely won't be able to remember what you did after the
fact. (Or, at the very least, use some program to capture everything
you do so that you can refer to it later).

And, finally, I heard vague rumors a while ago that made me think that
GHC 6.10 might have a pure ANSI-C backend? Is there any truth to this?
That would make porting much easier if it meant you did not have to do
steps 1-4.

j.  

ps. I would be happy to try to answer any questions if someone tries a
port. I would still like to run GHC on my 770, and I hope to own an
iPhone if they fix a few ommisions (bluetooth keyboard support, and
similar stuff).

At Tue, 17 Jun 2008 13:12:33 -0700,
Don Stewart wrote:
> 
> xj2106:
> > "Ariel J. Birnbaum" <[EMAIL PROTECTED]> writes:
> > 
> > >> In the mean time -- who knows enough to make ghc target
> > >> ARM, and get this to link against the iPhone libraries?
> > >> This would be quite a coup if it could be made to run
> > >> there!
> > > For that matter, there's another ARM-based target in which
> > > I'm interested: Nintendo DS. Has anyone got any Haskell
> > > code to run on one of these?  PS: Maybe this discussion
> > > should be moved to a new "Haskell on ARM" thread?
> > 
> > I would be interested to see ghc running on Nokia n8xx or
> > iRex iliad.  Both of them are quite open linux based
> > systems.
> 
> Jeremy Shaw had ghc targeting the nokia last year, iirc.
> Perhaps he'll have more info.
> 
> -- Don
> ___
> 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] NW Functional Programming Interest Group

2008-06-24 Thread Greg Meredith
All,

Apologies for multiple listings.

A small cadre of us, collectively known as the Northwest Functional
Programming
Interest Group, have been meeting monthly to discuss all things functional.
Our next meeting is at

The Seattle Public Library
5009 Roosevelt Way N.E. *
Seattle*, WA 98105
206-684-4063

from 18:30 - 19:50 on June 25th.

We'd hoped to have Andrew Birkett talk on a Haskell implementation of an
emacs-like editor, but sadly could not secure a meeting venue before
Andrew's flight back to the UK. Maybe we can set up a skype session for a
presentation by Andrew in future. Since it's so late in the game i will step
in and offer a presentation on a compositional representation of graphs i've
been tinkering 
with
-- unless someone has something they'd like to talk about at a moment's
notice.

Hope to see you there.

Monadically yours,

--greg

-- 
L.G. Meredith
Managing Partner
Biosimilarity LLC
806 55th St NE
Seattle, WA 98105

+1 206.650.3740

http://biosimilarity.blogspot.com

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


Re: [Haskell-cafe] safe vs unsafe

2008-06-24 Thread Adam Langley
2008/6/23 Galchin, Vasili <[EMAIL PROTECTED]>:
> aio: schedule: re-entered unsafely.
>Perhaps a 'foreign import unsafe' should be 'safe'?
>
> I want to understand from an implementation viewpoint .. deeper. This is a
> GC issue yes?

Are you reentering Haskell on a path which involves an unsafe FFI
call? e.g. you enter C land via an unsafe FFI call and, on the same
call path, reenter Haskell with a callback?

http://www.cse.unsw.edu.au/~chak/haskell/ffi/ffi/ffise3.html#x6-130003.3 says:

"Optionally, an import declaration can specify, after the calling
convention, the safety level that should be used when invoking an
external entity. A safe call is less efficient, but guarantees to
leave the Haskell system in a state that allows callbacks from the
external code. In contrast, an unsafe call, while carrying less
overhead, must not trigger a callback into the Haskell system. If it
does, the system behaviour is undefined. The default for an invocation
is to be safe. Note that a callback into the Haskell system implies
that a garbage collection might be triggered after an external entity
was called, but before this call returns. Consequently, objects other
than stable pointers (cf. Section 5.6) may be moved or garbage
collected by the storage manager."

-- 
Adam Langley [EMAIL PROTECTED] http://www.imperialviolet.org
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Access to Oracle database from Haskell

2008-06-24 Thread Alistair Bayley
2008/6/24 Henning Thielemann <[EMAIL PROTECTED]>:
>
> (I remain on the list in order to fill the archive with information, others
> may need, too.)

As you wish.


> (Btw. Takusen should be split into
> several packages for all database backends because Cabal flags must not
> influence the package interface.)

I don't understand this (cabal flags must not influence package
interface). I thought that was the point of cabal flags? I wanted to
have a single package installation, and this seems like the best way.


> But on installation Cabal complains about missing /usr/oci directory.

When you run configure, you should get output that says:
Using Oracle: 

What is ?

The Setup.hs assumes the entire Oracle installation is under a single
root folder ($ORACLE_HOME); is this not true on Linux? If not, then we
will have to find some other way of locating the bin and include
folders. Perhaps we can do something like the Postgres installation,
where there is a program you can run which will print the include and
lib folders. That may mean a little hacking on Setup.hs, but there's
already a good example there for Postgres.


> Once I will get Takusen running with OCI - how would I use it? Is there a
> minimal example which connects to an Oracle database, performing a very
> simple query?

There's an example in the README.txt, which I've tweaked here for Oracle:

{-# OPTIONS -fglasgow-exts #-}
{-# OPTIONS -fallow-overlapping-instances #-}
module Main where
import Database.Oracle.Enumerator
import Control.Monad.Trans (liftIO)
main = flip catchDB reportRethrow $
  withSession (connect "user" "pswd" "dbname") (do
let iter (s::String) (_::String) = result s
result <- doQuery (sql "select 'Hello world.' from dual") iter ""
liftIO (putStrLn result)
)

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


Re: [Haskell-cafe] Access to Oracle database from Haskell

2008-06-24 Thread Henning Thielemann


On Fri, 20 Jun 2008, Alistair Bayley wrote:


Another problem is that the Oracle installation process assumes that,
for all platforms, the library is called oci i.e. the linker option
-loci is used. For Unix clients, the OCI library seems to be
libclnstsh.so, so I guess it should pass -lclnstsh. This highlights
the lack of testing on non-Windows platforms. If you'd like to help
get this working better, perhaps we can discuss off-list.


(I remain on the list in order to fill the archive with information, 
others may need, too.)


I have now installed the OCI SDK
  
http://download.oracle.com/otn/linux/instantclient/10204/oracle-instantclient-devel-10.2.0.4-1.i386.rpm
 and Cabal-1.4 in order to get Takusen from Darcs repository running. I 
configure the package with -f oracle and the package gets compiled (and 
emits several warnings from Haddock-2.0). (Btw. Takusen should be split 
into several packages for all database backends because Cabal flags must 
not influence the package interface.) But on installation Cabal complains 
about missing /usr/oci directory. I assume that this must be the include 
dir of OCI include files. For me this is

  /usr/include/oracle/10.2.0.4/client/
 I can add this path with
runhaskell Setup.hs configure 
--extra-include-dirs=/usr/include/oracle/10.2.0.4/client
 but I cannot replace /usr/oci. If I remove /usr/oci manually from 
dist/installed-pkg-config then the path /usr/oci is again added by

runhaskell Setup.hs install .
 I'm lost. Am I on the right track?

Once I will get Takusen running with OCI - how would I use it? Is there a 
minimal example which connects to an Oracle database, performing a very 
simple query?

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