Re: [Haskell-cafe] MySQL and Haskell on Windows

2010-04-29 Thread Maciej Podgurski

Hi,

some time ago I've had similar problems making MySQL work on Windows, 
and I wrote a post to haskell-cafe how I finally fixed them [1]. Maybe 
it helps you to solve your problems. I'm still getting linker errors 
when using hsql-mysql [2], so if you're going to use it and run into the 
same errors, but are able to fix them -- please let me know!


Best wishes,
Maciej


[1] http://www.mail-archive.com/haskell-cafe@haskell.org/msg61265.html
[2] http://www.mail-archive.com/haskell-cafe@haskell.org/msg71670.html


gladst...@gladstein.com wrote:

cabal install hdbc-mysql almost works on windows, but errors because the
mysql_config command isn't part of the windows MySQL install.

Has anyone been able to get a Haskell interface to MySql going on
Windows, either directly or via odbc? 


cabal install haskelldb-hsql-odbc fails because it can't find an 'odbc'
library. There are any number of odbc dll's installed by the MySQL odbc
connector, but they all have slightly different names.

As always, a precompiled binary would be preferable but I'm happy to
compile stuff under Cygwin or MINGW if need be. 

Thanks in advance for your help. 


___
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] Happstack/Apache configuration problem

2010-03-18 Thread Maciej Podgurski

Hi,

I'm not sure if this is the right place to ask because the problem may 
lay in my Apache or system configuration.


I use the Apache proxy module to forward a HTTP request from port 80 to 
a Happstack application listening on port 8000 via `ProxyPass / 
http://localhost:8000/' on Windows XP. When calling http://my_domain in 
the browser, I get `503 service temporarily unavailable' and in the 
apache logs `proxy: HTTP: attempt to connect to 127.0.0.1:8000 
(localhost) failed'. So I tried to access http://127.0.0.1:8000 manually 
in the browser but got a connection error, while http://[::1]:8000/ 
works perfectly and displays the content returned from the Happstack 
application.


Maybe I'm wrong, but isn't the problem here that Happstack only accepts 
IPv6 addresses, while Apache forwards an IPv4 request?



Best wishes,

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


Re: [Haskell-cafe] installing Network on windows

2010-03-17 Thread Maciej Podgurski

Am 17.03.2010 21:17 schrieb Andrew Coppin:

gladst...@gladstein.com wrote:
I need some advice on the most straightforward way to install the 
Network package on Windows. I can install Cywgin if that's what it 
takes. Thanks in advance.
 
cabal install network

Resolving dependencies...
Configuring network-2.2.1.7...
cabal: Error: some packages failed to install:
network-2.2.1.7 failed during the configure step. The exception was:
sh: runGenProcess: does not exist (No such file or directory)


Looks like it wants to run sh (i.e., the Borne Shell), which 
obviously doesn't exist on Windows. Now I'm sure some kind soul 
somewhere has probably compiled a Win32 binary for it, but I would 
suggest that the build will just immediately trip over again because 
some *other* Unix-only tool isn't available.


How to fix? Well, I'm guessing you'll be forced to install some kind 
of Unix emulation layer such as Cygwin. I don't have any expertise of 
such things...


You can also use MSYS/MinGW, I prefer this to Cygwin.

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


Re: [Haskell-cafe] Problems linking hsql-mysql

2010-02-24 Thread Maciej Podgurski

Hi,

no, it's absolutely not urgent. I'm just in early stage with building a 
Happstack webpage and testing via GHCi works fine.


The problem occurs on a Windows XP machine with hsql-1.7.1, 
hsql-mysql-1.7.1, GHC-6.10.4 and MySQL Server 5.1. Last year I posted an 
instruction on how I got hsql-mysql running (see 
http://www.mail-archive.com/haskell-cafe@haskell.org/msg61265.html), the 
changes for the new GHC version where exactly the same. To replicate the 
error, just do an import Database.HSQL.MySQL and build the file via ghc 
--make.


As far as I remember this worked with GHC-6.8.3, but I'm not quite sure. 
Let me know if you need additional informationen.



Thanks for help,

Maciej


Am 24.02.2010 01:07 schrieb Nick Rudnick:

Hi Maciej,

I will try to reproduce the error -- could you send me your both 
*.cabal files (for hsql  hsql-mysql), if you have changed anything, 
and your system configuration.


Is this extremely urgent? I ask this, as these days exactly the end 
phase of the projects of about 100 beginner Haskell students, which I 
am the one to look after. So I am in a little of slow motion regarding 
other things... ;-)


But in case you are in emergency, please let me know... At first 
sight, I would say it looks like a configuration problem... ;-)


Cheers,

   Nick

Maciej Podgurski wrote:

Hi,

I have problems linking a simple test program that imports 
Database.HSQL.MySQL via ghc --make Test.hs. The error only occurs 
when importing this module of hsql-mysql-1.7.1. I pasted the building 
output here: http://hpaste.org/fastcgi/hpaste.fcgi/view?id=22911 
(actually it was even longer but hpaste only takes 30k).


When I do ghc -e main Test.hs or starting it from GHCi, everything 
works fine and no errors occur. So I guess all needed .lib files are 
there but GHC can't find them when linking (adding the flag -Lpath 
to mysql/lib/opt doesn't help). Anyone an idea?



Best wishes,

Maciej
___
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] Problems linking hsql-mysql

2010-02-23 Thread Maciej Podgurski

Hi,

I have problems linking a simple test program that imports 
Database.HSQL.MySQL via ghc --make Test.hs. The error only occurs when 
importing this module of hsql-mysql-1.7.1. I pasted the building output 
here: http://hpaste.org/fastcgi/hpaste.fcgi/view?id=22911 (actually it 
was even longer but hpaste only takes 30k).


When I do ghc -e main Test.hs or starting it from GHCi, everything works 
fine and no errors occur. So I guess all needed .lib files are there but 
GHC can't find them when linking (adding the flag -Lpath to 
mysql/lib/opt doesn't help). Anyone an idea?



Best wishes,

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


[Haskell-cafe] Cabal update problem

2010-02-19 Thread Maciej Podgurski

Hi,

after updating to cabal-install-0.8.0/Cabal-1.8.0.2 with GHC 6.10.4, I 
always get an error when updating the package list:


cabal update
   Downloading the latest package list from hackage.haskell.org
   cabal: Codec.Compression.Zlib: premature end of compressed stream

Is there a way to fix this without rebuilding from the latest darcs repo?


Best wishes,

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


Re: [Haskell-cafe] Re: Cabal update problem

2010-02-19 Thread Maciej Podgurski

Am 19.02.2010 12:57 schrieb Christian Maeder:

Maciej Podgurski schrieb:
  

Hi,

after updating to cabal-install-0.8.0/Cabal-1.8.0.2 with GHC 6.10.4, I
always get an error when updating the package list:

cabal update
   Downloading the latest package list from hackage.haskell.org
   cabal: Codec.Compression.Zlib: premature end of compressed stream

Is there a way to fix this without rebuilding from the latest darcs repo?



Does removing ~/.cabal/packages/hackage.haskell.org/00-index.tar.gz
help? Did you overwrite your old cabal-binary. If not, does this binary
also fail?
  


Removing this file doesn't help. The old version was cabal-install-0.6.2 
+ Cabal-1.6.0.2 with GHC 6.10.3. I deleted it because I changed to GHC 
6.10.4, but it worked fine 2 days ago.



(I think everything under ~/.cabal/packages/hackage.haskell.org can be
savely deleted and will be downloaded again if needed.)

Which architecture you're on?
  


Windows XP


Best wishes,

Maciej


Cheers Christian

  

Best wishes,

Maciej


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


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


Re: [Haskell-cafe] Cabal update problem

2010-02-19 Thread Maciej Podgurski

Am 19.02.2010 13:55 schrieb Valery V. Vorotyntsev:

after updating to cabal-install-0.8.0/Cabal-1.8.0.2 with GHC 6.10.4, I
always get an error when updating the package list:

   cabal update
  Downloading the latest package list from hackage.haskell.org
  cabal: Codec.Compression.Zlib: premature end of compressed stream



Would you please send the output of `cabal update -v3' command?

  


Downloading the latest package list from hackage.haskell.org
Sending:
GET /packages/archive/00-index.tar.gz HTTP/1.1
Host: hackage.haskell.org
User-Agent: cabal-install/0.8.0
Creating new connection to hackage.haskell.org
Received:
HTTP/1.1 200 OK
Date: Fri, 19 Feb 2010 13:28:11 GMT
Server: Apache/2.2.9 (Debian) mod_python/3.3.1 Python/2.5.2
Last-Modified: Fri, 19 Feb 2010 11:18:51 GMT
ETag: 1bda0c4-167869-47ff23f7fdcc0
Accept-Ranges: bytes
Content-Length: 1472617
Content-Type: application/x-tar
Content-Encoding: x-gzip
Downloaded to C:\Dokumente und
Einstellungen\Maciej\Anwendungsdaten\cabal\packages\hackage.haskell.org\00-index.tar.gz
cabal: Codec.Compression.Zlib: premature end of compressed stream


Best wishes,

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


Re: [Haskell-cafe] Re: Cabal update problem

2010-02-19 Thread Maciej Podgurski

Am 19.02.2010 15:29 schrieb Christian Maeder:

Sorry, I've got no further idea (except reinstalling everything).

http://hackage.haskell.org/trac/hackage/ticket/562
may be related.

Did your installation of cabal-install-0.8.0 also reinstall HTTP and
zlib packages?
  


Yes, I installed the latest versions of that packages. Now I tried to 
gradually go back to the versions before (HTTP-4000.0.9 to 4000.0.7 and 
zlib-0.5.2.0 to 0.5.0.0), without any success. Finally cabal-install 
made it at version 0.6.2, so the problem really seems to be at 
cabal-install-0.8.0.



Good luck
Christian

Maciej Podgurski schrieb:
  

Am 19.02.2010 12:57 schrieb Christian Maeder:


Maciej Podgurski schrieb:
 
  

Hi,

after updating to cabal-install-0.8.0/Cabal-1.8.0.2 with GHC 6.10.4, I
always get an error when updating the package list:

cabal update
   Downloading the latest package list from hackage.haskell.org
   cabal: Codec.Compression.Zlib: premature end of compressed stream

Is there a way to fix this without rebuilding from the latest darcs
repo?



Does removing ~/.cabal/packages/hackage.haskell.org/00-index.tar.gz
help? Did you overwrite your old cabal-binary. If not, does this binary
also fail?
  
  

Removing this file doesn't help. The old version was cabal-install-0.6.2
+ Cabal-1.6.0.2 with GHC 6.10.3. I deleted it because I changed to GHC
6.10.4, but it worked fine 2 days ago.



(I think everything under ~/.cabal/packages/hackage.haskell.org can be
savely deleted and will be downloaded again if needed.)

Which architecture you're on?
  
  

Windows XP


Best wishes,

Maciej



Cheers Christian

 
  

Best wishes,

Maciej



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

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


Re: [Haskell-cafe] Re: Cabal update problem

2010-02-19 Thread Maciej Podgurski
But the platform only includes cabal-install-0.6.2. My intention was 
getting the merge-all-package-documentation-into-single-html feature :-)



Best wishes,

Maciej


Am 19.02.2010 16:50 schrieb Bas van Gijzel:

I had the same problem on Windows XP when doing cabal install cabal-install.
I fixed it by just replacing the cabal-install executable by the old one
used in the haskell platform.

Cheers,

Bas

On 19 February 2010 16:11, Maciej Podgurski maciej.podgur...@googlemail.com

wrote:



Am 19.02.2010 15:29 schrieb Christian Maeder:

 Sorry, I've got no further idea (except reinstalling everything).

http://hackage.haskell.org/trac/hackage/ticket/562
may be related.

Did your installation of cabal-install-0.8.0 also reinstall HTTP and
zlib packages?



Yes, I installed the latest versions of that packages. Now I tried to
gradually go back to the versions before (HTTP-4000.0.9 to 4000.0.7 and
zlib-0.5.2.0 to 0.5.0.0), without any success. Finally cabal-install made it
at version 0.6.2, so the problem really seems to be at cabal-install-0.8.0.


 Good luck

Christian


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] Virus alert while installing happstack

2010-02-14 Thread Maciej Podgurski

Hi,

I tried to install happstack via cabal install happstack on my WinXP 
system. While installation progress, my anti-virus software (Avira 
AntiVir) warned me about dll_hsc_make.exe and files_hsc_make.exe to be a 
Trojan horse called TR/Dropper.Gen. It's a bit confusing to get a 
virus alert while installing Haskell packages. Has anyone experienced 
this problem? And can I trust these files to be harmless?



Besh wishes,

Maciej

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

2009-06-18 Thread Maciej Podgurski

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
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] self-referential data

2008-08-09 Thread Maciej Podgurski

brian wrote:

On Sat, Aug 9, 2008 at 5:18 PM, Brent Yorgey [EMAIL PROTECTED] wrote:

The problem is that BString is not a type, it is a data constructor.


I know.


You could use M.Map BValue BValue, but of course that's probably not
what you want either.


Right. That wouldn't be according to spec either.


What's wrong with just using 'String' as the Map key?


It seems wrong. Yeah, it's just a String, but we're being all abstract
because that's better practice. It happens that when you parse
bencoded data, the length of the string is given. Maybe I want to
store that in BString, too.

But mainly I want to know how to think about it differently so that I
know what to do when it comes up again and actually matters.


What about using a type parameter:

data BValue bString = BString bString
| BIntegerInteger
| BList   [BValue bString]
| BDictionary (Map bString (BValue bString))


Regards,
Maciej

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


[Haskell-cafe] Return user state in Parsec

2008-05-21 Thread Maciej Podgurski

Hi,

I'm currently writing a parser using the Parsec library. What I want is 
to store the order of each subparser called in a user state. So every 
single parser will be marked with a label that is stored in a special 
treelike structure when the parser is run.


My problem is to return the last state of this structure when a parse 
error occurred. This information shall be used to display a kind of 
stack trace showing the order of the parser calls for debug purposes. 
Any ideas how to achieve this?


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


[Haskell-cafe] Parsec: Transforming between parsers with different token streams

2008-02-11 Thread Maciej Podgurski

Hi,

I'm writing a simple parser for a line-oriented language using Parsec. A 
group of lines is parsed by a parser that tokens are of type String. 
Each token is again parsed by a parser that tokens are of type Char 
(i.e. this parser has the Parsec type Parser a).


Now I wrote a transforming function that converts a char parser to a 
line parser by running the char parser on the current token of the line 
parser and accepting the token, if the char parser did not fail:


type LineParser = GenParser String () a

toLineParser :: Parser a - LineParser a
toLineParser p = tokenPrim showLine nextPos testLine
? how to get the inner error message???
where
showLine l = \:  ++ l ++ \
nextPos pos t rest = incSourceLine pos 1
testLine l = case parse p  l of
 Left msg   - Nothing
 Right res  - Just res

My problem is to extract the possible error message of the inner char 
parser (msg) and pass it to the outer line parser. Maybe using tokenPrim 
is no the best approach here. Someone how can help me with that problem?



Besh wishes,

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