[Haskell-cafe] how to #include files within parsec ... without unsafePerformIO?

2009-06-19 Thread Leonard Siebeneicher
Hi Neil, Hi Daniel.

Thank you for your help, using parsec 3.0.0 and liftIO was the solution.

After installing new parsec I have had to use
import Text.Parsec
... instead of ...
import Text.ParserCombinators.Parsec
... to get it work.
It seems Text.ParserCombinators.Parsec refers to old Parsec 2

Have a nice week--end,
Leonard


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


Re: [Haskell-cafe] Creating a new Haskell mailing list

2009-06-19 Thread Wolfgang Jeltsch
Am Donnerstag, 18. Juni 2009 16:21 schrieb Henning Thielemann:
 Ryan Trinkle schrieb:
  Hi all,
 
  I'm interested in starting a mailing list on haskell.org
  http://haskell.org.  Who should I talk to about such things?

 Is it a mailing list related to a project? Then you may request a
 project on community.haskell.org, then you can start a mailing list at
 yourproj...@project.haskell.org

See http://community.haskell.org/.

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


Re: [Haskell-cafe] Use MySQL from Haskell

2009-06-19 Thread david48
 Marciej,

 I went the HDBC route and got the same problem. Although it does not seem to
 be officially blessed, try installing the time-1.1.3 package. It's working
 for me at least, which I know is a dubious recommendation.What worked for me :

1) Install GHC 6.10.3 from the binary tarball
2) Intall the haskell platform. ( not without problems, sadly )
3) cabal install HDBC-mysql

voilà.

That worked both on Kubuntu 9.04 and on Centos 5.3

On kubuntu it was a pain in the  to figure out which files were
needed for opengl. I had to make a symlink by hand. ( opengl was built
by the haskell platform )

On centos 5.3 ... libedit was the problem, but once the haskell
platform is installed, cabal install hdbc-mysql works like a charm.

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


Re: [Haskell-cafe] Use MySQL from Haskell

2009-06-19 Thread Björn Peemöller
Maciej Podgurski schrieb:
 So I switched to HDBC-2.1.1 and got the next compile error:

 Building convertible-1.0.5...

 Data/Convertible/Instances/Num.hs:671:0:
 warning: no newline at end of file
 [...]
 [5 of 8] Compiling Data.Convertible.Instances.C (
 Data/Convertible/Instances/C.hs, dist\build/Data/C
 onvertible/Instances/C.o )
 [6 of 8] Compiling Data.Convertible.Instances.Time (
 Data/Convertible/Instances/Time.hs, dist\build/
 Data/Convertible/Instances/Time.o )

 Data/Convertible/Instances/Time.hs:64:0:
Duplicate instance declarations:
  instance Typeable NominalDiffTime
-- Defined at Data/Convertible/Instances/Time.hs:(64,0)-(65,42)
  instance Typeable NominalDiffTime
-- Defined in time-1.1.3:Data.Time.Clock.UTC

 Data/Convertible/Instances/Time.hs:67:0:
Duplicate instance declarations:
  instance Typeable UTCTime
-- Defined at Data/Convertible/Instances/Time.hs:(67,0)-(68,34)
  instance Typeable UTCTime
-- Defined in time-1.1.3:Data.Time.Clock.UTC 

Hi Maciej,

this is quite easy to fix (although a little bit dirty). The problem is
that time-1.1.3 now defines some Typeable instances which time-1.1.2.4
did not and which are therefore defined in convertible, too. I don't
know a general fix to the problem, but you can either

- download the convertible package and comment out the two instance
declarations as shown in the error message and then cabal install it
- install from Hackage with additional constraint: cabal install
convertible --constraint=time1.1.3

I hope this will help you get HDBC running.

Cheers,
Björn




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


Re: [Haskell-cafe] Runtime strictness analysis for polymorphic HOFs?

2009-06-19 Thread Edward Kmett
Hi Max,
I don't have anything in a public repository at this time. I have been
exploring a series of designs in this space trying to see if any could be
applied to a system like GHC's bytecode interpreter, but up to now I've been
working mostly with cooperatively jitting x86-64 assembly to x86-64 assembly
for a possibly commercial project. I have only recently started trying to
adapt my research to a more functional setting. If you hop on #haskell some
time, I'd be happy to talk further.

-Edward Kmett


On Thu, Jun 18, 2009 at 12:30 PM, Max Bolingbroke 
batterseapo...@hotmail.com wrote:

 2009/6/18 Edward Kmett ekm...@gmail.com:
  What is interesting is in a lazy setting, if you are tracing a bytecode
  representation that knows about allocation and thunks, you can do some
  additional optimizations in here. If on every path to a side exit or the
 end
  of the loop you find that the thunk is evaluated you can evaluate it
  strictly and move its execution earlier in the trace. This gives you a
 weak
  form of runtime strictness analysis. If the pointer to that thunk never
  escapes, then you can unbox the contents of the thunk and operate on its
  members in registers. Add constant folding, polyinline caching to improve
  branch prediction for spineless tagless g-machine thunk evaluation, and
 code
  migration to the side exits and it becomes an interesting runtime system.

 This sounds absolutely awesome! Is the source code for your prototype
 publicly available anywhere? I'd love to take a look at the basic
 structure of something like this - trace JITing is something I keep
 meaning to look at in more depth.

 Cheers,
 Max

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


[Haskell-cafe] FFI question

2009-06-19 Thread Vasili I. Galchin
Hello,

   I would like to write bindings from Haskell to Java. Is this
possible? If so, where are examples?

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


[Haskell-cafe] Re: Could someone give me a sample about haskelldb?

2009-06-19 Thread Magicloud Magiclouds
I changed it, some other problem occured.
1. How to compare a BoolT column to a True? t!c .. True could not work.
2. What shoud I use after !? Like table!col, recordset!col, what is col?
Thanks.

On Fri, Jun 19, 2009 at 1:24 PM, Magicloud
Magicloudsmagicloud.magiclo...@gmail.com wrote:
 Hi,
  I am learning it following the very few documents on its site. Well,
 I failed, with the import modules, I still cannot compile it. The
 error is on T.*.

  6 import Database.HaskellDB.HDBC.SQLite3
  7 import Database.HaskellDB
  8 import Database.HaskellDB.DBSpec
  9 import Database.HaskellDB.DBSpec.PPHelpers
 10 import Database.HaskellDB.Query

 48     q = do
 49       t - table $ Table notes []
 50       restrict ( t!T.done .. False )
 51       r - project ( T.subject  t!T.subject )
 52       order [ desc r T.priority
 53             , desc r T.dt ]
 54       return r
 --
 竹密岂妨流水过
 山高哪阻野云飞




-- 
竹密岂妨流水过
山高哪阻野云飞
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: Running a sub-process which dies with the main program

2009-06-19 Thread Deniz Dogan
2009/6/18 Deniz Dogan deniz.a.m.do...@gmail.com:
 Hi

 I couldn't come up with a better subject than this one, so anyways...

 I have a small program which spawns a subprocess. However, when I hit
 C-c, the subprocess won't die, instead it will just keep running until
 it's done or until I kill it. I've looked around in System.Process for
 something suitable for my needs, but I can't seem to find it. Any
 ideas?

With a tip from a person outside of the mailing list I found
System.Process.system, which essentially does exactly what I was
asking for. However, I would really like some more control over what
file descriptors the subprocess should use (specifically stdout and
stderr). Looking at the source code for System.Process.system, I find
that it uses the syncProcess function, which would be useful to me,
but isn't exported.

So why is syncProcess not exported? Is there any good reason not to?

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


Re: [Haskell-cafe] Re: Running a sub-process which dies with the main program

2009-06-19 Thread Aycan iRiCAN

Cum, 2009-06-19 tarihinde 11:58 +0200 saatinde, Deniz Dogan yazdı:
 2009/6/18 Deniz Dogan deniz.a.m.do...@gmail.com:
  Hi
 
  I couldn't come up with a better subject than this one, so anyways...
 
  I have a small program which spawns a subprocess. However, when I hit
  C-c, the subprocess won't die, instead it will just keep running until
  it's done or until I kill it. I've looked around in System.Process for
  something suitable for my needs, but I can't seem to find it. Any
  ideas?
 
 With a tip from a person outside of the mailing list I found
 System.Process.system, which essentially does exactly what I was
 asking for.

Hey I'm already subscribed :) You can read from sout and serr with
below example. Hope that it helps.


module Main where

import System.Process  -- using process-1.0.1.1

main = do
  (_, sout, serr, p) - createProcess (proc sleep [10])
{ std_out = CreatePipe
, std_err = CreatePipe }
  r - waitForProcess p
  return ()


Regards,
--
aycan

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


Re: [Haskell-cafe] Re: Running a sub-process which dies with the main program

2009-06-19 Thread Deniz Dogan
2009/6/19 Aycan iRiCAN aycan.iri...@core.gen.tr:

 Cum, 2009-06-19 tarihinde 11:58 +0200 saatinde, Deniz Dogan yazdı:
 2009/6/18 Deniz Dogan deniz.a.m.do...@gmail.com:
  Hi
 
  I couldn't come up with a better subject than this one, so anyways...
 
  I have a small program which spawns a subprocess. However, when I hit
  C-c, the subprocess won't die, instead it will just keep running until
  it's done or until I kill it. I've looked around in System.Process for
  something suitable for my needs, but I can't seem to find it. Any
  ideas?

 With a tip from a person outside of the mailing list I found
 System.Process.system, which essentially does exactly what I was
 asking for.

 Hey I'm already subscribed :) You can read from sout and serr with
 below example. Hope that it helps.


 module Main where

 import System.Process  -- using process-1.0.1.1

 main = do
  (_, sout, serr, p) - createProcess (proc sleep [10])
                        { std_out = CreatePipe
                        , std_err = CreatePipe }
  r - waitForProcess p
  return ()


Thanks!

But this was the approach I used before I went to
System.Process.system and it did not work on my Linux machine. Looking
at the source code for system, we see that it uses syncProcess,
which has #ifdef mingw32_HOST_OS (IIRC) in which the code you gave me
resides. If mingw32_HOST_OS is not defined, one has to go through
quite a bit more trouble to get the same effect.

This is why it bugs me a bit that syncProcess is not exported. I can't
find any reason not to export it, but what do I know?

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


Re: [Haskell-cafe] Re: Running a sub-process which dies with the main program

2009-06-19 Thread Aycan iRiCAN

Cum, 2009-06-19 tarihinde 12:42 +0200 saatinde, Deniz Dogan yazdı:
 2009/6/19 Aycan iRiCAN aycan.iri...@core.gen.tr:
 
  Cum, 2009-06-19 tarihinde 11:58 +0200 saatinde, Deniz Dogan yazdı:
  2009/6/18 Deniz Dogan deniz.a.m.do...@gmail.com:
   Hi
  
   I couldn't come up with a better subject than this one, so anyways...
  
   I have a small program which spawns a subprocess. However, when I hit
   C-c, the subprocess won't die, instead it will just keep running until
   it's done or until I kill it. I've looked around in System.Process for
   something suitable for my needs, but I can't seem to find it. Any
   ideas?
 
  With a tip from a person outside of the mailing list I found
  System.Process.system, which essentially does exactly what I was
  asking for.
 
  Hey I'm already subscribed :) You can read from sout and serr with
  below example. Hope that it helps.
 
 
  module Main where
 
  import System.Process  -- using process-1.0.1.1
 
  main = do
   (_, sout, serr, p) - createProcess (proc sleep [10])
 { std_out = CreatePipe
 , std_err = CreatePipe }
   r - waitForProcess p
   return ()
 
 
 Thanks!
 
 But this was the approach I used before I went to
 System.Process.system and it did not work on my Linux machine.

Give it a try. Try to send CTRL-C and look if sleep 10 (which is a
subprocess) process terminates.

ay...@aycan:~/haskell$ time ./deniz2  ps -ef | grep sleep
^C
real0m0.707s
user0m0.001s
sys 0m0.004s
   aycan 13098  4430   0 13:50:23 pts/7   0:00 grep sleep

It terminates with ghc 6.10.3 on OpenSolaris.

Best Regards,
--
aycan

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


Re: [Haskell-cafe] Re: Running a sub-process which dies with the main program

2009-06-19 Thread Deniz Dogan
2009/6/19 Aycan iRiCAN aycan.iri...@core.gen.tr:

 Cum, 2009-06-19 tarihinde 12:42 +0200 saatinde, Deniz Dogan yazdı:
 2009/6/19 Aycan iRiCAN aycan.iri...@core.gen.tr:
 
  Cum, 2009-06-19 tarihinde 11:58 +0200 saatinde, Deniz Dogan yazdı:
  2009/6/18 Deniz Dogan deniz.a.m.do...@gmail.com:
   Hi
  
   I couldn't come up with a better subject than this one, so anyways...
  
   I have a small program which spawns a subprocess. However, when I hit
   C-c, the subprocess won't die, instead it will just keep running until
   it's done or until I kill it. I've looked around in System.Process for
   something suitable for my needs, but I can't seem to find it. Any
   ideas?
 
  With a tip from a person outside of the mailing list I found
  System.Process.system, which essentially does exactly what I was
  asking for.
 
  Hey I'm already subscribed :) You can read from sout and serr with
  below example. Hope that it helps.
 
 
  module Main where
 
  import System.Process  -- using process-1.0.1.1
 
  main = do
   (_, sout, serr, p) - createProcess (proc sleep [10])
                         { std_out = CreatePipe
                         , std_err = CreatePipe }
   r - waitForProcess p
   return ()
 

 Thanks!

 But this was the approach I used before I went to
 System.Process.system and it did not work on my Linux machine.

 Give it a try. Try to send CTRL-C and look if sleep 10 (which is a
 subprocess) process terminates.

 ay...@aycan:~/haskell$ time ./deniz2  ps -ef | grep sleep
 ^C
 real    0m0.707s
 user    0m0.001s
 sys     0m0.004s
   aycan 13098  4430   0 13:50:23 pts/7       0:00 grep sleep

 It terminates with ghc 6.10.3 on OpenSolaris.

This is copied verbatim from my terminal. I used the exact some code
that you gave me.

% time ./test  ps -ef | grep sleep
^C
real0m10.005s
user0m0.003s
sys 0m0.003s
deniz14095 14047  0 13:05 pts/100:00:00 grep sleep

What's strange though is that when I hit C-c *twice*, I get this behavior:

time ./test  ps -ef | grep sleep
^C^C

real0m0.915s
user0m0.003s
sys 0m0.000s

This is with GHC 6.10.3 on Arch Linux i686.

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


[Haskell-cafe] Re: Could someone give me a sample about haskelldb?

2009-06-19 Thread GüŸnther Schmidt

Hi Magicloud,


restrict (t!T.done .. constant False) should dot it

but your t!T.done confuses me, is the the T.xxx due to an import?
also the line 49 does not seem to be right. Would you mind to post your 
table and column definitions?



Günther


Magicloud Magiclouds schrieb:

I changed it, some other problem occured.
1. How to compare a BoolT column to a True? t!c .. True could not work.
2. What shoud I use after !? Like table!col, recordset!col, what is col?
Thanks.

On Fri, Jun 19, 2009 at 1:24 PM, Magicloud
Magicloudsmagicloud.magiclo...@gmail.com wrote:

Hi,
 I am learning it following the very few documents on its site. Well,
I failed, with the import modules, I still cannot compile it. The
error is on T.*.

 6 import Database.HaskellDB.HDBC.SQLite3
 7 import Database.HaskellDB
 8 import Database.HaskellDB.DBSpec
 9 import Database.HaskellDB.DBSpec.PPHelpers
10 import Database.HaskellDB.Query

48 q = do
49   t - table $ Table notes []
50   restrict ( t!T.done .. False )
51   r - project ( T.subject  t!T.subject )
52   order [ desc r T.priority
53 , desc r T.dt ]
54   return r
--
竹密岂妨流水过
山高哪阻野云飞








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


Re: [Haskell-cafe] Use MySQL from Haskell

2009-06-19 Thread Daniel van den Eijkel
The same with me - I'm on XP, and HDBC-odbc is the library I got running 
to access the MySQL database.

Regards,
Daniel


Michael Snoyman schrieb:

Marciej,

I went the HDBC route and got the same problem. Although it does not 
seem to be officially blessed, try installing the time-1.1.3 package. 
It's working for me at least, which I know is a dubious recommendation.


Also, I am currently using the hdbc-odbc package for accessing MySQL. 
I couldn't get hdbc-mysql to work properly. I hope that once I get 
this project working right, I'll have a chance to dig into the 
hdbc-mysql issue itself.


Good luck!

Michael

On Fri, Jun 19, 2009 at 12:26 AM, Maciej Podgurski 
maciej.podgur...@googlemail.com 
mailto:maciej.podgur...@googlemail.com wrote:


Hello,

I'm trying to use MySQL from Haskell but it seems impossible for
me to install one of the MySQL packages on my Windows XP machine.

First I tired to install hsql-mysql-1.7.1 on GHC 6.10.3 but
installing haskelldb-hsql failed with a hidden package error. So I
added the old-time package to the cabal file but there still was a
compile error (something due to the change from Exception to
Exception e = e).

So I switched to GHC 6.8.3 and tried it again. Now it says:

Configuring hsql-mysql-1.7.1...
Warning: 'extra-lib-dirs: /usr/lib/mysql' directory does not exist.
Warning: 'include-dirs: /usr/include/mysql' directory does not exist.
Warning: This package indirectly depends on multiple versions of
the same
package. This is highly likely to cause a compile failure.
package process-1.0.0.1 requires filepath-1.1.0.0
package directory-1.0.0.1 requires filepath-1.1.0.0
package Cabal-1.6.0.3 requires filepath-1.1.0.2
Setup: Missing dependency on a foreign library:
* Missing C library: mysqlclient
This problem can usually be solved by installing the system
package that
provides this library (you may need the -dev version). If the
library is
already installed but in a non-standard location then you can use
the flags
--extra-include-dirs= and --extra-lib-dirs= to specify where it is.

There's no Haskell package mysqlclient and I don't know how to
install a C library in Haskell. So I switched to HDBC-2.1.1 and
got the next compile error:

Building convertible-1.0.5...

Data/Convertible/Instances/Num.hs:671:0:
   warning: no newline at end of file
[...]
[5 of 8] Compiling Data.Convertible.Instances.C (
Data/Convertible/Instances/C.hs, dist\build/Data/C
onvertible/Instances/C.o )
[6 of 8] Compiling Data.Convertible.Instances.Time (
Data/Convertible/Instances/Time.hs, dist\build/
Data/Convertible/Instances/Time.o )

Data/Convertible/Instances/Time.hs:64:0:
  Duplicate instance declarations:
instance Typeable NominalDiffTime
  -- Defined at Data/Convertible/Instances/Time.hs:(64,0)-(65,42)
instance Typeable NominalDiffTime
  -- Defined in time-1.1.3:Data.Time.Clock.UTC

Data/Convertible/Instances/Time.hs:67:0:
  Duplicate instance declarations:
instance Typeable UTCTime
  -- Defined at Data/Convertible/Instances/Time.hs:(67,0)-(68,34)
instance Typeable UTCTime
  -- Defined in time-1.1.3:Data.Time.Clock.UTC

So please help me, what GHC/package configuration will I need to
use MySQL from my Haskell programs on Windows? I really like
Haskell but all those broken packages are really discouraging. :(


Best wishes,
Maciej
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org mailto: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


[Haskell-cafe] Using Parsec with ByteString ?

2009-06-19 Thread Fernand

Hi,

May be it's a frequently asked question, but I have been unable to find 
my way in the parsec-3.0.0 library when trying to write a small parser 
with Parsec that could work with ByteStrings. I mean, there is the 
Text.Parsec.ByteString module which allows to parse a file using 
ByteStrings,

but the parser one needs to write must parse ByteStrings instead of Strings
(that is, something like having a Parsec Bytestring () type, unless I'm
completely misunderstanding the situation). My problem is that I do not 
manage
to write primitive parsing combinators (like string, satisfy, letter, 
etc.) to

define my language's tokens.

I'm surely missing some primitive somewhere (may be the 
Text.Parsec.Prim.token,

though I do not really manage to use it).

Thanks in advance,

F.

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


Re: [Haskell-cafe] Re: Running a sub-process which dies with the main program

2009-06-19 Thread Aycan iRiCAN

Cum, 2009-06-19 tarihinde 13:09 +0200 saatinde, Deniz Dogan yazdı:
 2009/6/19 Aycan iRiCAN aycan.iri...@core.gen.tr:
 
  Cum, 2009-06-19 tarihinde 12:42 +0200 saatinde, Deniz Dogan yazdı:
  2009/6/19 Aycan iRiCAN aycan.iri...@core.gen.tr:
  
   Cum, 2009-06-19 tarihinde 11:58 +0200 saatinde, Deniz Dogan yazdı:
   2009/6/18 Deniz Dogan deniz.a.m.do...@gmail.com:
Hi
   
I couldn't come up with a better subject than this one, so anyways...
   
I have a small program which spawns a subprocess. However, when I hit
C-c, the subprocess won't die, instead it will just keep running until
it's done or until I kill it. I've looked around in System.Process for
something suitable for my needs, but I can't seem to find it. Any
ideas?
  
   With a tip from a person outside of the mailing list I found
   System.Process.system, which essentially does exactly what I was
   asking for.
  
   Hey I'm already subscribed :) You can read from sout and serr with
   below example. Hope that it helps.
  
  
   module Main where
  
   import System.Process  -- using process-1.0.1.1
  
   main = do
(_, sout, serr, p) - createProcess (proc sleep [10])
  { std_out = CreatePipe
  , std_err = CreatePipe }
r - waitForProcess p
return ()
  
 
  Thanks!
 
  But this was the approach I used before I went to
  System.Process.system and it did not work on my Linux machine.
 
  Give it a try. Try to send CTRL-C and look if sleep 10 (which is a
  subprocess) process terminates.
 
  ay...@aycan:~/haskell$ time ./deniz2  ps -ef | grep sleep
  ^C
  real0m0.707s
  user0m0.001s
  sys 0m0.004s
aycan 13098  4430   0 13:50:23 pts/7   0:00 grep sleep
 
  It terminates with ghc 6.10.3 on OpenSolaris.
 
 This is copied verbatim from my terminal. I used the exact some code
 that you gave me.
 
 % time ./test  ps -ef | grep sleep
 ^C
 real  0m10.005s
 user  0m0.003s
 sys   0m0.003s
 deniz14095 14047  0 13:05 pts/100:00:00 grep sleep
 
 What's strange though is that when I hit C-c *twice*, I get this behavior:

Hmm, I think GHC RTS handles SIGINT. I recompiled with thread support and got 
the same behavour. 

See: http://hackage.haskell.org/trac/ghc/wiki/Commentary/Rts/Signals

When the interrupt signal is received, the default behaviour of
the runtime is to attempt to shut down the Haskell program
gracefully. It does this by calling interruptStgRts() in
rts/Schedule.c (see Commentary/Rts/Scheduler#ShuttingDown). If a
second interrupt signal is received, then we terminate the
process immediately; this is just in case the normal shutdown
procedure failed or hung for some reason, the user is always
able to stop the process with two control-C keystrokes.

You better install signal handlers using installHandler.

Best Regards,
--
aycan

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


Re: [Haskell-cafe] Re: Running a sub-process which dies with the main program

2009-06-19 Thread Deniz Dogan
2009/6/19 Aycan iRiCAN aycan.iri...@core.gen.tr:

 Cum, 2009-06-19 tarihinde 13:09 +0200 saatinde, Deniz Dogan yazdı:
 2009/6/19 Aycan iRiCAN aycan.iri...@core.gen.tr:
 
  Cum, 2009-06-19 tarihinde 12:42 +0200 saatinde, Deniz Dogan yazdı:
  2009/6/19 Aycan iRiCAN aycan.iri...@core.gen.tr:
  
   Cum, 2009-06-19 tarihinde 11:58 +0200 saatinde, Deniz Dogan yazdı:
   2009/6/18 Deniz Dogan deniz.a.m.do...@gmail.com:
Hi
   
I couldn't come up with a better subject than this one, so anyways...
   
I have a small program which spawns a subprocess. However, when I hit
C-c, the subprocess won't die, instead it will just keep running 
until
it's done or until I kill it. I've looked around in System.Process 
for
something suitable for my needs, but I can't seem to find it. Any
ideas?
  
   With a tip from a person outside of the mailing list I found
   System.Process.system, which essentially does exactly what I was
   asking for.
  
   Hey I'm already subscribed :) You can read from sout and serr with
   below example. Hope that it helps.
  
  
   module Main where
  
   import System.Process  -- using process-1.0.1.1
  
   main = do
    (_, sout, serr, p) - createProcess (proc sleep [10])
                          { std_out = CreatePipe
                          , std_err = CreatePipe }
    r - waitForProcess p
    return ()
  
 
  Thanks!
 
  But this was the approach I used before I went to
  System.Process.system and it did not work on my Linux machine.
 
  Give it a try. Try to send CTRL-C and look if sleep 10 (which is a
  subprocess) process terminates.
 
  ay...@aycan:~/haskell$ time ./deniz2  ps -ef | grep sleep
  ^C
  real    0m0.707s
  user    0m0.001s
  sys     0m0.004s
    aycan 13098  4430   0 13:50:23 pts/7       0:00 grep sleep
 
  It terminates with ghc 6.10.3 on OpenSolaris.

 This is copied verbatim from my terminal. I used the exact some code
 that you gave me.

 % time ./test  ps -ef | grep sleep
 ^C
 real  0m10.005s
 user  0m0.003s
 sys   0m0.003s
 deniz    14095 14047  0 13:05 pts/1    00:00:00 grep sleep

 What's strange though is that when I hit C-c *twice*, I get this behavior:

 Hmm, I think GHC RTS handles SIGINT. I recompiled with thread support and got 
 the same behavour.

 See: http://hackage.haskell.org/trac/ghc/wiki/Commentary/Rts/Signals

        When the interrupt signal is received, the default behaviour of
        the runtime is to attempt to shut down the Haskell program
        gracefully. It does this by calling interruptStgRts() in
        rts/Schedule.c (see Commentary/Rts/Scheduler#ShuttingDown). If a
        second interrupt signal is received, then we terminate the
        process immediately; this is just in case the normal shutdown
        procedure failed or hung for some reason, the user is always
        able to stop the process with two control-C keystrokes.

 You better install signal handlers using installHandler.

 Best Regards,

But that's what syncProcess does when mingw32_HOST_OS is not defined.
Also, compiling without -threaded doesn't help the problem on my
machine, it still acts the same.

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


[Haskell-cafe] duplicate definition for symbol

2009-06-19 Thread Henk-Jan van Tuyl


L.S.,

I am trying to run a program in GHCi, but I get a meesage that an object  
file is loaded twice; it appears that two different versions of package  
process are loaded, see the session text below. How can I solve this?



GHCi, version 6.10.1: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer ... linking ... done.
Loading package base ... linking ... done.
Prelude :load Main.lhs
[1 of 1] Compiling Main ( Main.lhs, interpreted )
Ok, modules loaded: Main.
*Main :main
Loading package syb ... linking ... done.
Loading package base-3.0.3.0 ... linking ... done.
Loading package array-0.2.0.0 ... linking ... done.
Loading package containers-0.2.0.0 ... linking ... done.
Loading package bytestring-0.9.1.4 ... linking ... done.
Loading package old-locale-1.0.0.1 ... linking ... done.
Loading package old-time-1.0.0.1 ... linking ... done.
Loading package filepath-1.1.0.1 ... linking ... done.
Loading package Win32-2.2.0.0 ... linking ... done.
Loading package directory-1.0.0.2 ... linking ... done.
Loading package random-1.0.0.1 ... linking ... done.
Loading package time-1.1.2.2 ... linking ... done.
Loading package stm-2.1.1.2 ... linking ... done.
Loading package split-0.1.1 ... linking ... done.
Loading package HUnit-1.2.0.3 ... linking ... done.
Loading package QuickCheck-1.2.0.0 ... linking ... done.
Loading package process-1.0.1.1 ... linking ... done.
Loading package haskell98 ... linking ... done.
Loading package mtl-1.1.0.2 ... linking ... done.
Loading package parsec-2.1.0.1 ... linking ... done.
Loading package network-2.2.0.1 ... linking ... done.
Loading package hslogger-1.0.7 ... linking ... done.
Loading package process-1.0.1.0 ...

GHCi runtime linker: fatal error: I found a duplicate definition for symbol
   _runInteractiveProcess
whilst processing object file
   C:\Programs\ghc\ghc-6.10.1\process-1.0.1.0\HSprocess-1.0.1.0.o
This could be caused by:
   * Loading two different object files which export the same symbol
   * Specifying the same object file twice on the GHCi command line
   * An incorrect `package.conf' entry, causing some object to be
 loaded twice.
GHCi cannot safely continue in this situation.  Exiting now.  Sorry.


--
Met vriendelijke groet,
Henk-Jan van Tuyl


--
http://functor.bamikanarie.com
http://Van.Tuyl.eu/
--


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


Re: [Haskell-cafe] duplicate definition for symbol

2009-06-19 Thread Daniel Fischer
Am Freitag 19 Juni 2009 16:06:50 schrieb Henk-Jan van Tuyl:
 L.S.,

 I am trying to run a program in GHCi, but I get a meesage that an object  
 file is loaded twice; it appears that two different versions of package  
 process are loaded, see the session text below. How can I solve this?

http://www.haskell.org/cabal/FAQ.html#dependencies-conflict

Wow, that one is really common.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] ANNOUNCE fmlist

2009-06-19 Thread Sebastian Fischer


On Jun 18, 2009, at 9:57 AM, Sjoerd Visscher wrote:


This is my first package on Hackage, so any comments are welcome!


It is not only pleasingly elegant but also quite useful:

Your Monad and MonadPlus instances lead me to an interesting  
observation. Various strategies for non-deterministic search can be  
implemented using FMList by expressing failure and choice via a Monoid  
instance.


I have just finished a revision of a paper that explains how to factor  
two-continuation based backtracking (and other strategies) into a  
continuation monad transformer and a type class for non-deterministic  
computations (I'd be glad to receive comments!).


http://www-ps.informatik.uni-kiel.de/~sebf/pub/atps09.html

Now I recognise that one can also use FMList as the part that provides  
return and = and any Monoid for failure and choice.


Especially, one can implement breadth-first search (bfs) using a  
monoid that collects levels of a search tree and iterative deepening  
depth-first search (idfs) using a monoid that represents depth-bounded  
computations.


I have updated my package level-monad to use your library and monoids:

http://hackage.haskell.org/package/level-monad

The employed Monoid instances do not satisfy any monoid law. However,  
these are the simplest implementations of bfs and idfs that I am aware  
of, so I don't care very much ;)


Sebastian


--
Underestimating the novelty of the future is a time-honored tradition.
(D.G.)



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


Re: [Haskell-cafe] ANNOUNCE fmlist

2009-06-19 Thread Sjoerd Visscher


On Jun 19, 2009, at 3:35 PM, Sjoerd Visscher wrote:


 transform t l = FM $ \f - unFM l (t f)

Unfortunately I couldn't get this code to type-check, so the library  
doesn't use transform.



With some help from Martijn van Steenbergen the type turned out to be:

transform :: (forall b. Monoid b = (a - b) - (c - b)) - FMList c - 
 FMList a


I've updated the library to use the transform function.
--
Sjoerd Visscher
sjo...@w3future.com



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


Re: [Haskell-cafe] packages on Hackage?

2009-06-19 Thread Don Stewart
vigalchin:
 Hello,
 
   Haskell packages on Hackage can be hosted anywhere, yes?
 
   If a Haskell package is hosted on Hackage, how often is it backed up?

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


Re: [Haskell-cafe] IORef memory leak

2009-06-19 Thread Don Stewart
jsnow:

 I'm having some trouble with excessive memory use in a program that uses  
 a lot of IORefs.  I was able to write a much simpler program which  
 exhibits the same sort of behavior.  It appears that modifyIORef and  
 writeIORef leak memory; perhaps they keep a reference to the old  
 value.  I tried both ghc-6.8.3 and ghc-6.10.1.

 Is this a known limitation, or is this a ghc bug, or am I using IORefs  
 in the wrong way?

 -jim


 module Main where

 import Data.IORef
 import Control.Monad

 -- Leaks memory
 leakcheck1 ior =
 do go 10
 where
go 0 = return ()
go n = do modifyIORef ior (+1)
  go (n-1)

It is not possible to write a modifyIORef that *doesn't* leak memory!

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


Re: [Haskell-cafe] IORef memory leak

2009-06-19 Thread Daniel van den Eijkel


Don Stewart schrieb:

It is not possible to write a modifyIORef that *doesn't* leak memory!
  

Why? Or can one read about it somewhere?

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


Re: [Haskell-cafe] IORef memory leak

2009-06-19 Thread Don Stewart
dvde:

 Don Stewart schrieb:
 It is not possible to write a modifyIORef that *doesn't* leak memory!
   
 Why? Or can one read about it somewhere?


Try writing a version of this program, using modifyIORef only, 
such that it doesn't exhaust the heap:

import Data.IORef
import Control.Monad
import System.IO.Unsafe

ref :: IORef Int
ref = unsafePerformIO $ newIORef 0
{-# NOINLINE ref #-}

main = do
modifyIORef ref (\a - a + 1)
main

Run it in a constrained environment, so you don't thrash:

$ ./A +RTS -M100M
Heap exhausted;
Current maximum heap size is 9744 bytes (95 MB);
use `+RTS -Msize' to increase it.

The goal is to run in constant space.

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


Re: [Haskell-cafe] IORef memory leak

2009-06-19 Thread Claus Reinke

It is not possible to write a modifyIORef that *doesn't* leak memory!
  

Why? Or can one read about it somewhere?


Possibly, Don meant that 'modifyIORef' is defined in a way that 
does not allow to enforce evaluation of the result of the modification

function (a typical problem with fmap-style library functions):

   modifyIORef ref f = readIORef ref = writeIORef ref . f

No matter whether 'f' is strict or not, the 'writeIORef r' doesn't
evaluate its result, just stores the unevaluated application:

r-newIORef 0
modifyIORef r (\x-trace done $ x+1)
modifyIORef r (\x-trace done $ x+1)
readIORef r
   done
   done
   2

If it had been defined like this instead

   mRef r ($) f = readIORef r = (writeIORef r $) . f

it would be possible to transform the strictness of 'writeIORef r'
to match that of 'f':

r-newIORef 0
mRef r ($) (\x-trace done $ x+1)
mRef r ($) (\x-trace done $ x+1)
readIORef r
   done
   done
   2
r-newIORef 0
mRef r ($!) (\x-trace done $ x+1)
   done
mRef r ($!) (\x-trace done $ x+1)
   done
readIORef r
   2

Claus


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


Re: [Haskell-cafe] Using Parsec with ByteString ?

2009-06-19 Thread Chaddaï Fouché
On Fri, Jun 19, 2009 at 1:51 PM, Fernandquarantedeu...@yahoo.fr wrote:
 but the parser one needs to write must parse ByteStrings instead of Strings
 (that is, something like having a Parsec Bytestring () type, unless I'm
 completely misunderstanding the situation). My problem is that I do not
 manage
 to write primitive parsing combinators (like string, satisfy, letter, etc.)
 to
 define my language's tokens.

Why would you want to do that ? After all, those combinators are
already available in Text.Parsec.Char : they work on any Stream
instance whose token type is Char, which happens to be the case for
ByteString.

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


Re: [Haskell-cafe] IORef memory leak

2009-06-19 Thread Daniel van den Eijkel

Don Stewart schrieb:

dvde:
  

Don Stewart schrieb:


It is not possible to write a modifyIORef that *doesn't* leak memory!
  
  

Why? Or can one read about it somewhere?




Try writing a version of this program, using modifyIORef only, 
such that it doesn't exhaust the heap:


import Data.IORef
import Control.Monad
import System.IO.Unsafe

ref :: IORef Int
ref = unsafePerformIO $ newIORef 0
{-# NOINLINE ref #-}

main = do
modifyIORef ref (\a - a + 1)
main

Run it in a constrained environment, so you don't thrash:

$ ./A +RTS -M100M
Heap exhausted;
Current maximum heap size is 9744 bytes (95 MB);
use `+RTS -Msize' to increase it.

The goal is to run in constant space.

-- Don

  
Hm, do you say it is not possible to write a modifyIORef function that 
does not leak memory, or do you say it is not possible to use the 
(existing) modifyIORef without having memory leaks?


I wrote the following which runs in constant space, but it introduces 
strictness, which is not always desirable. And yes, using only 
modifyIORef this could not be done this way, because the strict 
evaluation happens on the IO-Monad-level. But such examples occured 
already in this thread.


import Data.IORef
import Control.Monad
import System.IO.Unsafe

ref :: IORef Int
ref = unsafePerformIO $ newIORef 0
{-# NOINLINE ref #-}

main = do
   myModifyIORef ref (\a - a + 1)
   main
  
myModifyIORef :: IORef a - (a-a) - IO ()

myModifyIORef ref f = do
a - readIORef ref
let a' = f a
seq a' $ writeIORef ref a'

So would it make sense to create a strict modifyIORef' function?

best regards,
daniel

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


Re: [Haskell-cafe] IORef memory leak

2009-06-19 Thread Don Stewart
dvde:
 Don Stewart schrieb:
 dvde:
   
 Don Stewart schrieb:
 
 It is not possible to write a modifyIORef that *doesn't* leak memory!
 
 Why? Or can one read about it somewhere?
 


 Try writing a version of this program, using modifyIORef only, such 
 that it doesn't exhaust the heap:

 import Data.IORef
 import Control.Monad
 import System.IO.Unsafe

 ref :: IORef Int
 ref = unsafePerformIO $ newIORef 0
 {-# NOINLINE ref #-}

 main = do
 modifyIORef ref (\a - a + 1)
 main

 Run it in a constrained environment, so you don't thrash:

 $ ./A +RTS -M100M
 Heap exhausted;
 Current maximum heap size is 9744 bytes (95 MB);
 use `+RTS -Msize' to increase it.

 The goal is to run in constant space.

 -- Don

   
 Hm, do you say it is not possible to write a modifyIORef function that  
 does not leak memory, or do you say it is not possible to use the  
 (existing) modifyIORef without having memory leaks?


The latter. atomicModifyIORef is harder though still, since it is a
primop with the same properties as modifyIORef :/

 So would it make sense to create a strict modifyIORef' function?


Very much so. In fact, I'd argue the vast majority of uses are for the
WHNF-strict version.

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


Re: [Haskell-cafe] IORef memory leak

2009-06-19 Thread Daniel van den Eijkel

Yes I guessed that.
Thanks,
Daniel

Claus Reinke schrieb:

It is not possible to write a modifyIORef that *doesn't* leak memory!
  

Why? Or can one read about it somewhere?


Possibly, Don meant that 'modifyIORef' is defined in a way that does 
not allow to enforce evaluation of the result of the modification

function (a typical problem with fmap-style library functions):

   modifyIORef ref f = readIORef ref = writeIORef ref . f

No matter whether 'f' is strict or not, the 'writeIORef r' doesn't
evaluate its result, just stores the unevaluated application:

r-newIORef 0
modifyIORef r (\x-trace done $ x+1)
modifyIORef r (\x-trace done $ x+1)
readIORef r
   done
   done
   2

If it had been defined like this instead

   mRef r ($) f = readIORef r = (writeIORef r $) . f

it would be possible to transform the strictness of 'writeIORef r'
to match that of 'f':

r-newIORef 0
mRef r ($) (\x-trace done $ x+1)
mRef r ($) (\x-trace done $ x+1)
readIORef r
   done
   done
   2
r-newIORef 0
mRef r ($!) (\x-trace done $ x+1)
   done
mRef r ($!) (\x-trace done $ x+1)
   done
readIORef r
   2

Claus


___
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] Use MySQL from Haskell

2009-06-19 Thread John Goerzen
Maciej Podgurski wrote:
 Building convertible-1.0.5...

There was unfortunately an API change in GHC 6.10.3 that could not be
worked around.  Either upgrade to 6.10.3 or use an older version of
convertible.

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


Re: [Haskell-cafe] ANNOUNCE fmlist

2009-06-19 Thread Sjoerd Visscher


On Jun 19, 2009, at 5:06 PM, Sebastian Fischer wrote:

Your Monad and MonadPlus instances lead me to an interesting  
observation. Various strategies for non-deterministic search can be  
implemented using FMList by expressing failure and choice via a  
Monoid instance.


I have just finished a revision of a paper that explains how to  
factor two-continuation based backtracking (and other strategies)  
into a continuation monad transformer and a type class for non- 
deterministic computations (I'd be glad to receive comments!).


   http://www-ps.informatik.uni-kiel.de/~sebf/pub/atps09.html

Now I recognise that one can also use FMList as the part that  
provides return and = and any Monoid for failure and choice.


Especially, one can implement breadth-first search (bfs) using a  
monoid that collects levels of a search tree and iterative deepening  
depth-first search (idfs) using a monoid that represents depth- 
bounded computations.


I have updated my package level-monad to use your library and monoids:

   http://hackage.haskell.org/package/level-monad

The employed Monoid instances do not satisfy any monoid law.  
However, these are the simplest implementations of bfs and idfs that  
I am aware of, so I don't care very much ;)



Very nice. It is cool to see someone using this already! I see you did  
performance tests. How does your current version compare to f.e. one  
based on DiffLists?


I wonder though, aren't you worried that updated versions of FMList  
might use the monoid laws to rewrite certains bits, and your code  
would break? Essentially you are using FMLists as a tree structure,  
which isn't possible when you abide by the monoid laws.


I think you should be able to do the same thing in as many lines,  
using f.e. the ChoiceT type from MonadLib, where bfs and idfsBy are  
variations on runChoiceT. The ChoiceEff part might complicate things a  
bit though. But I might be missing some essential detail.


greetings,
--
Sjoerd Visscher
sjo...@w3future.com



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


Re: [Haskell-cafe] duplicate definition for symbol

2009-06-19 Thread austin s
Excerpts from Henk-Jan van Tuyl's message of Fri Jun 19 09:06:50 -0500 2009:
 
 L.S.,
 
 I am trying to run a program in GHCi, but I get a meesage that an object  
 file is loaded twice; it appears that two different versions of package  
 process are loaded, see the session text below. How can I solve this?
 
 
 GHCi, version 6.10.1: http://www.haskell.org/ghc/  :? for help
 Loading package ghc-prim ... linking ... done.
 Loading package integer ... linking ... done.
 Loading package base ... linking ... done.
 Prelude :load Main.lhs
 [1 of 1] Compiling Main ( Main.lhs, interpreted )
 Ok, modules loaded: Main.
 *Main :main
 Loading package syb ... linking ... done.
 Loading package base-3.0.3.0 ... linking ... done.
 Loading package array-0.2.0.0 ... linking ... done.
 Loading package containers-0.2.0.0 ... linking ... done.
 Loading package bytestring-0.9.1.4 ... linking ... done.
 Loading package old-locale-1.0.0.1 ... linking ... done.
 Loading package old-time-1.0.0.1 ... linking ... done.
 Loading package filepath-1.1.0.1 ... linking ... done.
 Loading package Win32-2.2.0.0 ... linking ... done.
 Loading package directory-1.0.0.2 ... linking ... done.
 Loading package random-1.0.0.1 ... linking ... done.
 Loading package time-1.1.2.2 ... linking ... done.
 Loading package stm-2.1.1.2 ... linking ... done.
 Loading package split-0.1.1 ... linking ... done.
 Loading package HUnit-1.2.0.3 ... linking ... done.
 Loading package QuickCheck-1.2.0.0 ... linking ... done.
 Loading package process-1.0.1.1 ... linking ... done.
 Loading package haskell98 ... linking ... done.
 Loading package mtl-1.1.0.2 ... linking ... done.
 Loading package parsec-2.1.0.1 ... linking ... done.
 Loading package network-2.2.0.1 ... linking ... done.
 Loading package hslogger-1.0.7 ... linking ... done.
 Loading package process-1.0.1.0 ...
 
 GHCi runtime linker: fatal error: I found a duplicate definition for symbol
 _runInteractiveProcess
 whilst processing object file
 C:\Programs\ghc\ghc-6.10.1\process-1.0.1.0\HSprocess-1.0.1.0.o
 This could be caused by:
 * Loading two different object files which export the same symbol
 * Specifying the same object file twice on the GHCi command line
 * An incorrect `package.conf' entry, causing some object to be
   loaded twice.
 GHCi cannot safely continue in this situation.  Exiting now.  Sorry.
 
 

The easiest solution would simply be to 'ghc-pkg unregister
process-1.0.1.1', and then rebuild all the packages that depend on it
against process-1.0.1.0.

The reason this is happening is simply because you have two libraries
you depend on, each of which depends on a different version of
process.

It's a fairly annoying error, that is prone to happen when you have
upgraded versions of GHC's bootlibs (i.e. necessary libraries for
GHC installation.)

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


Re: [Haskell-cafe] Use MySQL from Haskell

2009-06-19 Thread Maciej Podgurski
Does Database.HDBC.getTables work for you? I successfully created a new 
table and selected data from a database but getTables always returns an 
empty list (what is not a big problem since a query show tables works 
fine).


Besh wishes,
Maciej


W dniu 19.06.2009 13:50 Daniel van den Eijkel pisze:
The same with me - I'm on XP, and HDBC-odbc is the library I got 
running to access the MySQL database.

Regards,
Daniel


Michael Snoyman schrieb:

Marciej,

I went the HDBC route and got the same problem. Although it does not 
seem to be officially blessed, try installing the time-1.1.3 package. 
It's working for me at least, which I know is a dubious recommendation.


Also, I am currently using the hdbc-odbc package for accessing MySQL. 
I couldn't get hdbc-mysql to work properly. I hope that once I get 
this project working right, I'll have a chance to dig into the 
hdbc-mysql issue itself.


Good luck!

Michael   


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


Re: [Haskell-cafe] IORef memory leak

2009-06-19 Thread Jim Snow


Don Stewart wrote:

dvde:
  

Don Stewart schrieb:


It is not possible to write a modifyIORef that *doesn't* leak memory!
  
  

Why? Or can one read about it somewhere?




Try writing a version of this program, using modifyIORef only, 
such that it doesn't exhaust the heap:


import Data.IORef
import Control.Monad
import System.IO.Unsafe

ref :: IORef Int
ref = unsafePerformIO $ newIORef 0
{-# NOINLINE ref #-}

main = do
modifyIORef ref (\a - a + 1)
main

Run it in a constrained environment, so you don't thrash:

$ ./A +RTS -M100M
Heap exhausted;
Current maximum heap size is 9744 bytes (95 MB);
use `+RTS -Msize' to increase it.

The goal is to run in constant space.

-- Don
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
  
Thanks, that's good to know. 


do x - readIORef ior
 writeIORef ior $! (x+1)

Works for me.  The laziness of modifyIORef and workarounds would be a 
good thing to have documented in the modifyIORef docs [1], since it's 
probably a common source of memory leaks.  I'd also be in favor of a 
strict version of modifyIORef.


[1] 
http://www.haskell.org/ghc/dist/current/docs/libraries/base/Data-IORef.html#v%3AmodifyIORef


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


Re: [Haskell-cafe] Use MySQL from Haskell

2009-06-19 Thread Maciej Podgurski

Hi Björn,

thanks for your hint, I finally made HDBC-odbc and even hsql-mysql run. 
Below is a step-by-step manual how to install both packages on windows 
for people having the same troubles I had. I used GHC 6.8.3.


MySQL from HDBC-odbc


1.) Install package time-1.1.2.4.

2.) Download package convertible-1.0.5. In convertible.cabal find the line
   Build-Depends: ..., time=1.1.2.4, ...
and replace it by 
   Build-Depends: ..., time=1.1.2.4  1.1.3, ...

Now the installation shouldn't fail with a compilation error.

3.) Download package HDBC-2.1.1, modfiy HDBC.cabal in the same way as in 
2.) and install the package.


4.) Install package HDBC-odbc-2.1.0.0.

5.) There still was one thing I didn't know that made my example fail 
with an exception. You need to install a MySQL ODBC connector for 
Windows (available from dev.mysql.com).


6) Now the following example should return a list of all table names in 
the database:


import Database.HDBC
import Database.HDBC.ODBC

main :: IO ()
main = do
   conn - connectODBC DRIVER={MySQL ODBC 5.1 Driver}; 
SERVER=my_server; DATABASE=my_database; UID=my_username; 
PASSWORD=my_password

   qs - quickQuery' conn show tables []
   mapM_ (\[SqlByteString table] - print table) qs
   disconnect conn

(There's also a getTables function but it always returns an empty list 
on my system, I don't know why).



MySQL from hsql-mysql
*

1.) Install package hsql-1.7.1.

2.) Download package hsql-mysql-1.7.1. In hsql-mysql.cabal find the line
   include-dirs: Database/HSQL, /usr/include/mysql
and replace it by
   include-dirs: Database/HSQL
Also find the line
   extra-lib-dirs: /usr/lib/mysql
and remove it.

3.) Do a
   runghc Setup configure --extra-include-dirs=path_to_mysql/include/
  --extra-lib-dirs=path_to_mysql/lib/opt/
   runghc Setup build
   runghc Setup install
  
where path_to_mysql is the path to your MySQL server installation. I'm 
using MySQL Server 5.1, so maybe you have to adjust the include or lib path.


4.) Now you should be able to compile:

import Database.HSQL
import Database.HSQL.MySQL

main :: IO ()
main = do
   conn - connect my_server my_database my_username my_password
   ts - tables conn
   mapM_ print ts
   disconnect conn

5.) Execute the main function. If you get an error like
   Loading package hsql-mysql-1.7.1 ... can't load .so/.DLL for: 
mysqlclient (addDLL: unknown error)
go to path_to_mysql/bin where a file libmySQL.dll should reside. 
Copy this file to mysqlclient.dll and try executing the main function 
again. Now you should get a list of all tables in the database.



Installing HDBC-mysql still failed due to a missing file mysql_config 
which seems to be available only for linux systems.


Best wishes,
Maciej


W dniu 19.06.2009 09:31 Björn Peemöller pisze:

Maciej Podgurski schrieb:

So I switched to HDBC-2.1.1 and got the next compile error:

Building convertible-1.0.5...

Data/Convertible/Instances/Num.hs:671:0:
warning: no newline at end of file
[...]
[5 of 8] Compiling Data.Convertible.Instances.C (
Data/Convertible/Instances/C.hs, dist\build/Data/C
onvertible/Instances/C.o )
[6 of 8] Compiling Data.Convertible.Instances.Time (
Data/Convertible/Instances/Time.hs, dist\build/
Data/Convertible/Instances/Time.o )

Data/Convertible/Instances/Time.hs:64:0:
   Duplicate instance declarations:
 instance Typeable NominalDiffTime
   -- Defined at Data/Convertible/Instances/Time.hs:(64,0)-(65,42)
 instance Typeable NominalDiffTime
   -- Defined in time-1.1.3:Data.Time.Clock.UTC

Data/Convertible/Instances/Time.hs:67:0:
   Duplicate instance declarations:
 instance Typeable UTCTime
   -- Defined at Data/Convertible/Instances/Time.hs:(67,0)-(68,34)
 instance Typeable UTCTime
   -- Defined in time-1.1.3:Data.Time.Clock.UTC 


Hi Maciej,

this is quite easy to fix (although a little bit dirty). The problem is
that time-1.1.3 now defines some Typeable instances which time-1.1.2.4
did not and which are therefore defined in convertible, too. I don't
know a general fix to the problem, but you can either

- download the convertible package and comment out the two instance
declarations as shown in the error message and then cabal install it
- install from Hackage with additional constraint: cabal install
convertible --constraint=time1.1.3

I hope this will help you get HDBC running.

Cheers,
Björn




___
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] IORef memory leak

2009-06-19 Thread Gregory Collins
Jim Snow js...@cs.pdx.edu writes:

 Works for me.  The laziness of modifyIORef and workarounds would be a
 good thing to have documented in the modifyIORef docs, since it's
 probably a common source of memory leaks.  I'd also be in favor of a
 strict version of modifyIORef.

http://hackage.haskell.org/packages/archive/strict-io/0.1/doc/html/Data-IORef-Strict.html
?

G.
-- 
Gregory Collins g...@gregorycollins.net
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Installing agda through cabal

2009-06-19 Thread Paulo J. Matos
Hi all,

I am trying to install agda through cabal but I get this:
$ cabal install alex
Resolving dependencies...
[1 of 1] Compiling Main
( /tmp/alex-2.3.116333/alex-2.3.1/Setup.lhs, 
/tmp/alex-2.3.116333/alex-2.3.1/dist/setup/Main.o )

/tmp/alex-2.3.116333/alex-2.3.1/Setup.lhs:6:51:
Warning: In the use of `buildVerbose'
 (imported from Distribution.Simple.Setup):
 Deprecated: Use buildVerbosity instead

/tmp/alex-2.3.116333/alex-2.3.1/Setup.lhs:7:51:
Warning: In the use of `defaultUserHooks'
 (imported from Distribution.Simple):
 Deprecated: Use simpleUserHooks or autoconfUserHooks,
unless you need Cabal-1.2
 compatibility in which case you must stick with
defaultUserHooks
Linking /tmp/alex-2.3.116333/alex-2.3.1/dist/setup/setup ...
Warning: defaultUserHooks in Setup script is deprecated.
Configuring alex-2.3.1...
Preprocessing executables for alex-2.3.1...
Building alex-2.3.1...
[ 1 of 16] Compiling Set  ( src/Set.hs,
dist/build/alex/alex-tmp/Set.o )
[ 2 of 16] Compiling DFS  ( src/DFS.hs,
dist/build/alex/alex-tmp/DFS.o )
[ 3 of 16] Compiling Sort ( src/Sort.hs,
dist/build/alex/alex-tmp/Sort.o )
[ 4 of 16] Compiling CharSet  ( src/CharSet.hs,
dist/build/alex/alex-tmp/CharSet.o )
[ 5 of 16] Compiling Map  ( src/Map.hs,
dist/build/alex/alex-tmp/Map.o )
[ 6 of 16] Compiling Paths_alex
( dist/build/autogen/Paths_alex.hs,
dist/build/alex/alex-tmp/Paths_alex.o )
[ 7 of 16] Compiling Util ( src/Util.hs,
dist/build/alex/alex-tmp/Util.o )
[ 8 of 16] Compiling AbsSyn   ( src/AbsSyn.hs,
dist/build/alex/alex-tmp/AbsSyn.o )
[ 9 of 16] Compiling ParseMonad   ( src/ParseMonad.hs,
dist/build/alex/alex-tmp/ParseMonad.o )
[10 of 16] Compiling Scan
( dist/build/alex/alex-tmp/Scan.hs, dist/build/alex/alex-tmp/Scan.o )
[11 of 16] Compiling Output   ( src/Output.hs,
dist/build/alex/alex-tmp/Output.o )
[12 of 16] Compiling Info ( src/Info.hs,
dist/build/alex/alex-tmp/Info.o )
[13 of 16] Compiling NFA  ( src/NFA.hs,
dist/build/alex/alex-tmp/NFA.o )
[14 of 16] Compiling DFA  ( src/DFA.hs,
dist/build/alex/alex-tmp/DFA.o )
[15 of 16] Compiling Parser
( dist/build/alex/alex-tmp/Parser.hs,
dist/build/alex/alex-tmp/Parser.o )
[16 of 16] Compiling Main ( src/Main.hs,
dist/build/alex/alex-tmp/Main.o )
Linking dist/build/alex/alex ...
Installing executable(s) in /home/pmatos/.cabal/bin
pma...@drserver ~ $ cabal install agda
Resolving dependencies...
Configuring Agda-2.2.2...
cabal: alex version =2.0.1  3 is required but it could not be found.
cabal: Error: some packages failed to install:
Agda-2.2.2 failed during the configure step. The exception was:
exit: ExitFailure 1

As you can see, I had just finished installing alex 2.3.1, so why does
cabal still request alex =2.0.1  3?

Cheers,

Paulo Matos

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


Re: [Haskell-cafe] Installing agda through cabal

2009-06-19 Thread Jake McArthur

Paulo J. Matos wrote:

As you can see, I had just finished installing alex 2.3.1, so why does
cabal still request alex =2.0.1  3?


Probably you don't have alex in your PATH.

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


Re: [Haskell-cafe] Installing agda through cabal

2009-06-19 Thread Paulo J. Matos
On Fri, 2009-06-19 at 15:35 -0500, Jake McArthur wrote:
 Paulo J. Matos wrote:
  As you can see, I had just finished installing alex 2.3.1, so why does
  cabal still request alex =2.0.1  3?
 
 Probably you don't have alex in your PATH.
 
 - Jake

Shouldn't cabal make sure the library it installs are in PATH? or at
least, they are in the PATH of the apps built by cabal itself?

Cheers,

Paulo Matos

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


Re: [Haskell-cafe] Installing agda through cabal

2009-06-19 Thread Max Rabkin
On Fri, Jun 19, 2009 at 11:20 PM, Paulo J. Matospocma...@gmail.com wrote:
 Shouldn't cabal make sure the library it installs are in PATH?

This would require modifying the path (since there may be no writable
location on the existing path). But the PATH is set by a combination
of several programs written in Turing-complete languages (shell
script), and those programs themselves are in unknown locations
(depending on the shell in use).

 or at
 least, they are in the PATH of the apps built by cabal itself?

This is a possibility. But surely you're one day going to want to run
your cabal-installed programs yourself (there are some pretty handy
ones), so the easiest thing is to extend your path.

It might be a good idea for cabal-install to warn that its bin
directory is not in your path when you install an executable.

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


Re: [Haskell-cafe] Installing agda through cabal

2009-06-19 Thread Paulo J. Matos
On Fri, 2009-06-19 at 23:35 +0200, Max Rabkin wrote:
 On Fri, Jun 19, 2009 at 11:20 PM, Paulo J. Matospocma...@gmail.com wrote:
  Shouldn't cabal make sure the library it installs are in PATH?
 
 This would require modifying the path (since there may be no writable
 location on the existing path). But the PATH is set by a combination
 of several programs written in Turing-complete languages (shell
 script), and those programs themselves are in unknown locations
 (depending on the shell in use).
 
  or at
  least, they are in the PATH of the apps built by cabal itself?
 
 This is a possibility. But surely you're one day going to want to run
 your cabal-installed programs yourself (there are some pretty handy
 ones), so the easiest thing is to extend your path.
 

You're right. Added .cabal/bin to path and everything is ok.

 It might be a good idea for cabal-install to warn that its bin
 directory is not in your path when you install an executable.
 

Yep, might be an interesting idea for warning. :)

 --Max

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


Re: [Haskell-cafe] Installing agda through cabal

2009-06-19 Thread Daniel Fischer
Am Freitag 19 Juni 2009 23:41:05 schrieb Paulo J. Matos:
  It might be a good idea for cabal-install to warn that its bin
  directory is not in your path when you install an executable.

 Yep, might be an interesting idea for warning. :)

This has been discussed in connection to the question where cabal should by 
default 
install things. IIRC, the plan is to have cabal display a message on first 
startup asking 
the user for the default install location [of binaries] and telling them to 
make sure it's 
in the path.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Use MySQL from Haskell

2009-06-19 Thread Daniel van den Eijkel

Hi Maciej,

Database.HDBC.getTables works fine here (XP, ghc 6.10.2, HDBC-2.1.0, 
HDBC-ODBC-2.1.0.0) - it gives me the list of all tablenames, as 
intended. Which HDBC version do you use?


best regards,
daniel


Maciej Podgurski schrieb:
Does Database.HDBC.getTables work for you? I successfully created a 
new table and selected data from a database but getTables always 
returns an empty list (what is not a big problem since a query show 
tables works fine).


Besh wishes,
Maciej


W dniu 19.06.2009 13:50 Daniel van den Eijkel pisze:
The same with me - I'm on XP, and HDBC-odbc is the library I got 
running to access the MySQL database.

Regards,
Daniel


Michael Snoyman schrieb:

Marciej,

I went the HDBC route and got the same problem. Although it does not 
seem to be officially blessed, try installing the time-1.1.3 
package. It's working for me at least, which I know is a dubious 
recommendation.


Also, I am currently using the hdbc-odbc package for accessing 
MySQL. I couldn't get hdbc-mysql to work properly. I hope that once 
I get this project working right, I'll have a chance to dig into the 
hdbc-mysql issue itself.


Good luck!

Michael   



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


[Haskell-cafe] Re: ANN: haskell-src-exts 1.0.0 rc1 (aka 0.5.2)

2009-06-19 Thread Niklas Broberg
Hi all,

 Another day, another release candidate. Please see
 haskell-src-exts-0.5.5, 1.0.0 rc3. Thanks a lot to all reports, and
 please keep up the good work!

Here we go again. Please have a look at haskell-src-exts-0.5.6, or
1.0.0 rc4. Thanks again for the reports, they're all truly invaluable.

Changes in 0.5.6:
===

One major addition:

* Support for relaxed layout in do-blocks! Yes, I caved in, after I
got enough reports about it.


Two stupid bugs fixed:

* MagicHash ConId lexemes can now be followed by things other than
space characters (like closing brackets: foo :: (Int#)).

* ctypes (i.e. types with contexts and forall-quantifiers) can now
appear inside tuples and lists if the proper extensions are on.


Cheers,

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


Re: [Haskell-cafe] Use MySQL from Haskell

2009-06-19 Thread Maciej Podgurski

Hi Daniel,

I use HDBC-2.1.1 + HDBC-odbc-2.1.0.0 with GHC 6.8.3 and MySQL Server 5.1 
on XP. The hsql equivalent Database.HSQL.tables works as expected.


Best wishes,
Maciej


W dniu 20.06.2009 01:16 Daniel van den Eijkel pisze:

Hi Maciej,

Database.HDBC.getTables works fine here (XP, ghc 6.10.2, HDBC-2.1.0, 
HDBC-ODBC-2.1.0.0) - it gives me the list of all tablenames, as 
intended. Which HDBC version do you use?


best regards,
daniel


Maciej Podgurski schrieb:
Does Database.HDBC.getTables work for you? I successfully created a 
new table and selected data from a database but getTables always 
returns an empty list (what is not a big problem since a query show 
tables works fine).


Besh wishes,
Maciej

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


[Haskell-cafe] hs-dotnet users?

2009-06-19 Thread GüŸnther Schmidt

Hi all,

I'm just touching base with Sigbjorns hs-dotnet package.

Are there other users of this package out there who would like to share 
their experience?


Günther

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


[Haskell-cafe] Getting my mind around UArray - STUArray conversion

2009-06-19 Thread Scott Michel
I'm trying to get my mind around how to thaw and then freeze a UArray.
Theoretically, what I've written below should be a no-op, but I keep
getting typing errors that I can't figure out. GHCI 6.10.3 says:

Couldn't match expected type `UArray ix a'
   against inferred type `ST s (STUArray s ix1 e)'
In the first argument of `(=)', namely
`(unsafeThaw mem :: ST s (STUArray s ix e))'
In the expression:
  (unsafeThaw mem :: ST s (STUArray s ix e))
=
  (\ mmem - unsafeFreeze mmem)
In the definition of `wombat':
wombat val idx mem
= (unsafeThaw mem :: ST s (STUArray s ix e))
=
  (\ mmem - unsafeFreeze mmem)

I'm figuring that usafeThaw with the type annotation should have given
GHIC enough clue.

Any suggestions?


-scooter
 (WOMBAT = Waste Of Money Brains And Time)

import Control.Monad;
import Control.Monad.ST;
import Data.Array.ST;
import Data.Array.Unboxed;
import Data.Array.MArray;
import Data.Word;

wombat :: (IArray UArray e, Ix ix, MArray (STUArray s) e (ST s)) = e
- ix - UArray ix e - UArray ix e
wombat val idx mem = (unsafeThaw mem :: ST s (STUArray s ix e)) =
(\mmem - unsafeFreeze mmem)
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Getting my mind around UArray - STUArray conversion

2009-06-19 Thread Dan Doel
On Friday 19 June 2009 9:43:29 pm Scott Michel wrote:
 wombat :: (IArray UArray e, Ix ix, MArray (STUArray s) e (ST s)) = e
 - ix - UArray ix e - UArray ix e
 wombat val idx mem = (unsafeThaw mem :: ST s (STUArray s ix e)) =
 (\mmem - unsafeFreeze mmem)

Based on the error message and dealing with this sort of thing before, your 
problem is that when you say:

  :: ST s (STUArray s ix e)

the s, ix and e there aren't the same as they are in the signature of wombat. 
To make them the same, you need the ScopedTypeVariables extension, and to make 
wombat's signature:

  wombat :: forall e ix s. ...

where the dots are your current signature.

It's possible you'll still have errors, but that will solve the one in your 
mail.

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


Re: [Haskell-cafe] Getting my mind around UArray - STUArray conversion

2009-06-19 Thread Daniel Fischer
Am Samstag 20 Juni 2009 03:51:08 schrieb Dan Doel:
 On Friday 19 June 2009 9:43:29 pm Scott Michel wrote:
  wombat :: (IArray UArray e, Ix ix, MArray (STUArray s) e (ST s)) = e
  - ix - UArray ix e - UArray ix e
  wombat val idx mem = (unsafeThaw mem :: ST s (STUArray s ix e)) =
  (\mmem - unsafeFreeze mmem)

 Based on the error message and dealing with this sort of thing before, your
 problem is that when you say:

   :: ST s (STUArray s ix e)

 the s, ix and e there aren't the same as they are in the signature of
 wombat. To make them the same, you need the ScopedTypeVariables extension,
 and to make wombat's signature:

   wombat :: forall e ix s. ...

 where the dots are your current signature.

 It's possible you'll still have errors, but that will solve the one in your
 mail.

 -- Dan

No, only part of it. Another part is

unsafeFreeze :: (Ix i, MArray a e m, IArray b e) = a i e - m (b i e)

so 
unsafeThaw arr = unsafeFreeze
lives in a monad, here (ST s) and to get the type he wants, he has to wrap it 
in runST.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Getting my mind around UArray - STUArray conversion

2009-06-19 Thread Dan Doel
Oops, I replied too hastily.

What I wrote in my first mail is a problem, as witnessed by the ix and ix1 
in the error message. However, it isn't the main error. The main error is that 
you have a monadic expression, with type something like:

ST s (UArray ix e)

but the return type of your function is:

UArray ix e

To make a no-op you need to add a runST, something like:

runST (unsafeThaw mem = unsafeFreeze)

If you need to annotate 'unsafeThaw mem', that's where the ScopedTypeVariables 
will come in. However, there's also an issue that mentioning 's' in the type 
of wombat won't work with the runST, which may be a problem with the MArray 
constraint (and I'm not sure what to do about that off the top of my head; 
I've not worked with STUArray in a while, so you may be constructing an 
unresolvable ambiguity).

Sorry for the confusion.

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


Re: [Haskell-cafe] Confusion on the third monad law when using lambda abstractions

2009-06-19 Thread wren ng thornton

Hans van Thiel wrote:

On Wed, 2009-06-17 at 21:26 -0500, Jake McArthur wrote:

Jon Strait wrote:

I'm reading the third (bind associativity) law for monads in this form:

m = (\x - k x = h)  =  (m = k) = h

Arguably, that law would be better stated as:

 (h = k) = m  =  h = (k = m)

This wouldn't be so unintuitive.
Hi, 
The only place I've ever seen Kleisli composition, or its flip, used is

in demonstrating the monad laws. Yet it is so elegant and, even having
its own name, it must have some practical use. Do you, or anybody else,
have some pointers?


import Prelude hiding   (mapM)
import Data.Traversable (mapM)
import Control.Monad((=))
newtype Fix f = Fix { unFix :: f (Fix f) }


cata  phi  = phi   .   fmap (cata  phi)  . unFix

cataM phiM = phiM = (mapM (cataM phiM) . unFix)


ana   psi  =Fix . fmap (ana  psi).  psi

anaM  psiM = (liftM Fix . mapM (anaM psiM)) = psiM


etc. It's great for anyone who enjoys point-free style but wants to work 
with monads.


--
Live well,
~wren
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe