Re: [Haskell-cafe] [Haskell] Linker flags for foreign export.

2011-03-08 Thread Max Bolingbroke
Hi Jason,

On 8 March 2011 05:28, Jason Dusek jason.du...@gmail.com wrote:
    gcc -g -Wall -O2 -fPIC -Wall -o import \
      -I/usr/lib/ghc-6.12.1/include/ \
      import.c exports.so

In my experience, the easiest way to do this is to use gcc to build
object files from C source files, and then specify those object files
on the ghc command line in order to get GHC to do the linking step.
This will deal with linking in the correct RTS and, if you specify
appropriate -package flags, dependent packages as well.

If you want a C main function then see user guide section 8.2.1.1 at
http://www.haskell.org/ghc/docs/latest/html/users_guide/ffi-ghc.html.

Cheers,
Max

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


Re: [Haskell-cafe] Questions on list administration

2011-03-08 Thread Ketil Malde
Karthick Gururaj karthick.guru...@gmail.com writes:

 You are not allowed to post to this mailing list, and your message has
 been automatically rejected.  If you think that your messages are
 being rejected in error, contact the mailing list owner at
 haskell-cafe-ow...@haskell.org.

As it says on the Google about page, only members may post to the
list.  Ideally, the Google groups interface should add you as a member,
or otherwise perform some magic to allow you to post, but perhaps this
requires more than sufficiently advanced technology...

 Funny thing is, google reports that my post was successful, and my
 post was visible on google groups even after I signed out from my
 google account.

Possibly, posts via Google goes via a cache?

 Can I ask a couple of changes be done to help others like me?
 a. In google groups -
 https://groups.google.com/group/haskell-cafe/about - add a link to
 the haskell.org - Mailing lists for more info.

I don't know how Google maintains this page, and I'm not sure whoever is
the list owner does either.  If you can find out how to modify this, I'm
sure nobody would object to adding that information.

 b. Let users join from google groups interface, or if this is not
 possible, mention that in the about page

Yes, but this, too, is an issue with Google groups, and not the Haskell
mailing lists.

 c. Change the contents of the reject email (reproduced above) to
 include the following:
 If you want to subscribe to the Haskell Cafe mailing list, please
 visit http://www.haskell.org/mailman/listinfo/haskell-cafe;

Well, you don't have to use the web interface to subscribe, but some
information like that would be useful, and I believe this is easy to set
up (we're using Mailman, I believe?).

-k
-- 
If I haven't seen further, it is by standing in the footprints of giants

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


Re: [Haskell-cafe] Haskell IDE

2011-03-08 Thread Alberto G. Corona
The lazy path:

You can also just download  and install the binaries for your platform at
http://leksah.org/download.html.

From experience, I guess that most if not all of the capabilities will  work
with your version of GHC (except some features more tightly integrated with
the compiler, such is GHCI.


2011/3/7 Daniel Fischer daniel.is.fisc...@googlemail.com

 On Monday 07 March 2011 16:08:01, Alberto G. Corona wrote:
  I use leksah, and I want to say thanks to the people that maintain it. I
  want also to encourage them to continuing its valuable work.
 
  from the last release of Leksah, I particulary appreciate its:
 
  Multiplatform support
  Ease of installation in all platforms including windows
  capability to works with many cabal packages in a single workspace
  its detection of dependencies and rebuilding of the affected packages
  Integration of GHCI and the GHCI debugger
  integrated building of documentation
  referencing and navigation trough the  source of the installed packages
  and of course all the other traditional IDE capabilities

 That sounds nice, so I thought I'd try out leksah again.

 Unfortunately, the dependencies rule out GHC-7 (base  4.3, Cabal  1.9,
 containers  0.4 were the ones that sprang to the eyes immediately).
 Bummer

 Maybe someone could try relaxing the bounds and build it with GHC-7, and -
 if it works - upload a new version?
 (I could try if I get a go-ahead from Hamish or Jürgen)

 ___
 Leksah mailing list
 lek...@projects.haskell.org
 http://projects.haskell.org/cgi-bin/mailman/listinfo/leksah

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


Re: [Haskell-cafe] have anyone tried GHC 7.0.2

2011-03-08 Thread Christian Maeder
What does ghc-pkg list and ghc-pkg check say?

Cabal-1.10.1.0, directory-1.1.0.0 and process-1.0.1.5 should be there
after installation of GHC 7.0.2. (I've actually installed
cabal-install-0.10.0 using an older cabal, but that does not work on
macs and may not be the recommended way.)

I think I've used
http://www.galois.com/~dons/code/2011.2.0.0/haskell-platform-2011.2.0.0.tar.gz
from http://www.galois.com/~dons/code/2011.2.0.0/, but they are not
official yet.

C.

Am 08.03.2011 19:20, schrieb Qi Qi:
 Hi,
 
 After I installed GHC 7.0.2 and cabal-install 0.10.0 using Cabal library
 1.10.1, I found that some package failed to install. For example like
 Happy, I got the following error:
 
 cabal install happy
 Resolving dependencies...
 command line: cannot satisfy -package Cabal-1.10.1.0: 
 Cabal-1.10.1.0-64e8f05722ea5bbdf07df2e5a3491105 is unusable due to 
 missing or recursive dependencies:
   directory-1.1.0.0-85d1d0f9d96dffdacf64f3cc6fba6f2f 
 process-1.0.1.5-4cab1bf0666275ac101dd48c7565b64c
 (use -v for more information)
 cabal: Error: some packages failed to install:
 happy-1.18.6 failed during the configure step. The exception was:
 ExitFailure 1
 
 Besides happy package, some other packages like ghc-mod, hmatrix also
 failed to install. Does anyone else have the same issue after installed
 ghc 7.0.2? 
 
 By the way, does anyone hear anything about Haskell-platform 2011.2 ?
 
 
 Thanks!
 

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


Re: [Haskell-cafe] ANNOUNCE: cinvoke 0.1 released

2011-03-08 Thread Remi Turk
On Tue, Mar 08, 2011 at 01:15:26AM +, Felipe Almeida Lessa wrote:
 On Mon, Mar 7, 2011 at 6:32 PM, Remi Turk rt...@science.uva.nl wrote:
  - If you need to pass C structs (by value), you'll have to use
   libffi: cinvoke doesn't support them at all.
 
 What about CInvStructure[1]?  I was just glancing at the documentation
 when I saw this.

That's a part of cinvoke I have not implemented (and probably
won't, just like callbacks and a few other things, at least until
there is some demand for them).
However, the CInvStructure functions are used to construct
descriptions and instances of C structures at run-time. (think
alignment issues...)
Passing structures to functions using cinvoke can only be done
using pointers though.[1]

Cheers, Remi

[1] 
http://www.nongnu.org/cinvoke/doc/cinvoke_8h.html#4d288cacc9bde484cad7d8ed1b76c1a5

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


[Haskell-cafe] makeTokenParser + LanguageDef

2011-03-08 Thread Hauschild, Klaus (EXT)
Hi Haskellers,

is there a fine tutorial for building a parser with parsecs (3.*) 
makeTokenParser and LanguageDef stuff?

Klaus

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


Re: [Haskell-cafe] Overlaping Parsec rules

2011-03-08 Thread Hauschild, Klaus (EXT)
Hi Christian,

my version of parseList works currently strange.
The input {2\n2} will be parsed fine, but something like { } or so fails 
with 'expecting space or }'.

The redefinition of space is not necessary, it was copied from another tutorial 
code. How I write a version of parseGml that get gml token separated by any 
white space (space, tab, newline)?

Thanks

-Ursprüngliche Nachricht-
Von: Christian Maeder [mailto:christian.mae...@dfki.de] 
Gesendet: Montag, 7. März 2011 14:18
An: Hauschild, Klaus (EXT)
Cc: haskell-cafe@haskell.org
Betreff: Re: Overlaping Parsec rules

Am 07.03.2011 13:48, schrieb Hauschild, Klaus (EXT):
 Thanks Christian,
 
 I adapted the keyword parser and now n - negi does not occur.
 
 But there are still other problems to solve. If I activate the parseFunction 
 the parser will answer to fact.gml unexpected end of input, expecting space 
 or }.

Your redefinition of spaces (= skipMany1 space) is problematic and:

 parseList = sepBy parseGml' spaces

Allow for the original (optional) spaces after parseGml':

  parseGml'' = liftM2 const parseGml' spaces

  parseList = many parseGml''

C.

P.S. why do you call? many (noneOf )

   manyTill anyChar newline

   or just: many (noneOf \n)

   (a trailing newline will be skipped by spaces)

 
 Any ideas?
 
 
 -Ursprüngliche Nachricht-
 Von: Christian Maeder [mailto:christian.mae...@dfki.de] 
 Gesendet: Montag, 7. März 2011 12:23
 An: Hauschild, Klaus (EXT)
 Cc: haskell-cafe@haskell.org
 Betreff: Re: Overlaping Parsec rules
 
 You should parse keywords using:
 
 keyword s = try (string s)  notFollowedBy (letter | digit)
 
 C.
 
 Am 07.03.2011 11:34, schrieb Hauschild, Klaus (EXT):
 Hi,
  
 to solve this ICFP task _http://www.cs.cornell.edu/icfp/task.htm_ I'm
 currnetly working on the parser. With the hint from Thu (reading Phillip
 Wadlers monadic parser paper) and consulting
 _http://en.wikibooks.org/wiki/Write_Yourself_a_Scheme_in_48_Hours/Parsing_
 I produce a first working version of the parser.
 After this great moment I completed the token definition and near all
 parsing rules. For the complete code have a look at
 _http://code.google.com/p/hgmltracer/source/browse/#svn%2Ftrunk%2FhGmlTracer_
  
 data GmlToken =

 -- structures

 FunctionToken TokenSequence |

 ArrayToken TokenSequence|

 -- control operators

 ApplyToken  |

 IfToken |

 -- number operators

 AddiToken   |

 AddfToken   |

 ACosToken   |

 ASinToken   |

 ClampfToken |

 CosToken|

 DiviToken   |

 DivfToken   |

 EqiToken|

 EqfToken|

 FloorToken  |

 FracToken   |

 LessiToken  |

 LessfToken  |

 ModiToken   |

 MuliToken   |

 MulfToken   |

 NegiToken   |

 NegfToken   |

 ToRealToken |

 SinToken|

 SqrtToken   |

 SubiToken   |

 SubfToken   |

 -- points

 GetXToken   |

 GetYToken   |

 GetZToken   |

 PointToken  |

 -- arrays

 GetToken|

 LengthToken |

 -- environment

 IdentifierToken String  |

 BinderToken String  |

 -- types

 BoolToken Bool  |

 IntToken Int|

 RealToken Double|

 StringToken String  deriving Show  
  
 And
  
 parseGml :: String - [GmlToken]

 parseGml input = case parse parseList gml input of

 Left err - error (Parse error:  ++ (show err))

 Right gml - gml



 parseList = sepBy parseGml' spaces



 parseGml' =

 -- structures

 --parseFunction

 --| parseArray

 -- control operators

 

Re: [Haskell-cafe] I think I've found a regression in Haskell Platform, but what do I do next?

2011-03-08 Thread Nick Frolov
On Tue, 2011-02-22 at 07:12 -0800, Johan Tibell wrote:
 On Tue, Feb 22, 2011 at 7:08 AM, Nick Frolov n...@mkmks.org wrote:
  Something has definitely changed between these two ghc versions. Since
  I've spent considerable amount of time on finding a workaround for the
  problem, I'd like to file a real bug report, but I'm not completely sure
  where to do it because there are several pieces of software involved
  (ghc itself, 'process', 'satchmo' and 'minisat2' SAT solver). Could
  somebody guide me please?
 
 There were a few I/O manager related bugs, one related to forking
 processes. These should be fixed in GHC 7.0.2 (and the next HP
 release), due soon.

I've just reproduced the bug with GHC 7.0.2. It seems that it still has
to be reported, but, again, I have no idea if it's caused by a possible
regression in GHC. It could be that one of the libraries relies on the
wrong behaviour of GHC 6.12.*, right?


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


Re: [Haskell-cafe] Overlaping Parsec rules

2011-03-08 Thread Christian Maeder
Am 08.03.2011 12:30, schrieb Hauschild, Klaus (EXT):
 Hi Christian,
 
 my version of parseList works currently strange.
 The input {2\n2} will be parsed fine, but something like { } or so fails 
 with 'expecting space or }'.

You must skip (possible) spaces after {, too. (Actually after every
lexeme.)

C.

 
 The redefinition of space is not necessary, it was copied from another 
 tutorial code. How I write a version of parseGml that get gml token separated 
 by any white space (space, tab, newline)?
 
 Thanks
 
 -Ursprüngliche Nachricht-
 Von: Christian Maeder [mailto:christian.mae...@dfki.de] 
 Gesendet: Montag, 7. März 2011 14:18
 An: Hauschild, Klaus (EXT)
 Cc: haskell-cafe@haskell.org
 Betreff: Re: Overlaping Parsec rules
 
 Am 07.03.2011 13:48, schrieb Hauschild, Klaus (EXT):
 Thanks Christian,

 I adapted the keyword parser and now n - negi does not occur.

 But there are still other problems to solve. If I activate the parseFunction 
 the parser will answer to fact.gml unexpected end of input, expecting space 
 or }.
 
 Your redefinition of spaces (= skipMany1 space) is problematic and:
 
  parseList = sepBy parseGml' spaces
 
 Allow for the original (optional) spaces after parseGml':
 
   parseGml'' = liftM2 const parseGml' spaces
 
   parseList = many parseGml''
 
 C.
 
 P.S. why do you call? many (noneOf )
 
manyTill anyChar newline
 
or just: many (noneOf \n)
 
(a trailing newline will be skipped by spaces)
 

 Any ideas?


 -Ursprüngliche Nachricht-
 Von: Christian Maeder [mailto:christian.mae...@dfki.de] 
 Gesendet: Montag, 7. März 2011 12:23
 An: Hauschild, Klaus (EXT)
 Cc: haskell-cafe@haskell.org
 Betreff: Re: Overlaping Parsec rules

 You should parse keywords using:

 keyword s = try (string s)  notFollowedBy (letter | digit)

 C.

 Am 07.03.2011 11:34, schrieb Hauschild, Klaus (EXT):
 Hi,
  
 to solve this ICFP task _http://www.cs.cornell.edu/icfp/task.htm_ I'm
 currnetly working on the parser. With the hint from Thu (reading Phillip
 Wadlers monadic parser paper) and consulting
 _http://en.wikibooks.org/wiki/Write_Yourself_a_Scheme_in_48_Hours/Parsing_
 I produce a first working version of the parser.
 After this great moment I completed the token definition and near all
 parsing rules. For the complete code have a look at
 _http://code.google.com/p/hgmltracer/source/browse/#svn%2Ftrunk%2FhGmlTracer_
  
 data GmlToken =

 -- structures

 FunctionToken TokenSequence |

 ArrayToken TokenSequence|

 -- control operators

 ApplyToken  |

 IfToken |

 -- number operators

 AddiToken   |

 AddfToken   |

 ACosToken   |

 ASinToken   |

 ClampfToken |

 CosToken|

 DiviToken   |

 DivfToken   |

 EqiToken|

 EqfToken|

 FloorToken  |

 FracToken   |

 LessiToken  |

 LessfToken  |

 ModiToken   |

 MuliToken   |

 MulfToken   |

 NegiToken   |

 NegfToken   |

 ToRealToken |

 SinToken|

 SqrtToken   |

 SubiToken   |

 SubfToken   |

 -- points

 GetXToken   |

 GetYToken   |

 GetZToken   |

 PointToken  |

 -- arrays

 GetToken|

 LengthToken |

 -- environment

 IdentifierToken String  |

 BinderToken String  |

 -- types

 BoolToken Bool  |

 IntToken Int|

 RealToken Double|

 StringToken String  deriving Show  
  
 And
  
 parseGml :: String - [GmlToken]

 parseGml input = case parse parseList gml input of

 Left err - error (Parse error:  ++ (show err))

 Right gml - gml



 parseList = sepBy parseGml' spaces



Re: [Haskell-cafe] Overlaping Parsec rules

2011-03-08 Thread Christian Maeder
In
http://code.google.com/p/hgmltracer/source/browse/trunk/hGmlTracer/src/Gml/Parse.hs
I see identifier - many (noneOf  ). You should at least consume one
character by using many1! This also allows to call many parseGml''
later.

C.

Am 08.03.2011 12:30, schrieb Hauschild, Klaus (EXT):
 Hi Christian,
 
 my version of parseList works currently strange.
 The input {2\n2} will be parsed fine, but something like { } or so fails 
 with 'expecting space or }'.
 
 The redefinition of space is not necessary, it was copied from another 
 tutorial code. How I write a version of parseGml that get gml token separated 
 by any white space (space, tab, newline)?
 
 Thanks
 
 -Ursprüngliche Nachricht-
 Von: Christian Maeder [mailto:christian.mae...@dfki.de] 
 Gesendet: Montag, 7. März 2011 14:18
 An: Hauschild, Klaus (EXT)
 Cc: haskell-cafe@haskell.org
 Betreff: Re: Overlaping Parsec rules
 
 Am 07.03.2011 13:48, schrieb Hauschild, Klaus (EXT):
 Thanks Christian,

 I adapted the keyword parser and now n - negi does not occur.

 But there are still other problems to solve. If I activate the parseFunction 
 the parser will answer to fact.gml unexpected end of input, expecting space 
 or }.
 
 Your redefinition of spaces (= skipMany1 space) is problematic and:
 
  parseList = sepBy parseGml' spaces
 
 Allow for the original (optional) spaces after parseGml':
 
   parseGml'' = liftM2 const parseGml' spaces
 
   parseList = many parseGml''
 
 C.
 
 P.S. why do you call? many (noneOf )
 
manyTill anyChar newline
 
or just: many (noneOf \n)
 
(a trailing newline will be skipped by spaces)
 

 Any ideas?


 -Ursprüngliche Nachricht-
 Von: Christian Maeder [mailto:christian.mae...@dfki.de] 
 Gesendet: Montag, 7. März 2011 12:23
 An: Hauschild, Klaus (EXT)
 Cc: haskell-cafe@haskell.org
 Betreff: Re: Overlaping Parsec rules

 You should parse keywords using:

 keyword s = try (string s)  notFollowedBy (letter | digit)

 C.

 Am 07.03.2011 11:34, schrieb Hauschild, Klaus (EXT):
 Hi,
  
 to solve this ICFP task _http://www.cs.cornell.edu/icfp/task.htm_ I'm
 currnetly working on the parser. With the hint from Thu (reading Phillip
 Wadlers monadic parser paper) and consulting
 _http://en.wikibooks.org/wiki/Write_Yourself_a_Scheme_in_48_Hours/Parsing_
 I produce a first working version of the parser.
 After this great moment I completed the token definition and near all
 parsing rules. For the complete code have a look at
 _http://code.google.com/p/hgmltracer/source/browse/#svn%2Ftrunk%2FhGmlTracer_
  
 data GmlToken =

 -- structures

 FunctionToken TokenSequence |

 ArrayToken TokenSequence|

 -- control operators

 ApplyToken  |

 IfToken |

 -- number operators

 AddiToken   |

 AddfToken   |

 ACosToken   |

 ASinToken   |

 ClampfToken |

 CosToken|

 DiviToken   |

 DivfToken   |

 EqiToken|

 EqfToken|

 FloorToken  |

 FracToken   |

 LessiToken  |

 LessfToken  |

 ModiToken   |

 MuliToken   |

 MulfToken   |

 NegiToken   |

 NegfToken   |

 ToRealToken |

 SinToken|

 SqrtToken   |

 SubiToken   |

 SubfToken   |

 -- points

 GetXToken   |

 GetYToken   |

 GetZToken   |

 PointToken  |

 -- arrays

 GetToken|

 LengthToken |

 -- environment

 IdentifierToken String  |

 BinderToken String  |

 -- types

 BoolToken Bool  |

 IntToken Int|

 RealToken Double|

 StringToken String  deriving Show  
  
 And
  
 parseGml :: String - [GmlToken]

 parseGml input = case parse parseList gml input of


Re: [Haskell-cafe] ANNOUNCE: cinvoke 0.1 released

2011-03-08 Thread Gábor Lehel
On Sun, Mar 6, 2011 at 2:38 PM, Remi Turk rt...@science.uva.nl wrote:
 I am happy to finally announce cinvoke 0.1, a binding to the
 C library cinvoke[1], allowing functions to be loaded and called
 whose names and types are not known before run-time.

 Why?

 Sometimes you can't use the Haskell foreign function interface
 because you parse the type of the function from somewhere else,
 i.e. you're writing an interpreter for a language that has an FFI
 itself.

 What?

 The main function it exports is:

  cinvoke :: Symbol - RetType b - [Arg] - IO b

 And because code is worth a thousand words, here's a small program
 that uses libc to write a 1Gb buffer of random garbage to a file:

 module Main where

 import Foreign.CInvoke

 main = do
     cxt - newContext
     libc - loadLibrary cxt libc.so.6
     malloc - loadSymbol libc malloc
     creat  - loadSymbol libc creat
     write  - loadSymbol libc write
     free   - loadSymbol libc free
     let sz = 2^30
     buf - cinvoke malloc (retPtr retVoid)
                                     [argCSize sz]
     fd  - cinvoke creat  retCInt   [argString /tmp/test, argCUInt 0o644]
     n   - cinvoke write  retCSize  [argCInt fd, argPtr buf, argCSize sz]
     cinvoke free (retPtr retVoid) [argPtr buf]

 It hopefully works on any machine on which cinvoke works,
 but has only been tested on linux x86_64.
 As the current version of cinvoke only installs a static library,
 it does not work from GHCi at the moment (without hacking cinvoke
 to build a shared library).
 More interesting examples are included in examples/ in the
 package.

 Where?
 Hackage: http://hackage.haskell.org/package/cinvoke

 Cheers, Remi

 [1] http://www.nongnu.org/cinvoke/

Is there any information on how this (and libffi I guess) compare to
GHC's FFI in terms of performance? Is it equivalent? Once you've
loaded a function with loadSymbol and are cinvoking it with various
arguments, versus a plain foreign import of the same. (Also, I
assume cinvoke corresponds to the FFI's 'unsafe' calls, i.e. if the
function tries to call back into the GHC runtime then Bad Things will
happen, and it'll block threads on the same 'Capability' if it runs
too long?)



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




-- 
Work is punishment for failing to procrastinate effectively.

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


Re: [Haskell-cafe] Overlaping Parsec rules

2011-03-08 Thread Christian Maeder
Am 08.03.2011 12:30, schrieb Hauschild, Klaus (EXT):
 Hi Christian,
 
 my version of parseList works currently strange.
 The input {2\n2} will be parsed fine, but something like { } or so fails 
 with 'expecting space or }'.

Also } (and ], etc.) should be excluded as identifier letters.
} is the second identifier in { }. (The first one is empty.)

C.

 
 The redefinition of space is not necessary, it was copied from another 
 tutorial code. How I write a version of parseGml that get gml token separated 
 by any white space (space, tab, newline)?
 
 Thanks
 
 -Ursprüngliche Nachricht-
 Von: Christian Maeder [mailto:christian.mae...@dfki.de] 
 Gesendet: Montag, 7. März 2011 14:18
 An: Hauschild, Klaus (EXT)
 Cc: haskell-cafe@haskell.org
 Betreff: Re: Overlaping Parsec rules
 
 Am 07.03.2011 13:48, schrieb Hauschild, Klaus (EXT):
 Thanks Christian,

 I adapted the keyword parser and now n - negi does not occur.

 But there are still other problems to solve. If I activate the parseFunction 
 the parser will answer to fact.gml unexpected end of input, expecting space 
 or }.
 
 Your redefinition of spaces (= skipMany1 space) is problematic and:
 
  parseList = sepBy parseGml' spaces
 
 Allow for the original (optional) spaces after parseGml':
 
   parseGml'' = liftM2 const parseGml' spaces
 
   parseList = many parseGml''
 
 C.
 
 P.S. why do you call? many (noneOf )
 
manyTill anyChar newline
 
or just: many (noneOf \n)
 
(a trailing newline will be skipped by spaces)
 

 Any ideas?


 -Ursprüngliche Nachricht-
 Von: Christian Maeder [mailto:christian.mae...@dfki.de] 
 Gesendet: Montag, 7. März 2011 12:23
 An: Hauschild, Klaus (EXT)
 Cc: haskell-cafe@haskell.org
 Betreff: Re: Overlaping Parsec rules

 You should parse keywords using:

 keyword s = try (string s)  notFollowedBy (letter | digit)

 C.

 Am 07.03.2011 11:34, schrieb Hauschild, Klaus (EXT):
 Hi,
  
 to solve this ICFP task _http://www.cs.cornell.edu/icfp/task.htm_ I'm
 currnetly working on the parser. With the hint from Thu (reading Phillip
 Wadlers monadic parser paper) and consulting
 _http://en.wikibooks.org/wiki/Write_Yourself_a_Scheme_in_48_Hours/Parsing_
 I produce a first working version of the parser.
 After this great moment I completed the token definition and near all
 parsing rules. For the complete code have a look at
 _http://code.google.com/p/hgmltracer/source/browse/#svn%2Ftrunk%2FhGmlTracer_
  
 data GmlToken =

 -- structures

 FunctionToken TokenSequence |

 ArrayToken TokenSequence|

 -- control operators

 ApplyToken  |

 IfToken |

 -- number operators

 AddiToken   |

 AddfToken   |

 ACosToken   |

 ASinToken   |

 ClampfToken |

 CosToken|

 DiviToken   |

 DivfToken   |

 EqiToken|

 EqfToken|

 FloorToken  |

 FracToken   |

 LessiToken  |

 LessfToken  |

 ModiToken   |

 MuliToken   |

 MulfToken   |

 NegiToken   |

 NegfToken   |

 ToRealToken |

 SinToken|

 SqrtToken   |

 SubiToken   |

 SubfToken   |

 -- points

 GetXToken   |

 GetYToken   |

 GetZToken   |

 PointToken  |

 -- arrays

 GetToken|

 LengthToken |

 -- environment

 IdentifierToken String  |

 BinderToken String  |

 -- types

 BoolToken Bool  |

 IntToken Int|

 RealToken Double|

 StringToken String  deriving Show  
  
 And
  
 parseGml :: String - [GmlToken]

 parseGml input = case parse parseList gml input of

 Left err - error (Parse error:  ++ (show err))

 Right gml - gml



 

Re: [Haskell-cafe] Overlaping Parsec rules

2011-03-08 Thread Hauschild, Klaus (EXT)
Hi Christian,

Thank you for your help. Now the current version of Parse.hs 
(http://code.google.com/p/hgmltracer/source/browse/trunk/hGmlTracer/src/Gml/Parse.hs)
 works well for the test file fact.gml.

Now the last thing is parsing the different numbers (integer and float). If 
have a rule for parsing integers (parseInteger = liftM (IntToken . read) $ 
many1 digit) but if have currently no idea how to handle floats.



-Ursprüngliche Nachricht-
Von: Christian Maeder [mailto:christian.mae...@dfki.de] 
Gesendet: Dienstag, 8. März 2011 13:26
An: Hauschild, Klaus (EXT)
Cc: haskell-cafe@haskell.org
Betreff: Re: Overlaping Parsec rules

Am 08.03.2011 12:30, schrieb Hauschild, Klaus (EXT):
 Hi Christian,
 
 my version of parseList works currently strange.
 The input {2\n2} will be parsed fine, but something like { } or so fails 
 with 'expecting space or }'.

Also } (and ], etc.) should be excluded as identifier letters.
} is the second identifier in { }. (The first one is empty.)

C.

 
 The redefinition of space is not necessary, it was copied from another 
 tutorial code. How I write a version of parseGml that get gml token separated 
 by any white space (space, tab, newline)?
 
 Thanks
 
 -Ursprüngliche Nachricht-
 Von: Christian Maeder [mailto:christian.mae...@dfki.de] 
 Gesendet: Montag, 7. März 2011 14:18
 An: Hauschild, Klaus (EXT)
 Cc: haskell-cafe@haskell.org
 Betreff: Re: Overlaping Parsec rules
 
 Am 07.03.2011 13:48, schrieb Hauschild, Klaus (EXT):
 Thanks Christian,

 I adapted the keyword parser and now n - negi does not occur.

 But there are still other problems to solve. If I activate the parseFunction 
 the parser will answer to fact.gml unexpected end of input, expecting space 
 or }.
 
 Your redefinition of spaces (= skipMany1 space) is problematic and:
 
  parseList = sepBy parseGml' spaces
 
 Allow for the original (optional) spaces after parseGml':
 
   parseGml'' = liftM2 const parseGml' spaces
 
   parseList = many parseGml''
 
 C.
 
 P.S. why do you call? many (noneOf )
 
manyTill anyChar newline
 
or just: many (noneOf \n)
 
(a trailing newline will be skipped by spaces)
 

 Any ideas?


 -Ursprüngliche Nachricht-
 Von: Christian Maeder [mailto:christian.mae...@dfki.de] 
 Gesendet: Montag, 7. März 2011 12:23
 An: Hauschild, Klaus (EXT)
 Cc: haskell-cafe@haskell.org
 Betreff: Re: Overlaping Parsec rules

 You should parse keywords using:

 keyword s = try (string s)  notFollowedBy (letter | digit)

 C.

 Am 07.03.2011 11:34, schrieb Hauschild, Klaus (EXT):
 Hi,
  
 to solve this ICFP task _http://www.cs.cornell.edu/icfp/task.htm_ I'm
 currnetly working on the parser. With the hint from Thu (reading Phillip
 Wadlers monadic parser paper) and consulting
 _http://en.wikibooks.org/wiki/Write_Yourself_a_Scheme_in_48_Hours/Parsing_
 I produce a first working version of the parser.
 After this great moment I completed the token definition and near all
 parsing rules. For the complete code have a look at
 _http://code.google.com/p/hgmltracer/source/browse/#svn%2Ftrunk%2FhGmlTracer_
  
 data GmlToken =

 -- structures

 FunctionToken TokenSequence |

 ArrayToken TokenSequence|

 -- control operators

 ApplyToken  |

 IfToken |

 -- number operators

 AddiToken   |

 AddfToken   |

 ACosToken   |

 ASinToken   |

 ClampfToken |

 CosToken|

 DiviToken   |

 DivfToken   |

 EqiToken|

 EqfToken|

 FloorToken  |

 FracToken   |

 LessiToken  |

 LessfToken  |

 ModiToken   |

 MuliToken   |

 MulfToken   |

 NegiToken   |

 NegfToken   |

 ToRealToken |

 SinToken|

 SqrtToken   |

 SubiToken   |

 SubfToken   |

 -- points

 GetXToken   |

 GetYToken   |

 GetZToken   |

 PointToken  |

 -- arrays

 GetToken|

  

Re: [Haskell-cafe] Overlaping Parsec rules

2011-03-08 Thread Christian Maeder
Am 08.03.2011 13:35, schrieb Hauschild, Klaus (EXT):
 Hi Christian,
 
 Thank you for your help. Now the current version of Parse.hs 
 (http://code.google.com/p/hgmltracer/source/browse/trunk/hGmlTracer/src/Gml/Parse.hs)
  works well for the test file fact.gml.

   spaces
   char end

The idea is to call spaces _after_ every token. So the keyword parser
should be extended by  spaces and also the number, char, string,
binder and identifier parsers. Rather than using 'noneOf  ]}\n\t' I
would precisely define the identifier letters.

  isIdChar :: Char - Bool
  isIdChar c = isLetter c || isDigit c || 

and use satisfy isIdChar also in keyword's notFollowedBy.

 Now the last thing is parsing the different numbers (integer and float). If 
 have a rule for parsing integers (parseInteger = liftM (IntToken . read) $ 
 many1 digit) but if have currently no idea how to handle floats.

Look inside
http://hackage.haskell.org/packages/archive/parsec2/1.0.0/doc/html/src/Text-ParserCombinators-Parsec-Token.html
under floating and copy and adjust the code for you.

C.

 
 
 
 -Ursprüngliche Nachricht-
 Von: Christian Maeder [mailto:christian.mae...@dfki.de] 
 Gesendet: Dienstag, 8. März 2011 13:26
 An: Hauschild, Klaus (EXT)
 Cc: haskell-cafe@haskell.org
 Betreff: Re: Overlaping Parsec rules
 
 Am 08.03.2011 12:30, schrieb Hauschild, Klaus (EXT):
 Hi Christian,

 my version of parseList works currently strange.
 The input {2\n2} will be parsed fine, but something like { } or so fails 
 with 'expecting space or }'.
 
 Also } (and ], etc.) should be excluded as identifier letters.
 } is the second identifier in { }. (The first one is empty.)
 
 C.
 

 The redefinition of space is not necessary, it was copied from another 
 tutorial code. How I write a version of parseGml that get gml token 
 separated by any white space (space, tab, newline)?

 Thanks

 -Ursprüngliche Nachricht-
 Von: Christian Maeder [mailto:christian.mae...@dfki.de] 
 Gesendet: Montag, 7. März 2011 14:18
 An: Hauschild, Klaus (EXT)
 Cc: haskell-cafe@haskell.org
 Betreff: Re: Overlaping Parsec rules

 Am 07.03.2011 13:48, schrieb Hauschild, Klaus (EXT):
 Thanks Christian,

 I adapted the keyword parser and now n - negi does not occur.

 But there are still other problems to solve. If I activate the 
 parseFunction the parser will answer to fact.gml unexpected end of input, 
 expecting space or }.

 Your redefinition of spaces (= skipMany1 space) is problematic and:

  parseList = sepBy parseGml' spaces

 Allow for the original (optional) spaces after parseGml':

   parseGml'' = liftM2 const parseGml' spaces

   parseList = many parseGml''

 C.

 P.S. why do you call? many (noneOf )

manyTill anyChar newline

or just: many (noneOf \n)

(a trailing newline will be skipped by spaces)


 Any ideas?


 -Ursprüngliche Nachricht-
 Von: Christian Maeder [mailto:christian.mae...@dfki.de] 
 Gesendet: Montag, 7. März 2011 12:23
 An: Hauschild, Klaus (EXT)
 Cc: haskell-cafe@haskell.org
 Betreff: Re: Overlaping Parsec rules

 You should parse keywords using:

 keyword s = try (string s)  notFollowedBy (letter | digit)

 C.

 Am 07.03.2011 11:34, schrieb Hauschild, Klaus (EXT):
 Hi,
  
 to solve this ICFP task _http://www.cs.cornell.edu/icfp/task.htm_ I'm
 currnetly working on the parser. With the hint from Thu (reading Phillip
 Wadlers monadic parser paper) and consulting
 _http://en.wikibooks.org/wiki/Write_Yourself_a_Scheme_in_48_Hours/Parsing_
 I produce a first working version of the parser.
 After this great moment I completed the token definition and near all
 parsing rules. For the complete code have a look at
 _http://code.google.com/p/hgmltracer/source/browse/#svn%2Ftrunk%2FhGmlTracer_
  
 data GmlToken =

 -- structures

 FunctionToken TokenSequence |

 ArrayToken TokenSequence|

 -- control operators

 ApplyToken  |

 IfToken |

 -- number operators

 AddiToken   |

 AddfToken   |

 ACosToken   |

 ASinToken   |

 ClampfToken |

 CosToken|

 DiviToken   |

 DivfToken   |

 EqiToken|

 EqfToken|

 FloorToken  |

 FracToken   |

 LessiToken  |

 LessfToken  |

 ModiToken   |

 MuliToken   |

 

Re: [Haskell-cafe] makeTokenParser + LanguageDef

2011-03-08 Thread Peter Simons
Hi Klaus,

for what it's worth, you might want to consider using this package
instead of Parsec:

  http://hackage.haskell.org/package/BNFC

Take care,
Peter


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


[Haskell-cafe] Error recovery in Happy

2011-03-08 Thread Tom
Hey guys,

I was wondering if there were possiblities to ignore certain errors during
parsing. I tried using the error token, but that didn't seem to work. I
looked at the following topic
http://haskell.1045720.n5.nabble.com/Error-detection-in-GLR-Happy-grammar-td3083740.html


For my parser I need to be able to parse a certain token at any place, but
only in some places it is part of a rule. In other cases this token should
be ignored after which the parser just procedes to the next token. Is this
possible with Happy? Should I use the monadic parser to achieve this?

More concretely, I have tokenized some sourcecode which contains comments,
these should be ignored except when they are located above a function, in
which case I want them to parse.

Any ideas about this issue are greatly appreciated!

Thanks,

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


Re: [Haskell-cafe] makeTokenParser + LanguageDef

2011-03-08 Thread Job Vranish
The tutorial here:
http://legacy.cs.uu.nl/daan/download/parsec/parsec.html#Lexical analysis
http://legacy.cs.uu.nl/daan/download/parsec/parsec.html#Lexical analysisis
for parsec 2, but it's still quite relevant.

- Job

On Tue, Mar 8, 2011 at 6:22 AM, Hauschild, Klaus (EXT) 
klaus.hauschild@siemens.com wrote:

  Hi Haskellers,

 is there a fine tutorial for building a parser with parsecs (3.*)
 makeTokenParser and LanguageDef stuff?

 Klaus


 ___
 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] ANN: theoremquest-0.0.0

2011-03-08 Thread Tom Hawkins
 I am curious -- how easy is it to use theoremquest for playing with
 equational theories?

Let me turn the question around:  How easy is it to play with
equational theories in HOL Light?  Because this is the planed basis
for TheoremQuest.

-Tom

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


Re: [Haskell-cafe] Error recovery in Happy

2011-03-08 Thread Stephen Tetley
I'd join comments in with tokens so each token has a comment -
possibly the empty string, then the parser can decide what to do with
the comment part of token - e.g retaining it for functions, ignoring
it for everything else.

You may have to write a two-pass lexer to do this.

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


Re: [Haskell-cafe] Error recovery in Happy

2011-03-08 Thread Stephen Tetley
By the way - my last answer was for the second part of the question.

For error handling - Doaitse Swierstra's UU-Parsing is a combinator
parsing library with some flexibility for error recovery. For an LR
parser like Happy adding extra error handling cases to the productions
in your grammar is the main tool you have.

On 8 March 2011 15:54, Stephen Tetley stephen.tet...@gmail.com wrote:
 I'd join comments in with tokens so each token has a comment -
 possibly the empty string, then the parser can decide what to do with
 the comment part of token - e.g retaining it for functions, ignoring
 it for everything else.

 You may have to write a two-pass lexer to do this.


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


Re: [Haskell-cafe] ANN: theoremquest-0.0.0

2011-03-08 Thread rusi
On Mar 8, 8:20 pm, Tom Hawkins tomahawk...@gmail.com wrote:
  I am curious -- how easy is it to use theoremquest for playing with
  equational theories?

 Let me turn the question around:  How easy is it to play with
 equational theories in HOL Light?  Because this is the planed basis
 for TheoremQuest.

Dunno... I am far from being a theorem-prover buff/expert :-)
I know of Dijkstra-Scholten logic -- not as a formal logician but as a
math teacher.

But anyhow that (HOL) gives me some context and sense of direction --
Thanks.

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


Re: [Haskell-cafe] Error recovery in Happy

2011-03-08 Thread Tom
That two-pass lexer sounds like a good idea. I actually want to keep the
happy parser if possible, can you elaborate on adding extra error handling
cases for production rules? Do you mean I have to add a line for comments on
possible places where they can occur?

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


Re: [Haskell-cafe] Error recovery in Happy

2011-03-08 Thread Stephen Tetley
Hi Tom

Here's how I'd do comment annotation in the Parser:


 type Comment = String
 type Identifier = String

I suspect data carrying tokens need to pair the data and the comment
so Happy can treat them as a positional reference e.g. $1

 data Token =
   TK_identifier (Identifier,Comment)
 | TK_kywd_module Comment
 | ...


Productions now have to use smart constructors:


 module:: { Module }
   : '%module' mname  defs
 { mkModule $1 $2 $3  }




 data Module = Module { mod_comment :: Comment
  , mod_name:: String
  , mod_body:: [Def]
  }



The 'smart' constructor takes the comment before the module
delacration, any comment between the module start token and the module
name is ignored...

 mkModule :: Comment - (String,Comment) - [Def] - Module
 mkModule outer_comment (mname, _) defs =
Module outer_comment mname defs



As for error handling, the strategy is to add error handling
productions after good productions.

Now module can handle a missing module name:


 module:: { Module }
   : '%module' mname  defs
 { mkModule $1 $2 $3  }
   : ''%module' defs
 { badModule $1 $2 }



 badModule :: Comment [Def] - Module
 badModule outer_comment defs = Module outer_comment fake_name defs
   where
 fake_name = ERR - parser error reading module name


Ideally the smart constructors should be in a monad that supports
error logging like Writer.

As you can see this isn't a great way of doing things but I'm not sure
you have any other options. Personally I'd see if I could live with
first fail instead.

Best wishes

Stephen

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


Re: [Haskell-cafe] Haskell IDE

2011-03-08 Thread Andrew Coppin

On 07/03/2011 04:39 PM, Daniel Fischer wrote:


That sounds nice, so I thought I'd try out leksah again.

Unfortunately, the dependencies rule out GHC-7

Maybe someone could try relaxing the bounds and build it with GHC-7, and -
if it works - upload a new version?
(I could try if I get a go-ahead from Hamish or Jürgen)


I couldn't get it to build either. So I just grabbed the Windows binary 
from the homepage and used that. Worked just fine...


(Not sure that they have binaries for platforms that aren't Windows 
though. Can't remember off the top of my head.)


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


Re: [Haskell-cafe] Haskell Platform 2011.2

2011-03-08 Thread Andrew Coppin

On 06/03/2011 11:46 AM, Andrew Coppin wrote:

On 06/03/2011 01:22 AM, Don Stewart wrote:


P.S. you can help by testing the installers, and reporting issues on
the HP trac and mailing list. The candidate installers are here:

http://code.galois.com/darcs/haskell-platform/download-website/


Is there some way to navigate to this page from the HP homepage?


Seriously, if you want people to test it, having this fact more clearly 
visible seems like a good idea. (In particular, I have access to Windows 
systems I can test on, which is apparently rare around here, but until 
this email I had no idea that a release candidate was even available...)


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


Re: [Haskell-cafe] have anyone tried GHC 7.0.2

2011-03-08 Thread Qi Qi
ghc-pkg list returns these:


/usr/local/lib/ghc-7.0.2/package.conf.d:
Cabal-1.10.1.0
array-0.3.0.2
base-4.3.1.0
bin-package-db-0.0.0.0
bytestring-0.9.1.10
containers-0.4.0.0
directory-1.1.0.0
extensible-exceptions-0.1.1.2
ffi-1.0
filepath-1.2.0.0
(ghc-7.0.2)
(ghc-binary-0.5.0.2)
ghc-prim-0.2.0.0
(haskell2010-1.0.0.0)
haskell98-1.1.0.1
hpc-0.5.0.6
integer-gmp-0.2.0.3
old-locale-1.0.0.2
old-time-1.0.0.6
pretty-1.0.1.2
process-1.0.1.5
random-1.0.0.3
rts-1.0
template-haskell-2.5.0.0
time-1.2.0.3
unix-2.4.2.0

/home/qi/.ghc/i386-linux-7.0.2/package.conf.d:
HTTP-4000.1.1
QuickCheck-2.4.0.1
X11-1.5.0.0
X11-xft-0.3
binary-0.5.0.2
containers-0.3.0.0
cpphs-1.11
directory-1.1.0.0
filepath-1.1.0.4
haskell98-1.1.0.1
hinotify-0.3.1
hscolour-1.17
language-c-0.3.2.1
mtl-1.1.1.1
mtl-2.0.1.0
{network-2.2.1.10}
network-2.3.0.2
parsec-2.1.0.1
parsec-3.1.1
primitive-0.3.1
process-1.0.1.5
stm-2.2.0.1
storable-complex-0.2.1
syb-0.3
transformers-0.2.2.0
uniplate-1.6
utf8-string-0.3.6
vector-0.7.0.1
xmonad-0.9.2
xmonad-contrib-0.9.2
zlib-0.5.3.1




ghc-pkg check returns this:

There are problems in package network-2.2.1.10:
  dependency parsec-3.1.1-583092e3fd1a17b79365b197467a185d doesn't exist

The following packages are broken, either because they have a problem
listed above, or because they depend on a broken package.
network-2.2.1.10


I installed parsec and network  via cabal. Do you know how can I remove
network-2.2.1.10 that is not needed because a higher version exists. 

Should I delete anything under ~/.ghc and ~/.cabal, and reinstall ghc
and cabal-install, and those pacakges installed before using cabal?

Thanks for your link of the Haskell-platform. I will wait for the
official release and hope it will be soon.



Christian Maeder christian.mae...@dfki.de writes:

 What does ghc-pkg list and ghc-pkg check say?

 Cabal-1.10.1.0, directory-1.1.0.0 and process-1.0.1.5 should be there
 after installation of GHC 7.0.2. (I've actually installed
 cabal-install-0.10.0 using an older cabal, but that does not work on
 macs and may not be the recommended way.)

 I think I've used
 http://www.galois.com/~dons/code/2011.2.0.0/haskell-platform-2011.2.0.0.tar.gz
 from http://www.galois.com/~dons/code/2011.2.0.0/, but they are not
 official yet.

 C.

 Am 08.03.2011 19:20, schrieb Qi Qi:
 Hi,
 
 After I installed GHC 7.0.2 and cabal-install 0.10.0 using Cabal library
 1.10.1, I found that some package failed to install. For example like
 Happy, I got the following error:
 
 cabal install happy
 Resolving dependencies...
 command line: cannot satisfy -package Cabal-1.10.1.0: 
 Cabal-1.10.1.0-64e8f05722ea5bbdf07df2e5a3491105 is unusable due to 
 missing or recursive dependencies:
   directory-1.1.0.0-85d1d0f9d96dffdacf64f3cc6fba6f2f 
 process-1.0.1.5-4cab1bf0666275ac101dd48c7565b64c
 (use -v for more information)
 cabal: Error: some packages failed to install:
 happy-1.18.6 failed during the configure step. The exception was:
 ExitFailure 1
 
 Besides happy package, some other packages like ghc-mod, hmatrix also
 failed to install. Does anyone else have the same issue after installed
 ghc 7.0.2? 
 
 By the way, does anyone hear anything about Haskell-platform 2011.2 ?
 
 
 Thanks!
 

-- 
Qi Qi

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


[Haskell-cafe] Tagless interpreter, expression problem and zipper

2011-03-08 Thread Roel van Dijk
Hello everyone,

I am stuck rewriting some code in the tagless style. My problem can be
thought of as an interpreter for a very simple language:

 data Exp = Lit Integer
  | Add Exp Exp
  | Mul Exp Exp
deriving (Show)

But some complexity is added by the fact that my interpreter also
needs to know the context in which literals appear in an
expression. So given the example

 t1 :: Exp
 t1 = (Lit 3 `Add` Lit 4) `Mul` Lit 2

I want to have access to the fact that the literal 3 appears on
the left side of an addition. Therefore I created a type:

 data Ctx = Empty
  | AddL Exp Ctx
  | AddR Exp Ctx
  | MulL Exp Ctx
  | MulR Exp Ctx
deriving (Show)

This is almost a zipper over the Exp type. I left out a context for
literals themselves because it wasn't necessary. Now I can create a
simple evaluation function:

 eval :: (a - a - a)
  - (a - a - a)
  - (Integer - Ctx - a)
  - Exp
  - a
 eval add mul lit = go Empty
 where
   go ctx (Lit n)   = lit n ctx
   go ctx (Add x y) = let x' = go (AddL y ctx) x
  y' = go (AddR x ctx) y
  in x' `add` y'
   go ctx (Mul x y) = let x' = go (MulL y ctx) x
  y' = go (MulR x ctx) y
  in x' `mul` y'

This function can evaluate an expression to any type 'a', but it needs
some additional functions to accomplish that: add, mul and lit. Notice
how the 'lit' function has access to a literal's context. To interpret
an Exp as an Integer I use:

 evalInt :: Exp - Integer
 evalInt = eval (+) (*) const

Or as a String:

 evalStr1 :: Exp - String
 evalStr1 = eval addStr mulStr (const . show)

 addStr x y = ( ++ x ++  +  ++ y ++ )
 mulStr x y = ( ++ x ++  *  ++ y ++ )

Or a silly example which uses the context:

 evalStr2 :: Exp - String
 evalStr2 = eval addStr mulStr lit
 where
   lit _ (AddL (Lit 4) (MulL _ _)) = Foo!
   lit n _ = show n

The silly example replaces a literal with Foo! if it appears on the
left side of an addition with 4, and the whole addition is the left
side of a multiplication, like in (x + 4) * ?.

All of this works. But I want to be able to add additional
constructors to the Exp language without changing existing code. This
looks like the expression problem.

Ignoring the zipper-like context I came up with the following:

First define the language:
 class Lit a where lit :: Integer - a
 class Add a where add :: a - a - a
 class Mul a where mul :: a - a - a

Integer interpreter:
 instance Lit Integer where lit = fromInteger
 instance Add Integer where add = (+)
 instance Mul Integer where mul = (*)

String interpreter, using a newtype so I don't need
TypeSynonymInstances:
 newtype Str = Str {unS :: String}
 instance Show Str where show = show . unS

 instance Lit Str where lit = Str . show
 instance Add Str where add x y = Str $ addStr (unS x) (unS y)
 instance Mul Str where mul x y = Str $ mulStr (unS x) (unS y)

Same example expression, now polymorphic:
 t1 :: (Lit a, Add a, Mul a) = a
 t1 = (lit 3 `add` lit 4) `mul` lit 2

This expression can now be interpreted in multiple ways:
 t1 :: Integer
 14
 t1 :: Str
 ((3 + 4) * 2)

This solves the expression problem. I can add new structures to my
language in other modules without having to change existing code. The
necessary parts are mentioned in the type constraint (Lit a, Add a,
Mul a).

But I lost the power of the context! How do I get it back?

Attached are the two approaches, WithTags.hs and Tagless.hs (but
without context).

Any help would be greatly appreciated!
module WithTags where

data Exp = Lit Integer
 | Add Exp Exp
 | Mul Exp Exp
   deriving (Show)

data Ctx = Empty
 | AddL Exp Ctx
 | AddR Exp Ctx
 | MulL Exp Ctx
 | MulR Exp Ctx
   deriving (Show)

eval :: (a - a - a)
 - (a - a - a)
 - (Integer - Ctx - a)
 - Exp
 - a
eval add mul lit = go Empty
where
  go ctx (Lit n)   = lit n ctx
  go ctx (Add x y) = let x' = go (AddL y ctx) x
 y' = go (AddR x ctx) y
 in x' `add` y'
  go ctx (Mul x y) = let x' = go (MulL y ctx) x
 y' = go (MulR x ctx) y
 in x' `mul` y'

evalInt :: Exp - Integer
evalInt = eval (+) (*) const

addStr x y = ( ++ x ++  +  ++ y ++ )
mulStr x y = ( ++ x ++  *  ++ y ++ )

evalStr1 :: Exp - String
evalStr1 = eval addStr mulStr (const . show)

evalStr2 :: Exp - String
evalStr2 = eval addStr mulStr lit
where
  lit _ (AddL (Lit 4) (MulL _ _)) = Foo!
  lit n _ = show n

t1 :: Exp
t1 = (Lit 3 `Add` Lit 4) `Mul` Lit 2
module Tagless where

class Lit a where lit :: Integer - a
class Add a where add :: a - a - a
class Mul a where mul :: a - a - a

instance Lit Integer where lit = fromInteger
instance Add Integer where add = (+)
instance Mul Integer where mul = (*)

-- Newtype so I 

Re: [Haskell-cafe] Haskell IDE

2011-03-08 Thread Daniel Fischer
On Tuesday 08 March 2011 21:16:33, Andrew Coppin wrote:
 On 07/03/2011 04:39 PM, Daniel Fischer wrote:
  That sounds nice, so I thought I'd try out leksah again.
  
  Unfortunately, the dependencies rule out GHC-7
  
  Maybe someone could try relaxing the bounds and build it with GHC-7,
  and - if it works - upload a new version?
  (I could try if I get a go-ahead from Hamish or Jürgen)
 
 I couldn't get it to build either. So I just grabbed the Windows binary
 from the homepage and used that. Worked just fine...
 
 (Not sure that they have binaries for platforms that aren't Windows
 though. Can't remember off the top of my head.)
 

From what I remember, Mac, Fedora and Arch linux.
I guess there's a chance the Fedora RPMs work on openSUSE, but I won't try.
I'll wait for the next version on hackage.

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


Re: [Haskell-cafe] Haskell Platform 2011.2

2011-03-08 Thread Don Stewart
We have plenty of testers on the haskell-platform@ list. If you're
interested, you can join there to discuss results.
By definition the test installers are not yet ready for haskell-cafe@
consumption.

-- Don

On Tue, Mar 8, 2011 at 12:17 PM, Andrew Coppin
andrewcop...@btinternet.com wrote:
 On 06/03/2011 11:46 AM, Andrew Coppin wrote:

 On 06/03/2011 01:22 AM, Don Stewart wrote:

 P.S. you can help by testing the installers, and reporting issues on
 the HP trac and mailing list. The candidate installers are here:

 http://code.galois.com/darcs/haskell-platform/download-website/

 Is there some way to navigate to this page from the HP homepage?

 Seriously, if you want people to test it, having this fact more clearly
 visible seems like a good idea. (In particular, I have access to Windows
 systems I can test on, which is apparently rare around here, but until this
 email I had no idea that a release candidate was even available...)

 ___
 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] have anyone tried GHC 7.0.2

2011-03-08 Thread Daniel Fischer
On Wednesday 09 March 2011 11:42:48, Qi Qi wrote:
 ghc-pkg check returns this:
 
 There are problems in package network-2.2.1.10:
   dependency parsec-3.1.1-583092e3fd1a17b79365b197467a185d doesn't
 exist

Seems parsec-3.1.1 was rebuilt after network-2.2.1.10 was installed.
Any idea what package caused that?

 
 The following packages are broken, either because they have a problem
 listed above, or because they depend on a broken package.
 network-2.2.1.10
 
 
 I installed parsec and network  via cabal. Do you know how can I remove
 network-2.2.1.10 that is not needed because a higher version exists. 

Try

$ ghc-pkg unregister network-2.2.1.10

If ghc-pkg says that would break other packages (it shouldn't, if it would, 
those should have been reported too), you could unregister them first (or 
use --force) (and reinstall them afterwards).

 
 Should I delete anything under ~/.ghc and ~/.cabal, and reinstall ghc
 and cabal-install, and those pacakges installed before using cabal?

Not as a first measure, while breakage is small, ghc-pkg unregister tends 
to be less work. Only if you have lots of breakage would I recommend 
deleting the local package db.

 
 Thanks for your link of the Haskell-platform. I will wait for the
 official release and hope it will be soon.

Should be only a couple of days, iirc.

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


Re: [Haskell-cafe] Haskell Platform 2011.2

2011-03-08 Thread Andrew Coppin

On 08/03/2011 08:57 PM, Don Stewart wrote:

We have plenty of testers on the haskell-platform@ list. If you're
interested, you can join there to discuss results.
By definition the test installers are not yet ready for haskell-cafe@
consumption.


Oh, right. There's a mailing list? I wasn't aware of that. I'll go take 
a look...


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


[Haskell-cafe] some problem with Cabal

2011-03-08 Thread Qi Qi
Hi,

When I tried the haskell platform 2011.2 source, from here
http://code.galois.com/darcs/haskell-platform/download-website/linux.html
. 

Configuration passed successfully. But when making, it gives the following
error:

scripts/build.sh
**
Scanning system for any installed Haskell Platform components...

Found:None.

New packages to install: None! All done.

**
Building 
/usr/local/bin/ghc --make Setup -o Setup -package Cabal-1.10.1.0
command line: cannot satisfy -package Cabal-1.10.1.0: 
Cabal-1.10.1.0-64e8f05722ea5bbdf07df2e5a3491105 is unusable due to missing 
or recursive dependencies:
  directory-1.1.0.0-85d1d0f9d96dffdacf64f3cc6fba6f2f 
process-1.0.1.5-4cab1bf0666275ac101dd48c7565b64c
(use -v for more information)

Error:
Compiling the Setup script failed
make: *** [build.stamp] Error 2


I think this is the same problem as I got during installing some other
packages via cabal such as hmatrix, ghc-mod, happy and etc.

Does anyone have any idea about how to solve it?

Thanks!



-- 
Qi Qi

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


Re: [Haskell-cafe] have anyone tried GHC 7.0.2

2011-03-08 Thread qiqi
Thank you!

I fixed the broken package, network-2.2.1.10 by manually removing it locally
and recache the ghc's package cache by running ghc-pkg recache. Thanks
though for the unregister option.

Now ghc-pkg check doesn't return any broken packages. But Cabal seems still
got problem. I got the same cabal problem when I tried to test with the
haskell-platform 2011-2. I have post another with that regard.


--
View this message in context: 
http://haskell.1045720.n5.nabble.com/have-anyone-tried-GHC-7-0-2-tp3413510p3414675.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

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


Re: [Haskell-cafe] some problem with Cabal

2011-03-08 Thread Daniel Fischer
On Wednesday 09 March 2011 12:16:30, Qi Qi wrote:
 I think this is the same problem as I got during installing some other
 packages via cabal such as hmatrix, ghc-mod, happy and etc.
 
 Does anyone have any idea about how to solve it?


I think it may be a problem with your GHC. I have no problems cabal 
install'ing packages using

$ cabal --version
cabal-install version 0.10.0
using version 1.10.1.0 of the Cabal library

$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 7.0.2

Does compiling a simple module using the Cabal library work?
(for example

module Main (main) where

import Distribution.Simple.Setup

main :: IO ()
main = print defaultGlobalFlags

)

If your Cabal package is really unusable, that should break too (but then, 
why doesn't ghc-pkg check report it as broken?). Re-installing Cabal would 
be an option then.
If it works, on the other hand, the problem may be with your cabal and re-
installing that may be worth a try.

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


Re: [Haskell-cafe] Error recovery in Happy

2011-03-08 Thread Tom
Alright thanks for your comprehensive answer! I think I got something to
work with :)

Cheers,

Tom


On Tue, Mar 8, 2011 at 8:09 PM, Stephen Tetley stephen.tet...@gmail.comwrote:

 Hi Tom

 Here's how I'd do comment annotation in the Parser:


  type Comment = String
  type Identifier = String

 I suspect data carrying tokens need to pair the data and the comment
 so Happy can treat them as a positional reference e.g. $1

  data Token =
TK_identifier (Identifier,Comment)
  | TK_kywd_module Comment
  | ...


 Productions now have to use smart constructors:

 
  module:: { Module }
: '%module' mname  defs
  { mkModule $1 $2 $3  }
 



  data Module = Module { mod_comment :: Comment
   , mod_name:: String
   , mod_body:: [Def]
   }



 The 'smart' constructor takes the comment before the module
 delacration, any comment between the module start token and the module
 name is ignored...

  mkModule :: Comment - (String,Comment) - [Def] - Module
  mkModule outer_comment (mname, _) defs =
 Module outer_comment mname defs



 As for error handling, the strategy is to add error handling
 productions after good productions.

 Now module can handle a missing module name:

 
  module:: { Module }
: '%module' mname  defs
  { mkModule $1 $2 $3  }
: ''%module' defs
  { badModule $1 $2 }


 
  badModule :: Comment [Def] - Module
  badModule outer_comment defs = Module outer_comment fake_name defs
where
  fake_name = ERR - parser error reading module name
 

 Ideally the smart constructors should be in a monad that supports
 error logging like Writer.

 As you can see this isn't a great way of doing things but I'm not sure
 you have any other options. Personally I'd see if I could live with
 first fail instead.

 Best wishes

 Stephen

 ___
 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] have anyone tried GHC 7.0.2

2011-03-08 Thread qiqi
The problem is solved! I found out that both global and local package db get
directory-1.1.0.0 and process-1.0.1.5. I unregistered them and other caused
broken packages in the local package db. Then I successfully installed back
hmatrix, ghc-mod, happy and etc. It seems that xmobar will install
directory-1.1.0.0 again in the local package db. 

Thank you all who replied this threading!

--
View this message in context: 
http://haskell.1045720.n5.nabble.com/have-anyone-tried-GHC-7-0-2-tp3413510p3414820.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

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


Re: [Haskell-cafe] some problem with Cabal

2011-03-08 Thread qiqi
Thank you, Daniel. 

The problem is solved! I found out that both global and local package db get
directory-1.1.0.0 and process-1.0.1.5. I unregistered them and other caused
broken packages in the local package db. Then I successfully installed back
hmatrix, ghc-mod, happy and etc. It seems that xmobar will install
directory-1.1.0.0 again in the local package db. 

Did you succeed in installing haddock 2.9? Mine got some syntax oriented
error duing cabal install haddock. But it's fine.



Daniel Fischer wrote:
 
 On Wednesday 09 March 2011 12:16:30, Qi Qi wrote:
 I think this is the same problem as I got during installing some other
 packages via cabal such as hmatrix, ghc-mod, happy and etc.
 
 Does anyone have any idea about how to solve it?
 
 
 I think it may be a problem with your GHC. I have no problems cabal 
 install'ing packages using
 
 $ cabal --version
 cabal-install version 0.10.0
 using version 1.10.1.0 of the Cabal library
 
 $ ghc --version
 The Glorious Glasgow Haskell Compilation System, version 7.0.2
 
 Does compiling a simple module using the Cabal library work?
 (for example
 
 module Main (main) where
 
 import Distribution.Simple.Setup
 
 main :: IO ()
 main = print defaultGlobalFlags
 
 )
 
 If your Cabal package is really unusable, that should break too (but then, 
 why doesn't ghc-pkg check report it as broken?). Re-installing Cabal would 
 be an option then.
 If it works, on the other hand, the problem may be with your cabal and re-
 installing that may be worth a try.
 
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe
 


--
View this message in context: 
http://haskell.1045720.n5.nabble.com/some-problem-with-Cabal-tp3414662p3414823.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

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


Re: [Haskell-cafe] some problem with Cabal

2011-03-08 Thread Daniel Fischer
On Wednesday 09 March 2011 00:34:39, qiqi wrote:
 The problem is solved! I found out that both global and local package db
 get directory-1.1.0.0 and process-1.0.1.5. I unregistered them and
 other caused broken packages in the local package db.

D'oh, I should've seen that.

 Then I
 successfully installed back hmatrix, ghc-mod, happy and etc. It seems
 that xmobar will install directory-1.1.0.0 again in the local package
 db.

That's not good. And it doesn't seem to do that here:

$ cabal install xmobar --dry-run
Resolving dependencies...
In order, the following would be installed (use -v for more details):
stm-2.2.0.1
syb-0.3
X11-1.5.0.0
utf8-string-0.3.6
xmobar-0.12

What does

$ cabal install xmobar --dry-run -v3 say for you about directory?

 
 Did you succeed in installing haddock 2.9?

That was built with the compiler (I built from source), no problems.

$ haddock --version
Haddock version 2.9.2, (c) Simon Marlow 2006
Ported to use the GHC API by David Waern 2006-2008

 Mine got some syntax oriented
 error duing cabal install haddock. But it's fine.

The same as 
http://haskell.org/pipermail/haskell-cafe/2011-March/089902.html ?
I don't know if that's been solved.

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


Re: [Haskell-cafe] some problem with Cabal

2011-03-08 Thread Don Stewart
This is fixed in the new release of cabal-install  ( I think) so we're
rolling new installers.

Discussion around the installers is taking place on the haskell-platform list.

-- Don

On Wed, Mar 9, 2011 at 3:16 AM, Qi Qi qiqi...@gmail.com wrote:
 Hi,

 When I tried the haskell platform 2011.2 source, from here
 http://code.galois.com/darcs/haskell-platform/download-website/linux.html
 .

 Configuration passed successfully. But when making, it gives the following
 error:

 scripts/build.sh
 **
 Scanning system for any installed Haskell Platform components...

 Found:None.

 New packages to install: None! All done.

 **
 Building
 /usr/local/bin/ghc --make Setup -o Setup -package Cabal-1.10.1.0
 command line: cannot satisfy -package Cabal-1.10.1.0:
    Cabal-1.10.1.0-64e8f05722ea5bbdf07df2e5a3491105 is unusable due to missing 
 or recursive dependencies:
      directory-1.1.0.0-85d1d0f9d96dffdacf64f3cc6fba6f2f 
 process-1.0.1.5-4cab1bf0666275ac101dd48c7565b64c
    (use -v for more information)

 Error:
 Compiling the Setup script failed
 make: *** [build.stamp] Error 2


 I think this is the same problem as I got during installing some other
 packages via cabal such as hmatrix, ghc-mod, happy and etc.

 Does anyone have any idea about how to solve it?

 Thanks!



 --
 Qi Qi

 ___
 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] some problem with Cabal

2011-03-08 Thread qiqi
I used cabal install xmobar --flags=all_extensions .
Is it true that every package installed from hackage should not install any
package, which already exists in the global with the same version number ,
in the local db?



Daniel Fischer wrote:
 
 On Wednesday 09 March 2011 00:34:39, qiqi wrote:
 The problem is solved! I found out that both global and local package db
 get directory-1.1.0.0 and process-1.0.1.5. I unregistered them and
 other caused broken packages in the local package db.
 
 D'oh, I should've seen that.
 
 Then I
 successfully installed back hmatrix, ghc-mod, happy and etc. It seems
 that xmobar will install directory-1.1.0.0 again in the local package
 db.
 
 That's not good. And it doesn't seem to do that here:
 
 $ cabal install xmobar --dry-run
 Resolving dependencies...
 In order, the following would be installed (use -v for more details):
 stm-2.2.0.1
 syb-0.3
 X11-1.5.0.0
 utf8-string-0.3.6
 xmobar-0.12
 
 What does
 
 $ cabal install xmobar --dry-run -v3 say for you about directory?
 
 
 Did you succeed in installing haddock 2.9?
 
 That was built with the compiler (I built from source), no problems.
 
 $ haddock --version
 Haddock version 2.9.2, (c) Simon Marlow 2006
 Ported to use the GHC API by David Waern 2006-2008
 
 Mine got some syntax oriented
 error duing cabal install haddock. But it's fine.
 
 The same as 
 http://haskell.org/pipermail/haskell-cafe/2011-March/089902.html ?
 I don't know if that's been solved.
 
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe
 


--
View this message in context: 
http://haskell.1045720.n5.nabble.com/some-problem-with-Cabal-tp3414662p3414931.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

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


Re: [Haskell-cafe] some problem with Cabal

2011-03-08 Thread Daniel Fischer
On Wednesday 09 March 2011 02:51:35, qiqi wrote:
 I used cabal install xmobar --flags=all_extensions .

Whoa:

In order, the following would be installed:
containers-0.3.0.0 (new version)
filepath-1.1.0.4 (new version)
directory-1.1.0.0 (reinstall) changes: filepath-1.2.0.0 - 1.1.0.4
hinotify-0.3.1 (new package)
mtl-1.1.1.1 (new version)
network-2.2.1.10 (new version)
process-1.0.1.5 (reinstall) changes: filepath-1.2.0.0 - 1.1.0.4
stm-2.2.0.1 (new package)
syb-0.3 (new package)
X11-1.5.0.0 (new package)
time-1.1.4 (new version)
random-1.0.0.3 (reinstall) changes: time-1.2.0.3 - 1.1.4
haskell98-1.1.0.1 (reinstall)
utf8-string-0.3.6 (new package)
X11-xft-0.3 (new package)
libmpd-0.5.0 (new package)
xmobar-0.12 (new package)

I haven't looked further, but libmpd is at least partially responsible, it 
depends on filepath  1.2, time  1.2 and a couple other old packages.

 Is it true that every package installed from hackage should not install
 any package, which already exists in the global with the same version
 number , in the local db?

Generally, it shouldn't (and doesn't), but here some packages have to be 
reinstalled because they have to be built against different dependencies.

I'd prefer cabal install to refuse here (overridable with a --force flag) 
because reinstalling boot libs (containers, filepath, directory, process, 
time) tends to be a bad idea.

However, xmobar is an executable and no library, so if you unregister the 
packages (from the user db!) after installing before they can cause 
trouble, you should be fine (but no guarantees).

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


Re: [Haskell-cafe] some problem with Cabal

2011-03-08 Thread qiqi

Daniel Fischer wrote:
 
 On Wednesday 09 March 2011 02:51:35, qiqi wrote:
 I used cabal install xmobar --flags=all_extensions .
 
 Whoa:
 
 In order, the following would be installed:
 containers-0.3.0.0 (new version)
 filepath-1.1.0.4 (new version)
 directory-1.1.0.0 (reinstall) changes: filepath-1.2.0.0 - 1.1.0.4
 hinotify-0.3.1 (new package)
 mtl-1.1.1.1 (new version)
 network-2.2.1.10 (new version)
 process-1.0.1.5 (reinstall) changes: filepath-1.2.0.0 - 1.1.0.4
 stm-2.2.0.1 (new package)
 syb-0.3 (new package)
 X11-1.5.0.0 (new package)
 time-1.1.4 (new version)
 random-1.0.0.3 (reinstall) changes: time-1.2.0.3 - 1.1.4
 haskell98-1.1.0.1 (reinstall)
 utf8-string-0.3.6 (new package)
 X11-xft-0.3 (new package)
 libmpd-0.5.0 (new package)
 xmobar-0.12 (new package)
 
 I haven't looked further, but libmpd is at least partially responsible, it 
 depends on filepath  1.2, time  1.2 and a couple other old packages.
 
 Is it true that every package installed from hackage should not install
 any package, which already exists in the global with the same version
 number , in the local db?
 
 Generally, it shouldn't (and doesn't), but here some packages have to be 
 reinstalled because they have to be built against different dependencies.
 
 I'd prefer cabal install to refuse here (overridable with a --force flag) 
 because reinstalling boot libs (containers, filepath, directory, process, 
 time) tends to be a bad idea.
 
 However, xmobar is an executable and no library, so if you unregister the 
 packages (from the user db!) after installing before they can cause 
 trouble, you should be fine (but no guarantees).
 
 This is exactly what I am doing. I unregistered those packages but kept
 the xmobar's executable under ~/.cabal/bin. It works fine.
 
 Thanks Daniel. I appreciate it!
 
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe
 


--
View this message in context: 
http://haskell.1045720.n5.nabble.com/some-problem-with-Cabal-tp3414662p3414954.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

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


Re: [Haskell-cafe] Tagless interpreter, expression problem and zipper

2011-03-08 Thread Felipe Almeida Lessa
2011/3/8 Roel van Dijk vandijk.r...@gmail.com:
 Hello everyone,

Hello!

 But I lost the power of the context! How do I get it back?

The tagless interpreters splits the interpreter code (in your case,
the 'eval' function) into multiple functions on one or more type
classes.  Now, the key insight is that your interpreter is actually
not 'eval' but 'go' =), which has type 'Ctx - a' (instead of just
'a').  But you don't need to change any code that uses Lit, Add and
Mul, they work unmodified.

First of all, I'll generalize your context a bit:

  data Ctx a = Empty
 | AddL a (Ctx a)
 | AddR a (Ctx a)
 | MulL a (Ctx a)
 | MulR a (Ctx a)
 deriving (Show)

Now we can create a new interpreter:

  newtype CtxInterpA a = CIA {unCIA :: Ctx a → a}

I'm appending A to its name because later on I'll propose another
interpreter B.  The underlying type 'a' is the same 'a' from your
original 'eval' function, so we can't use 'lit' from 'Lit' type class.
 So we create

  class CtxLitA a where
ctxLitA :: Integer → Ctx a → a

Our interpreter's instance for 'Lit' is then simply

  instance CtxLitA a ⇒ Lit (CtxInterpA a) where
lit = CIA∘ctxLitA

To get a result from 'CtxInterpA a' we just pass an empty context:

  fromCtxInterpA :: CtxInterpA a → a
  fromCtxInterpA x = unCIA x Empty

The 'Add' instance, however, is somewhat problematic.  We need an 'a'
for our 'Ctx a', however the arguments given for 'add' are of type
'CtxInterpA a'.  To get an 'a' from 'CtxInterpA a' we need, again, a
'Ctx a'.

  instance Add a ⇒ Add (CtxInterpA a) where
add x y = CIA (λctx → let x' = unCIA x (AddL y' ctx)
  y' = unCIA y (AddR x' ctx)
  in x' `add` y')

The main problem with this instance with respect to your original
'eval' code is that in 'AddL' and 'AddR' we have y' and x', and not y
and x.  So y' and x' are mutually recursive.  The Mul instance is
similar.

This may or may not be what you wanted on your original problem.
Note, however, that there's a plan B.  We can have different
definitions of CtxLitA and CtxInterpA, this time using 'Ctx Exp':

  class CtxLitB a where
ctxLitB :: Integer → Ctx Exp → a

  data CtxInterpB a = CIB {cibMake :: Ctx Exp → a
  ,cibExp  :: Exp}

Besides our function that creates 'a's, we also keep note of the
corresponding 'Exp' and use it to create the 'Ctx Exp' without mutual
recursion:

  instance CtxLitB a ⇒ Lit (CtxInterpB a) where
lit i = CIB (ctxLitB i) (lit i)

  instance Add a ⇒ Add (CtxInterpB a) where
add x y = CIB (λctx → let x' = cibMake x (AddL (cibExp y) ctx)
  y' = cibMake y (AddR (cibExp x) ctx)
   in x' `add` y')
  (add (cibExp x) (cibExp y))

The drawback of this approach should be obvious: we are tagging
everything =).  So this sort of defeats the tagless interpreter
approach.

I don't know if this solves your real problem, but it may be a start
=).  I'm attaching everything.

Cheers,

-- 
Felipe.
module Tagless where

class Lit a where lit :: Integer - a
class Add a where add :: a - a - a
class Mul a where mul :: a - a - a

instance Lit Integer where lit = fromInteger
instance Add Integer where add = (+)
instance Mul Integer where mul = (*)

-- Newtype so I don't need FlexibleInstances.
newtype Str = Str {unS :: String}
instance Show Str where show = show . unS

addStr x y = ( ++ x ++  +  ++ y ++ )
mulStr x y = ( ++ x ++  *  ++ y ++ )

instance Lit Str where lit = Str . show
instance Add Str where add x y = Str $ addStr (unS x) (unS y)
instance Mul Str where mul x y = Str $ mulStr (unS x) (unS y)

t1 :: (Lit a, Add a, Mul a) = a
t1 = (lit 3 `add` lit 4) `mul` lit 2




data Exp = Lit Integer
 | Add Exp Exp
 | Mul Exp Exp
   deriving (Show)

instance Lit Exp where lit = Lit
instance Add Exp where add = Add
instance Mul Exp where mul = Mul




data Ctx a = Empty
   | AddL a (Ctx a)
   | AddR a (Ctx a)
   | MulL a (Ctx a)
   | MulR a (Ctx a)
   deriving (Show)


-- First approach
-- Drawback: mutual recursion on the definition of add and mul.

class CtxLitA a where
  ctxLitA :: Integer - Ctx a - a

newtype CtxInterpA a = CIA {unCIA :: Ctx a - a}

instance CtxLitA a = Lit (CtxInterpA a) where
  lit = CIA . ctxLitA

instance Add a = Add (CtxInterpA a) where
  add x y = CIA (\ctx - let x' = unCIA x (AddL y' ctx)
 y' = unCIA y (AddR x' ctx)
 in x' `add` y')

instance Mul a = Mul (CtxInterpA a) where
  mul x y = CIA (\ctx - let x' = unCIA x (MulL y' ctx)
 y' = unCIA y (MulR x' ctx)
 in x' `mul` y')

fromCtxInterpA :: CtxInterpA a - a
fromCtxInterpA x = unCIA x Empty


-- Second approach
-- Drawback: have to maintain two representations

class CtxLitB a where
  ctxLitB :: Integer - Ctx Exp - a

data CtxInterpB a 

[Haskell-cafe] cabal install / upgrade (was: Re: some problem with Cabal)

2011-03-08 Thread Evan Laforge
 Generally, it shouldn't (and doesn't), but here some packages have to be
 reinstalled because they have to be built against different dependencies.

 I'd prefer cabal install to refuse here (overridable with a --force flag)
 because reinstalling boot libs (containers, filepath, directory, process,
 time) tends to be a bad idea.

Seconded!  I've had my setup screwed up because some package wanted to
recompile base against a tiny version bump on the random package for
whatever reason.  The presence of two bases with the same version, one
in the ghc dir and one in /usr/local/lib proceded to screw up all
kinds of things.  It took a long time to figure out because I wasn't
expecting two copies of base with the same version, and it somehow
managed to overwrite the package file in package.conf.d so the
original metadata was gone.  Eventually I gave up and reinstalled ghc.

And all I did was accidentally run cabal upgrade somepackage when I
wanted to install a newer version of somepackage.  By the time I
realized it was apparently still aliased to cabal break-everything and
hit ^C it was too late.

And it's not like I haven't been warned away from cabal upgrade
either... but it made me think, if the command is so dangerous, should
it have a scarier name?

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


Re: [Haskell-cafe] operations on lists with continuations

2011-03-08 Thread Evan Laforge
On Thu, Mar 3, 2011 at 12:33 AM, Mark Lentczner
mark.lentcz...@gmail.com wrote:
 To make up for my total misunderstanding of what you were asking
 before, I hereby offer you the Plumbing module, available here:
  https://bitbucket.org/mtnviewmark/haskell-playground/src/2d022b576c4e/Plumbing.hs

 With it, I think you can construct the kinds of pipelines you describe
 with the composition aspects you desire:

Indeed, it looks like a more thorough version of what I'm doing.  I'm
guessing the breaking into pairs thing would be ultimately more
composable, by which I mean lead to fewer special case functions.

 :load Plumbing.hs
 [1 of 1] Compiling Plumbing         ( Plumbing.hs, interpreted )
 Ok, modules loaded: Plumbing.
 let filterUntil cond start end = (passUntil (=start) =|= pfilter cond) =+= 
 passWhile (end)
 let filterUntilPlus1 cond start end = filterUntil cond start end =+= pass 1
 filterUntil even 10 15 `pump` [1..]
 [2,4,6,8,10,11,12,13,14]
 filterUntilPlus1 even 10 15 `pump` [1..]
 [2,4,6,8,10,11,12,13,14,15]

I would write the above as:

 let filterUntilPlus1 cond start end = Then.filter cond (=start) $ 
 Then.takeWhile (end) $ take 1
 filterUntilPlus1 even 10 15 [1..]
[2,4,6,8,10,11,12,13,14,15]

I think mine is less flexible but it interacts with the basic list
functions more directly so it feels simpler to me.  In a way it
reminds me of STM, in that as long as you leave the last continuation
on, it's still open and can be composed.  But to get the actual
result, you have to stick a non-continuation function on the end, at
which point it no longer composes.  I suppose that's the model for
many many little DSLs though.

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


Re: [Haskell-cafe] operations on lists with continuations

2011-03-08 Thread Evan Laforge
On Wed, Mar 2, 2011 at 12:00 AM, Stephen Tetley
stephen.tet...@gmail.com wrote:
 Maybe you've invented the ApoPrelude?

 If I were doing it I'd probably code them in terms of an apomorphism -
 unfoldr with flush. Unlike regular unfoldr which discards the final
 state, an apomorphism uses the final state to produce the tail of the
 output list. See Jeremy Gibbons paper Streaming
 representation-changers section 4.4.

 http://www.comlab.ox.ac.uk/jeremy.gibbons/publications/

Interesting, thanks for the link.  Indeed it looks like a special case
of a general concept someone has already gotten a fair bit of milage
out of :)

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


Re: [Haskell-cafe] Haskell Platform 2011.2

2011-03-08 Thread Joachim Breitner
Hi,

Am Samstag, den 05.03.2011, 17:22 -0800 schrieb Don Stewart:
 We're currently testing the installers, with a view to announcing the
 release early in the week.

I thought
http://code.haskell.org/haskell-platform/haskell-platform.cabal
was the repository for the current darcs version of the platform, but
now I also find
http://code.galois.com/darcs/haskell-platform/haskell-platform.cabal

Which one is to be used?

Greetings,
Joachim

-- 
Joachim nomeata Breitner
Debian Developer
  nome...@debian.org | ICQ# 74513189 | GPG-Keyid: 4743206C
  JID: nome...@joachim-breitner.de | http://people.debian.org/~nomeata


signature.asc
Description: This is a digitally signed message part
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe