Re: [GHC] #810: GHC complains about missing instance in conjunction with GADTs
#810: GHC complains about missing instance in conjunction with GADTs --+- Reporter: [EMAIL PROTECTED] | Owner: simonpj Type: bug | Status: closed Priority: normal| Milestone: 6.8 Component: Compiler |Version: 6.4.1 Severity: normal| Resolution: fixed Keywords:| Difficulty: Unknown Testcase: gadt20| Architecture: x86 Os: Linux | --+- Changes (by simonpj): * resolution: = fixed * status: new = closed Comment: I think this is actually ok in 6.6, and in any case I'm fixing the type- class interaction, and we have a test case to remind us if it goes bad on us. So I'm closing this bug. Simon -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/810 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
[GHC] #973: Adding Arbitrary instance for Either
#973: Adding Arbitrary instance for Either --+- Reporter: guest | Owner: Type: proposal | Status: new Priority: normal | Milestone: Component: libraries (other) | Version: 6.6 Severity: normal |Keywords: Difficulty: Unknown|Testcase: Architecture: Unknown| Os: Unknown --+- Have Either a b be an instance of Arbitrary when both a and b are instances of Arbitrary. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/973 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
Re: [GHC] #973: Adding Arbitrary instance for Either
#973: Adding Arbitrary instance for Either ---+ Reporter: guest | Owner: Type: proposal | Status: new Priority: normal | Milestone: Component: libraries (other) |Version: 6.6 Severity: normal | Resolution: Keywords: | Difficulty: Unknown Testcase: | Architecture: Unknown Os: Unknown| ---+ -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/973 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
Re: [GHC] #960: Lexical call site string
#960: Lexical call site string +--- Reporter: [EMAIL PROTECTED] | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler|Version: 6.6 Severity: normal | Resolution: Keywords: | Difficulty: Unknown Testcase: | Architecture: Unknown Os: Unknown | +--- Comment (by simonpj): You're asking for a function; but what is this function called, and what is its type? In general it's not clear (to me) exactly what you are proposing; or whether it is implementable. Clarification welcome! -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/960 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
Re: [GHC] #973: Adding Arbitrary instance for Either
#973: Adding Arbitrary instance for Either ---+ Reporter: guest | Owner: Type: proposal | Status: closed Priority: normal | Milestone: Component: libraries (other) |Version: 6.6 Severity: normal | Resolution: fixed Keywords: | Difficulty: Unknown Testcase: | Architecture: Unknown Os: Unknown| ---+ Changes (by ross): * resolution: = fixed * status: new = closed -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/973 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
[GHC] #974: Add isLeft, isRight, fromLeft, fromRight, and splitEithers to Data.Either
#974: Add isLeft, isRight, fromLeft, fromRight, and splitEithers to Data.Either ---+ Reporter: guest | Owner: Type: proposal| Status: new Priority: normal | Milestone: Component: libraries/base | Version: 6.6 Severity: normal |Keywords: Difficulty: Unknown |Testcase: Architecture: Unknown | Os: Unknown ---+ This proposal would add basic functionality to `Either` similar to that for `Maybe`. The `splitEithers` function of type `[Either a b] - ([a],[b])` is unique; however, it seems to be a widely useful function. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/974 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
Re: [GHC] #974: Add isLeft, isRight, fromLeft, fromRight, and splitEithers to Data.Either
Hi #974: Add isLeft, isRight, fromLeft, fromRight, and splitEithers to Data.Either Woohoo! Finally! This proposal would add basic functionality to `Either` similar to that for `Maybe`. The `splitEithers` function of type `[Either a b] - ([a],[b])` is unique; however, it seems to be a widely useful function. This (in my mind) is a parallel to unzip? unzipEithers to me gives a much clearer picture of what is going on here. Thanks Neil ___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
Re: [GHC] #959: Debugging info(?) leaks out: Urk! Inventing strangely-kinded void TyCon
#959: Debugging info(?) leaks out: Urk! Inventing strangely-kinded void TyCon -+-- Reporter: igloo| Owner: Type: bug | Status: new Priority: lowest | Milestone: _|_ Component: Compiler (Type checker) |Version: 6.6 Severity: minor| Resolution: Keywords: | Difficulty: Unknown Testcase: | Architecture: Unknown Os: Unknown | -+-- Changes (by simonpj): * milestone: 6.6.1 = _|_ * priority: normal = lowest * severity: normal = minor Comment: The leakage is actually deliberate. In this program there is nothing to fix 'm' in the call to 'foo', so GHC makes up a fake type constructor, of kind (*-*)-*, and uses that at the call to foo. Now the trouble is that if this fake type constructor should show up in an interface file, GHC would not recognise the type constructor when reading the interface. So I left the warning in, so that people would yell if it actually happened. This is really a bug, and I'm sure there's a way round it, but it has not occurred in a real program so far, so I've been postponing fixing it, and propose to continue to postpone. The relevant code is in `TcHsSyn.mkArbitraryType` -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/959 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
Re: [GHC] #932: Improve inlining
#932: Improve inlining --+- Reporter: simonpj | Owner: Type: task | Status: new Priority: normal| Milestone: 6.6.1 Component: Compiler |Version: 6.4.2 Severity: normal| Resolution: Keywords:| Difficulty: Unknown Testcase: N/A | Architecture: Unknown Os: Unknown | --+- Changes (by samb): * cc: samb = samb simonpj -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/932 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
Re: [GHC] #960: Lexical call site string
#960: Lexical call site string +--- Reporter: [EMAIL PROTECTED] | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler|Version: 6.6 Severity: normal | Resolution: Keywords: | Difficulty: Unknown Testcase: | Architecture: Unknown Os: Unknown | +--- Comment (by simonpj): A neat way to do this might be to extend Template Haskell slightly, to provide {{{ currentLocation :: Q (Filepath, Int) }}} giving the filename and location of the current splice. (This is rather similar to the existing Template Haskell function [http://www.haskell.org/ghc/docs/latest/html/libraries/template-haskell /Language-Haskell-TH-Syntax.html#v%3AcurrentModule currentModule].) Then you could define {{{ callSite :: ExpQ callSite = do { (f,n) - currentLocation ; return (LitE (StringL (f ++ : ++ show n))) } }}} And use it thus: {{{ error (woggle at ++ $callSite) }}} Since the Template Haskell splice `$callSite` is a TH splice, it's ok for it to grab contextual information. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/960 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
Re: [GHC] #960: Lexical call site string
#960: Lexical call site string +--- Reporter: [EMAIL PROTECTED] | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler|Version: 6.6 Severity: normal | Resolution: Keywords: | Difficulty: Unknown Testcase: | Architecture: Unknown Os: Unknown | +--- Comment (by pauljohnson): I haven't studied Template Haskell, but won't that just give the location of the error call? I want the place the enclosing function was called from. So if head calls error I want to see what called head. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/960 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
[GHC] #975: Allow quoting of the file path in :load command
#975: Allow quoting of the file path in :load command ---+ Reporter: [EMAIL PROTECTED] | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: GHCi| Version: 6.4.2 Severity: normal |Keywords: Difficulty: Unknown |Testcase: Architecture: x86 | Os: Windows ---+ haskell-mode (version v2_1 distributed with XEmacs 21.4.13 on Windows) puts quotes around the full path of the file given as the argument to GHCi's :load command, which doesn't work. It seems like it would be a useful feature to be able to handle such paths, especially if the path contains spaces. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/975 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
Re: [GHC] #975: Allow quoting of the file path in :load command
#975: Allow quoting of the file path in :load command +--- Reporter: [EMAIL PROTECTED] | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: GHCi|Version: 6.4.2 Severity: normal | Resolution: Keywords: | Difficulty: Unknown Testcase: | Architecture: x86 Os: Windows | +--- Comment (by guest): I just upgraded to 6.6 and it's not a problem, except for the fact that XEmacs is passing backslashes in the path, which GHCi is interpreting as string escapes. Should :load be changed to use a platform's native path separator? -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/975 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
RE: improving error messages
| as you may remember, in GHC survey awkward error messages was named as | one of most serious GHC drawbacks. i propose to start collecting | examples of bad error messages together with what we want to see in | these cases. as first contribution, i've added this text as | http://hackage.haskell.org/trac/ghc/ticket/956 Thank you! It'll be very useful to have such a collection. Simon ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
RE: [Hugs-users] Record puns, time for removal?
| There was some discussion on the haskell' list about bring back | record puns, which were once in ghc. | | Record punning would have been very helpful on one of my recent | projects, where I had some large arrays of statically initialized | records. | The longFieldSelectorNamesToAvoidNamespaceClashes are just | noise is such a case. I always thought it was a mistake to remove record puns in H98. I would not be against re-introducing them into GHC, since they appear to remain in Hugs and are in Yhc. Simon ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: OpenGL failing with Mac Intel 6.6 distribution
On Oct 30, 2006, at 8:47 AM, Deborah Goldsmith wrote: Since the files are not in the distribution itself, they can hardly be installed. :-) It looks like the Mac OS X Intel distribution has a problem. I'll check the PPC distribution later to see if it has the same problem. I checked and the Mac OS X PowerPC binary distribution does not have this problem; only Mac OS X Intel. Deborah ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: Bad control characters in GHCi 6.6 (Mac OS X PPC)
On Oct 23, 2006, at 8:59 AM, Björn Buckwalter wrote: On 10/19/06, Simon Marlow [EMAIL PROTECTED] wrote: See this page that I just created: http://hackage.haskell.org/trac/ghc/wiki/Building/MacOSX I tried these instructions, first by using my existing (darwinports) readline in /opt/local, and when that failed by first installing readline in /usr/local per the instructions. Neither fixed the problem. I don't know why but perhaps I failed to remove the traces of my initial install completely. In the end I gave up and installed Greg Heartsfield's binary package which remedied my problems (thanks Greg!). I think I have this partially figured out. When I install version 5.1 of readline, rl_readline_version is defined as follows in readline/readline.h: /* */ /* */ /* Well Published Variables*/ /* */ /* */ /* The version of this incarnation of the readline library. */ extern const char *rl_library_version; /* e.g., 4.2 */ extern int rl_readline_version; /* e.g., 0x0402 */ However, in ghc-6.6, libraries/readline/configure has the following: cat conftest.$ac_ext _ACEOF /* end confdefs.h. */ /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern C #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char rl_readline_version (); int main () { rl_readline_version (); ; return 0; } _ACEOF which is looking for rl_readline_version as a *function*. This fails (at the link stage on Darwin/Intel), even though GNU readline is installed, because the symbol type is wrong. The configure script concludes that libedit is being used, even though it's using GNU Readline v5.1. Was rl_readline_version a function in earlier versions of GNU Readline? Deborah ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: [Hugs-users] Record puns, time for removal?
On Mon, Oct 30, 2006 at 12:11:23PM -, Simon Peyton-Jones wrote: I always thought it was a mistake to remove record puns in H98. I would not be against re-introducing them into GHC, since they appear to remain in Hugs and are in Yhc. yes. jhc has them too and I wish ghc did. puns like Foo { .. } would be great too. I made this page on the wiki to record fixes to the record system: http://haskell.galois.com/cgi-bin/haskell-prime/trac.cgi/wiki/ExistingRecords most would be pretty straightforward to implement. John -- John Meacham - ⑆repetae.net⑆john⑈ ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: [Hugs-users] Record puns, time for removal?
On Mon, 30 Oct 2006 16:30:42 -0800 John Meacham [EMAIL PROTECTED] wrote: On Mon, Oct 30, 2006 at 12:11:23PM -, Simon Peyton-Jones wrote: I always thought it was a mistake to remove record puns in H98. I would not be against re-introducing them into GHC, since they appear to remain in Hugs and are in Yhc. yes. jhc has them too and I wish ghc did. puns like Foo { .. } would be great too. I'd vote for enabling them with a command line switch, rather than by default, as they can be confusing to folks learning the language. Seth I made this page on the wiki to record fixes to the record system: http://haskell.galois.com/cgi-bin/haskell-prime/trac.cgi/wiki/ExistingRecords most would be pretty straightforward to implement. John -- John Meacham - ⑆repetae.net⑆john⑈ ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: [Hugs-users] Record puns, time for removal?
Hi puns like Foo { .. } would be great too. I'd vote for enabling them with a command line switch, rather than by default, as they can be confusing to folks learning the language. How discussions come full circle :) I started this discussion on the Hugs users list because I want to _remove_ the command line switch for puns from Yhc. I'm not overly fussed whether I remove the entire feature, or just remove the command line and make it always on by default, but I do want the command line switch gone! Interestingly now there seems to be a sudden body of people coming out the woodwork who want this feature - so perhaps this should be sorted for Haskell'. Thanks Neil ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: [Haskell] Re: package mounting
On 10/30/06, Frederik Eaton [EMAIL PROTECTED] wrote: On Sun, Oct 29, 2006 at 10:03:32PM -0400, Samuel Bronson wrote: On 10/25/06, Frederik Eaton [EMAIL PROTECTED] wrote: http://hackage.haskell.org/trac/ghc/wiki/PackageMounting It looks nice, but don't you think the -package-base flag ought to take both the package name *and* the mountpoint? My intention was that -package-base specifies a base for the package specified in the preceding -package flag, but I'll clarify it in the document. In other words, it is an optional argument and the syntax is ghc ... -package PACKAGE -package-base BASE ... (giving package PACKAGE mount point BASE) Otherwise, this looks like what I've wanted all along, if only I knew it ;-). Excellent, thanks. What about packages with multiple module trees like, say, Cabal? -- Cheers, Lemmih ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
[Haskell] Re: package mounting
Frederik Eaton [EMAIL PROTECTED] writes: It looks nice, but don't you think the -package-base flag ought to take both the package name *and* the mountpoint? My intention was that -package-base specifies a base for the package specified in the preceding -package flag [...] In other words, it is an optional argument and the syntax is ghc ... -package PACKAGE -package-base BASE ... How about something like ghc ... -package [EMAIL PROTECTED] (where the @BASE part is optional)? -k -- If I haven't seen further, it is by standing in the footprints of giants ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
Re: [Haskell] Re: package mounting
What about packages with multiple module trees like, say, Cabal? That's a good question, and I think the right answer is not to do anything special to support them. I assume that what you're referring to with Cabal is that there is no common prefix for all of the module names, but rather a small set of common prefixes (Distribution.*, Language.Haskell.Extension). Under my proposal, if we want to get rid of the 'Distribution' module prefix within the Cabal source code, then we'll have to either rename the Language.Haskell.Extension module, or move it to another package. Best, Frederik -- http://ofb.net/~frederik/ ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
[Haskell] RE: package mounting
| http://hackage.haskell.org/trac/ghc/wiki/PackageMounting | | It looks nice, but don't you think the -package-base flag ought to | take both the package name *and* the mountpoint? | | Otherwise, this looks like what I've wanted all along, if only I knew it ;-). I think most of you know that GHC 6.6 made (IHMO) a significant step forward, by allowing a program to contain multiple modules with the same name, if they are from different packages. That means that package authors can choose module names freely, rather than worry about accidentally colliding with other packages. (We'd regard it as unacceptable if the local variables of a function could not have the same name as the local variables of another procedure!) That still leaves an open question, not resolved by GHC 6.6: what to do if you want to import module M from two different packages into the same module? (A related question is when you have to decide what your module is called.) This can be tackled in at least three different ways, one being Frederik's proposal. Simon and I are not wedded to any particular one, and we'd welcome a consensus on what to do. The state of play is summarised here http://hackage.haskell.org/trac/ghc/wiki/GhcPackages which includes a link to the package-mounting proposal. If you care about this stuff, do debate it -- and please record points that survive a bit of discussion on the Wiki pages. None of this is very hard to implement; the difficulty is settling on a good design. Simon ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
[Haskell] University of Oxford: Lectureships in Software Engineering
UNIVERSITY OF OXFORD Software Engineering Programme Kellogg College THREE UNIVERSITY LECTURERSHIPS IN SOFTWARE ENGINEERING Applications are invited for three new University Lecturerships in Software Engineering. The successful applicants will join the staff of the University's Software Engineering Programme in teaching and researching the application of scientific principles to the development of software systems. The salary will be on a scale up to GBP50,589 per annum. An advanced degree in a related subject, proven teaching ability, and a strong research record - of international standing - are all essential requirements. Applications are particularly welcome from those with expertise in software and systems security, service-oriented architectures, or model-driven development. The appointments will be associated with fellowships at Kellogg College, Oxford and the appointees will be members of the Governing Body of the college. The closing date for applications is 27th November 2006. For further information, including full details of the application procedure and selection criteria, see http://www.softeng.ox.ac.uk/jobs/ ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
[Haskell] RE: package mounting
Simon Peyton-Jones wrote: | http://hackage.haskell.org/trac/ghc/wiki/PackageMounting | | It looks nice, but don't you think the -package-base flag ought to | take both the package name *and* the mountpoint? | | Otherwise, this looks like what I've wanted all along, if only I knew it ;-). I think most of you know that GHC 6.6 made (IHMO) a significant step forward, by allowing a program to contain multiple modules with the same name, if they are from different packages. That means that package authors can choose module names freely, rather than worry about accidentally colliding with other packages. I think this is true only in a very technical sense. I fear that in practice, library authors will go to great lengths to avoid such overlapping module names, because introducing them will cause too much difficulties for library users. The only way to make halfway sure that this doesn't happen is to use (fixed) module hierarchy prefixes containing (more or less) the package name, as in Text.ParserCombinators.Parsec, even though technically they aren't forced to do so. (We'd regard it as unacceptable if the local variables of a function could not have the same name as the local variables of another procedure!) Yes, but this analogy seems to cover only the problem with internal (package-local, non-exposed) modules. To widen your analogy, we'd regard it as similarly unacceptable if we had to qualify each exported entity with the module name each time we use them, even if we are inside the module that defines them, wouldn't we? Which is today's situation on the package/module level: We have to completely qualify module names with their mount point in the module hierarchy, even when refering to them from inside the package that defines them. I see, however, one point with Frederik's proposal that isn't clear to me: Assume library A uses library B. Then, presumably, lib A must chose a mount point for its use of lib B. Now imagine a program P wants to use lib A as well as directly import some module from lib B. Is P now free to give lib B its own mount point, independent of the one that was chosen by lib A? I think this should definitely be possible. There may, however, be some issues regarding implementation: Can a compilation system share code between both 'versions' of lib B (I assume they are /not/ really different versions but exactly the same one, only referred to via a different 'mount point')? Hmm, maybe this isn't really a problem. The compiler could simply alias the module names, similar as to what it does for 'import M as N'. That still leaves an open question, not resolved by GHC 6.6: what to do if you want to import module M from two different packages into the same module? What if I want to import them into /different/ modules (which are nevertheless part of the same package)? Can this be easily accomplished with ghc-6.6? Cheers Ben ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
[Haskell] Associated data types in GHC
Dear Haskell Folks This is to announce the availability of indexed data types, a modest extension of our earlier proposal for associated data types[1], in GHC's development version. Detailed information on where to get the right GHC and how to use indexed types is available from the Haskell wiki: http://haskell.org/haskellwiki/GHC/Indexed_types This is an experimental feature and any feedback is greatly appreciated. NB: The implementation of associated type *synonyms* is *not* complete yet. We are working on this now. Happy Hacking! Manuel [1] http://www.cse.unsw.edu.au/~chak/papers/CKPM05.html ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
[Haskell] Haskell Weekly News: October 31, 2006
--- Haskell Weekly News http://haskell.org/haskellwiki/HWN Issue 47 - October 31, 2006 --- Welcome to issue 47 of HWN, a weekly newsletter covering developments in the Haskell community. This week we see a number of community documentation and maintenance efforts, and the appearance of indexed data types in GHC Announcements * Associated data types in GHC. Manuel Chakravarty [1]announced the availability of indexed data types, an extension of our earlier proposal for [2]associated data types, in GHC's development version. Detailed information on where to get the right GHC and how to use indexed types is available from [3]the Haskell wiki. 1. http://article.gmane.org/gmane.comp.lang.haskell.general/14447 2. http://www.cse.unsw.edu.au/~chak/papers/CKPM05.html 3. http://haskell.org/haskellwiki/GHC/Indexed_types * Yhc Bytecode library 0.3. Robert Dockins [4]announced the release of the [5]Yhc Bytecode library, version 0.3. 4. http://article.gmane.org/gmane.comp.lang.haskell.general/14434 5. http://www.eecs.tufts.edu/~rdocki01/yhc-bytecode.html * Haskell Program Coverage. Andy Gill [6]checked the latest version of HPC, with GHC support, into the head GHC branch 6. http://www.galois.com/~andy/ray/hpc.html * Haskell Mersenne Twister. Lennart Augustsson [7]made available his Haskell implementation of the Mersenne Twister random number generator. 7. http://www.augustsson.net/Darcs/MT/ * Haskell-specific Google Search Engine. Don Stewart [8]initialised a Haskell-specific search engine, as part of Google's coop engine system, which seems to do a good job of targeting just Haskell sites, in particular, mailing list items 8. http://www.google.com/coop/cse?cx=015832023690232952875%3Acunmubfghzq * A process for submitting library extensions. The libraries hackers [9]have developed [10]a document describing how to best go about contributing new code to the core Haskell libraries. On a similar note, the GHC team has prepared [11]a page on best practice for GHC submissions. 9. http://article.gmane.org/gmane.comp.lang.haskell.libraries/5368 10. http://haskell.org/haskellwiki/Library_submissions 11. http://hackage.haskell.org/trac/ghc/wiki/WorkingConventions * How to create a Haskell project. Don Stewart and Ian Lynagh [12]prepared some guidelines on starting your own Haskell project. 12. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/16164/focus=16164 Haskell' This section covers the [13]Haskell' standardisation process. * [14]Lambda-match vs PMC * [15]Indentation of If-Then-Else * [16]Digit groups 13. http://hackage.haskell.org/trac/haskell-prime 14. http://thread.gmane.org/gmane.comp.lang.haskell.prime/1815/focus=1815 15. http://thread.gmane.org/gmane.comp.lang.haskell.prime/1791/focus=1791 16. http://thread.gmane.org/gmane.comp.lang.haskell.prime/1763/focus=1781 Discussion * Haskell Quiz/Ruby Quiz. Haskell Hackers [17]have started recording Ruby Quiz solutions on the Haskell wiki. Lots of fun puzzles are available, and its a useful resource if you're learning the language. 17. http://haskell.org/haskellwiki/Haskell_Quiz * Infinite, open, statically constrained HLists. Oleg Kiselyov [18]described heterogeneous sequences that admit infinite sequences and permits post-hoc addition of new elements, even to an already infinite sequence. 18. http://article.gmane.org/gmane.comp.lang.haskell.general/14424 * Lexically scoped type variables: new proposal. Ben Rudiak-Gould [19]made a new for scoped type variables. 19. http://article.gmane.org/gmane.comp.lang.haskell.general/14429 * Simple GADT parser for the eval example. Greg Buchholz [20]sought advice on creating evaluators with GADTs 20. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/16178/focus=16178 * Package mounting. Frederik Eaton [21]proposed an alternative [22]design for package mounting extensions to the package system. 21. http://article.gmane.org/gmane.comp.lang.haskell.libraries/5389 22. http://hackage.haskell.org/trac/ghc/wiki/PackageMounting * Function types as instances of Num. Greg Buchholz [23]had an interesting problem using functions as instances of Num 23. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/16129/focus=16129 * Yhc Core file generation. Neil Mitchell [24]suggested that it was time to start taking YHC Core output a bit more seriously, and made some proposals. 24. http://thread.gmane.org/gmane.comp.lang.haskell.yhc/397/focus=397 * Parallelism in GHC 6.6 and seq vs. pseq. Simon Marlow [25]noticed
Re: digit groups
On 2006-10-26, Jon Fairbairn [EMAIL PROTECTED] wrote: On 2006-10-25 at 20:57- Aaron Denney wrote: On 2006-10-25, Jon Fairbairn [EMAIL PROTECTED] wrote: No. A small alteration to the lexical syntax for the sake of improved readability seems perfectly justifiable as long as it doesn't make the lexical syntax /significantly/ more complicated or harder to learn. Sure. But some of us don't find it terribly readable. I'm not sure what you are saying here. Assessing readability by introspection is terribly unreliable. Unfamiliarity with the presentation of numbers with underlines is likely to make them feel a bit awkward to begin with, but habituation is likely to change that. Fair enough, I don't actually find it less readable, merely quite ugly. I might indeed get used to it. I think the ~~ operator hack gets 90% of the benefit for those who want it. I thought my earlier message adequately demonstrated that it does /not/. You demonstrated some corner cases that weren't convincing at all. Another case: if you change âsquare 123479010987â to âsquare 123_479_010_987â to improve readability it still means the same thing. If you change it to âsquare 123~~479~~010~~987â it doesn't. This is a bit more convincing. -- Aaron Denney -- ___ Haskell-prime mailing list Haskell-prime@haskell.org http://www.haskell.org/mailman/listinfo/haskell-prime
Re: lambda-match vs PMC
lambda-abstraction doesn't even exist at expression level, but is replaced by spliced matching; application exists, but is not needed, because (f e) = {| e | {| f |} |} (unless I'm mistaken?) oops, wrong brackets around f - should be: {| e | ^f^ |} -- {| ^f e^ |} -- f e with f supposedly being a lambda abstraction ( \v.b ) represented as a match ( {| v = ^b^ |} ), we get: f e = {| v = ^b^ |} e -- {| e | v = ^b^ |} -- {| ^b^[ v\a ] |} -- b[ v\a ] as seen on page 3 of the MPC2006 paper, also showing that application reduces to argument supply, which provides beta reduction. claus ___ Haskell-prime mailing list Haskell-prime@haskell.org http://www.haskell.org/mailman/listinfo/haskell-prime
Re: Re[2]: [Hugs-users] Record puns, time for removal?
Funny that you should mention this idea. I spent last night and this morning implementing it in ghc. But I use '..' instead of '*'. The punning is available both for expressions and patterns. I am of two minds about this extension. It introduces bound variables without mentioning the variable at the binding site. This can be error prone. (But 'import' has similar problems.) Dubious as it is, when using large records it reduces the amount of boiler place code significantly. -- Lennart On Oct 30, 2006, at 16:20 , Bulat Ziganshin wrote: Hello Simon, Monday, October 30, 2006, 3:11:23 PM, you wrote: I always thought it was a mistake to remove record puns in H98. I would not be against re-introducing them into GHC, since they appear to remain in Hugs and are in Yhc. what you (and all) think about wildcarded puns: data Command = Command { cmd_name :: !String , cmd_arcspec :: String , cmd_arclist :: [FilePath] , cmd_arcname :: FilePath , cmd_arc_filter :: !(FileInfo - Bool) , cmd_filespecs:: ![String] , cmd_added_arcnames :: !(IO [FilePath]) , cmd_diskfiles:: !(IO [FileInfo]) , cmd_subcommand :: !Bool } process_cmd (Command{*}) = do print cmd_name ... because Haskell encourage using of structure name as part of field's name, this will not create mess (at least for my programs), it will work like Pascal's 'with' operator -- Best regards, Bulatmailto:[EMAIL PROTECTED] ___ Haskell-prime mailing list Haskell-prime@haskell.org http://www.haskell.org/mailman/listinfo/haskell-prime ___ Haskell-prime mailing list Haskell-prime@haskell.org http://www.haskell.org/mailman/listinfo/haskell-prime
Re: proposal: introduce lambda-match (explicit match failure andfall-through)
name: introduce lambda-match (explicit match failure and fall-through) Dear All, may I be so optimistic as to interpret the absolute lack of counter arguments over the last week as indication that this proposal is acceptable in general? Thanks to those few who have expressed support so far, usually in the form I've wanted something like this for years! (*) I have braved the evil trac-wiki formatter again, to convert the email proposal into a slightly updated ticket, with attached patch for GHC, support libraries and usage examples: introduce lambda-match (explicit match failure and fall-through) http://hackage.haskell.org/trac/haskell-prime/ticket/114 most notable updates are in the support library (now being a bit more helpful in preserving error messages and defining fall_through cases; also supports joining of nested matches now), with a few added examples demonstrating the changes. It is a good sign that the syntax patch itself has not changed so far, and the support library now supports most of what I had in mind for it (took me a while to figure out how to do nest ;-). But it would be very helpful if more eyes looked over the code, to see if the functionality is roughly right (not to mention the implementation). And, of course, syntax patches for other Haskell implementations would be great (at least verify whether your favourite implementation can handle the support library, please - so far verified for GHC and Hugs)! Thank you, Claus ps. a quick recap for those who don't read webpages: a lambda-match | patterns | guards - expr is syntactic sugar for \ parameters - case parameters of { patterns | guards - Match $ return expr ; _ - Match $ fail lambda-match failure } which allows us to program explicitly with match failure (represented as Monad.fail/MonadPlus.mzero) and match fall-through (using MonadPlus.mplus), lifting MonadPlus operations over function parameters for ease of use. this enables us to write previously practically impossible things (the example file gives some indication of just how unreadable and hence unusable these would be without syntactic sugar), such as a user-defined case-variant (included in the library): caseOf True $ ( |True- False ) +++ ( |False- True ) -- False or monadic match-failure without using do-notation: return True = (ok $ |False- return hi) :: Maybe String -- Nothing lambda-matches may be nested, but unlike PMC, that will usually result in nested match monads, unless we use the new nest to join the nested monads: myAnd = splice (nest (|True- (|True-True) +++ (|False-False)) +++ nest (|False- fall_through False) ) we can now also abstract over groups of match alternatives: grp :: MonadPlus m = String - [(String, String)] - Match m String grp = (| x locals | Just y - lookup x locals - y) +++ (| X locals - 42) +++ matchError var not found and extend them later, or just use them to build different functions: -- select only the first match varVal :: String - [(String, String)] - String varVal = spliceE grp -- a variation, delivering all successful matches varVals :: String - [(String, String)] - [] String varVals = allMatches grp leading to uses like these: *Main varVal X [(X,hi)] hi *Main varVal Z [(X,hi)] *** Exception: var not found *Main varVals X [(X,hi)] [hi,42] *Main varVals Z [(X,hi)] [] and so on, and so on.. see the proposal attachments for more inspirations !-) (*) it might be useful for the Haskell' committee to clarify the process for acceptance of proposals, similar to what the Haskell library community has done recently: http://haskell.org/haskellwiki/Library_submissions (where the intent of the discussion period is to focus the process, and to ensure progress, ie lack of objections to a clearly implementable/implemented proposal is seen as implicit agreement) ___ Haskell-prime mailing list Haskell-prime@haskell.org http://www.haskell.org/mailman/listinfo/haskell-prime
Re: [Haskell-cafe] More documentation: how to create a Haskell project
[EMAIL PROTECTED] (Donald Bruce Stewart) writes: But we could do with more information on: [...] How to make cabal projects into distribution-specific (.deb, .rpm, and so on) packages? -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] mapAccumL - find max in-sequence subsequence
It's a pity that groupBy isn't defined a little differently: -- @'groupBy' rel xs@ returns the shortest list of lists such that -- -- * the concatenation of the lists is @xs@, and -- -- * @rel@ is 'True' for each consecutive pair of elements in a sublist. -- groupBy :: (a - a - Bool) - [a] - [[a]] groupBy rel [] = [] groupBy rel (x:xs) = (x:ys) : groupBy rel zs where (ys,zs) = groupByAux x xs groupByAux x0 (x:xs) | rel x0 x = (x:ys, zs) where (ys,zs) = groupByAux x xs groupByAux y xs = ([], xs) That's equivalent to the existing definition if rel is symmetric and transitive, but also useful in other cases, e.g. groupBy (=) would generate a list of runs, and the solution to the problem here would be longestInSequence :: (Enum a, Eq a) = [a] - Int longestInSequence = maximum . map length . groupBy adjacent where adjacent x y = succ x == y ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Deriving class instances using DrIFT
On 29.10 19:56, John Meacham wrote: Since DrIFT can only understand haskell source code, it can't derive instances for anything you don't have the original source to. such as things in the pre-compiled libraries that come with ghc. you will likely have to write out those instances by hand. Another possibility is that you could replicate just the data declarations by hand, and use DrIFT -r to just spit out the derivations and put those in a file on their own. How about using Template Haskell for getting the definition and then giving that to DrIFT? - Einar Karttunen ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] More documentation: how to create a Haskell project
Ketil Malde wrote: How to make cabal projects into distribution-specific (.deb, .rpm, and so on) packages? The answer for .debs is: ask a Debian developer (or a prospective developer) to package it for you. The reason is that to make a good .deb, one needs to be familiar with a lot of Debian-specific policies and technologies. If one is willing to invest the time and effort to learn this, then it makes sense for one to apply to become a Debian developer. If not, then packaging is best left for someone else. -- Antti-Juhani Kaijanaho, Debian developer ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] More documentation: how to create a Haskell project
On Mon, Oct 30, 2006 at 09:54:08AM +0100, Ketil Malde wrote: How to make cabal projects into distribution-specific (.deb, .rpm, and so on) packages? for slackware you can have a look to this slackBuild script: http://gorgias.mine.nu/repos/slackBuild/hxt/hxt/hxt.SlackBuild regards, andrea ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] More documentation: how to create a Haskell project
On 30/10/06, Tony Morris [EMAIL PROTECTED] wrote: 4) If you want links to base libraries in your haddock output, do such and such (how do you do that anyway?) I believe you need a local copy of the library sources, whose path you give to haddock with some flag. -- -David House, [EMAIL PROTECTED] ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re[2]: [Haskell-cafe] More documentation: how to create a Haskell project
Hello Tony, Monday, October 30, 2006, 6:22:31 AM, you wrote: My suggestion: The steps of reasoning as you start with a blank directory. For example: great idea! i'm sure that such sort of manual will be very helpful for anyone starting his first haskell project -- Best regards, Bulatmailto:[EMAIL PROTECTED] ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Simple GADT parser for the eval example
I'm trying to create a simple parser for the GADT evaluator from the wobbly types paper, and I need a little help. Here's the GADT and the evaluator... data Term a where Lit :: Int - Term Int Inc :: Term Int - Term Int IsZ :: Term Int - Term Bool If :: Term Bool - Term a - Term a - Term a Pair :: Term a - Term b - Term (a,b) Fst :: Term (a,b) - Term a Snd :: Term (a,b) - Term b eval :: Term a - a eval (Lit i)= i eval (Inc t)= eval t + 1 eval (IsZ t)= eval t == 0 eval (If b t e) = if eval b then eval t else eval e eval (Pair a b) = (eval a, eval b) eval (Fst t)= fst (eval t) eval (Snd t)= snd (eval t) ...and instead of writing my own read instance, I thought I'd take a shortcut and just try converting a regular data type to our generalized one... data Expr = ELit Int | EInc Expr | EIsZ Expr | EPair Expr Expr | EIf Expr Expr Expr | EFst Expr | ESnd Expr deriving (Read,Show) my_read' :: Expr - Term a my_read' (ELit a) = Lit a my_read' (EInc a) = Inc (my_read' a) my_read' (EIsZ a) = IsZ (my_read' a) my_read' (EPair a b) = Pair (my_read' a) (my_read' b) my_read' (EIf p t e) = If (my_read' p) (my_read' t) (my_read' e) my_read' (EFst a) = Fst (my_read' a) my_read' (ESnd a) = Snd (my_read' a) ...That looks nice and simple, but it doesn't type check. GHCi-6.6 complains... Couldn't match expected type `a' (a rigid variable) against inferred type `Int' `a' is bound by the type signature for `my_read' at eval_gadt_wobbly.hs:45:24 Expected type: Term a Inferred type: Term Int In the expression: Lit a In the definition of `my_read': my_read (ELit a) = Lit a ...No surprise there, since there is no way to fail in the event of a maltyped Expr. The next thing to try is a type class solution... class MyRead a where my_read :: Expr - Term a instance MyRead Int where my_read (ELit a) = Lit a my_read (EInc a) = Inc (my_read a) my_read (EIf p t e) = If (my_read p) (my_read t) (my_read e) my_read (EFst a) = Fst (my_read a :: MyRead b = Term (Int,b)) --my_read (ESnd a) = Snd (my_read a) instance MyRead Bool where my_read (EIsZ a) = IsZ (my_read a) my_read (EIf p t e) = If (my_read p) (my_read t) (my_read e) --my_read (EFst a) = Fst (my_read a) --my_read (ESnd a) = Snd (my_read a) instance (MyRead a, MyRead b) = MyRead (a,b) where my_read (EPair a b) = Pair (my_read a) (my_read b) my_read (EIf p t e) = If (my_read p) (my_read t) (my_read e) --my_read (EFst a) = Fst (my_read a) --my_read (ESnd a) = Snd (my_read a) This just about works, except for the definitions for the Fst and Snd constructors. The compiler complains... Ambiguous type variable `b' in the constraint: `MyRead b' arising from use of `my_read' at eval_gadt_wobbly.hs:65:28-36 Probable fix: add a type signature that fixes these type variable(s) ...Of course, that makes perfect sense, since, if we're applying Fst to a term, then we don't care about the other branch of the Pair. You can get it accepted by the type checker by making the types more concrete... my_read (EFst a) = Fst (my_read a :: Term (Int,Int)) ...or... my_read (EFst a) = Fst (my_read a :: Term (Int,Bool)) ...but how does a person fix this to work in the more general case? Or is this even the right way to build a parser for the GADT evaluator example? Notice the repetition needed: the If, Fst, and Snd defintions have to be copied to all three instances. Also, feel free to comment on this example, and the fact that it will evaluate with no problems. static_vs_laziness = eval (my_read (EIf (EIsZ (ELit 0)) (ELit 9) (EIsZ (ELit 42)))::Term Int) Thanks, Greg Buchholz ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] monadic performance
On 10/28/06, Tomasz Zielonka [EMAIL PROTECTED] wrote: On Fri, Oct 27, 2006 at 06:28:58AM -0700, Chad Scherrer wrote: Should I expect a monadic version to take a performance hit? What if I use some SPECIALIZE pragmas or somesuch? Is it more efficient to write one from scratch, or do specific type annotations give me the same thing anyway? That's good to hear, thanks! At this point my biggest concern is whether the strict parts and lazy parts will play nice. Everything about my data structure is strict, and thinking about how a Writer monad would interact with that just makes me confused, so far. -Chad ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Deriving class instances using DrIFT
On Monday 30 October 2006 22:18, Einar Karttunen wrote: On 29.10 19:56, John Meacham wrote: Since DrIFT can only understand haskell source code, it can't derive instances for anything you don't have the original source to. Ahhh, ok. such as things in the pre-compiled libraries that come with ghc. you will likely have to write out those instances by hand. Hmmm, seems strange that it can successfully derive for the Data.Maybe type but not the Data.Word32 type. I didn't think it would have access to any original source from my ghc install, there only seems to be hi files. Another possibility is that you could replicate just the data declarations by hand, and use DrIFT -r to just spit out the derivations and put those in a file on their own. How about using Template Haskell for getting the definition and then giving that to DrIFT? Thanks for the suggestions. Daniel ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Accumulating related XML nodes using HXT
Hello. I have some html from which I want to extract records. Each record is represented within a number of tr nodes, and all records tr nodes are contained by the same parent node. The things I've tried so far end up giving me the cartesian product of record fields, so for the html fragment included below I'd end up with: [ Prod Television 17 /prod17 A very nice telly. , Prod Television 17 /prod17 Mind your fillings. , Prod Cyclotron 24 /prod24 A very nice telly. , Prod Cyclotron 24 /prod24 Mind your fillings. ] instead of: [ Prod Television 17 /prod17 A very nice telly. , Prod Cyclotron 24 /prod24 Mind your fillings. ] How should I go about accumulating related tr nodes into individual records? Thanks Daniel HTML fragment follows: ... tr tr tdstrongProduct:/strong/td tdstronga href=/prod17Television/a/strong (code: 17)/td /tr tr tdstrongDescription:/strong/td tdA very nice telly./td /tr tr tdhr color=#0/td /tr tr tdstrongProduct:/strong/td tdstronga href=/prod24Cyclotron/a/strong (code: 24)/td /tr tr tdstrongDescription:/strong/td tdMind your fillings./td /tr tr tdhr color=#0/td /tr /tr ... ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Deriving class instances using DrIFT
On Tue, Oct 31, 2006 at 07:46:05AM +1300, Daniel McAllansmith wrote: Hmmm, seems strange that it can successfully derive for the Data.Maybe type but not the Data.Word32 type. I didn't think it would have access to any original source from my ghc install, there only seems to be hi files. It has a few data definitions built into it. Bool,Maybe,Either, and Ordering. see src/PreludData.hs for how that is done. John -- John Meacham - ⑆repetae.net⑆john⑈ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Simple GADT parser for the eval example
I don't have an answer, but would be extremely interested in knowing one! one of my first attempts to use GADTs was to do something similar, implemening the simple polymorphic lambda calculus in a way that transformations could be guarenteed typesafe statically, but then when I went and tried to write an interpreter, I couldn't figure out how to read in programs to interpret. it seems you would want something like first class existentials 'Exp (exists a . a)' or something like that. John -- John Meacham - ⑆repetae.net⑆john⑈ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Simple GADT parser for the eval example
Hi Greg, We've built some GADT parsers recently to fit our two-level transformation library with front-ends for for XML Schema and SQL. See Coupled Schema Transformation and Data Conversion For XML and SQL (PADL 2007) if you're interested. The trick is to use a constructor in which the a variable of Term a is existentially quantified. For example: data DynTerm where DynTerm :: Type a - Term a - DynTerm (I'm using GADT notation here, but normal ADT syntax would do just fine as well.) The first argument is the folklore GADT for representing types: data Type a where Int :: Type Int Bool :: Type Bool Prod :: Type a - Type b - Type (a,b) Then you can write your parser function with the following type: my_read' :: Expr - DynTerm Or, more likely: my_read' :: Expr - Maybe DynTerm with: my_read' (ELit a)= return $ DynTerm Int (Lit a) my_read' (EInc a)= do DynTerm Int a' - my_read' a return (DynTerm Int (Inc a')) Then you call eval something like: test :: Expr - Maybe Dynamic test expr = do DynTerm t a - my_read' expr return (Dyn t (eval a)) The Dynamic is defined as: data Dynamic where Dyn :: Type a - a - Dynamic The dynamic typing trick here is due to Swierstra and Baars. For further processing of the Dynamic result, you'll need to write functions with a type like: f :: Type a - a - X A typical example: gshow :: Type a - a - String gshow Int i = show i gshow Bool b = show b gshow (Prod a b) (x,y) = (++gshow a x++,++gshow b y++) Hope this helps. Source code is attached. Best, Joost On Oct 30, 2006, at 5:00 PM, Greg Buchholz wrote: I'm trying to create a simple parser for the GADT evaluator from the wobbly types paper, and I need a little help. Here's the GADT and the evaluator... data Term a where Lit :: Int - Term Int Inc :: Term Int - Term Int IsZ :: Term Int - Term Bool If :: Term Bool - Term a - Term a - Term a Pair :: Term a - Term b - Term (a,b) Fst :: Term (a,b) - Term a Snd :: Term (a,b) - Term b eval :: Term a - a eval (Lit i)= i eval (Inc t)= eval t + 1 eval (IsZ t)= eval t == 0 eval (If b t e) = if eval b then eval t else eval e eval (Pair a b) = (eval a, eval b) eval (Fst t)= fst (eval t) eval (Snd t)= snd (eval t) ...and instead of writing my own read instance, I thought I'd take a shortcut and just try converting a regular data type to our generalized one... data Expr = ELit Int | EInc Expr | EIsZ Expr | EPair Expr Expr | EIf Expr Expr Expr | EFst Expr | ESnd Expr deriving (Read,Show) my_read' :: Expr - Term a my_read' (ELit a) = Lit a my_read' (EInc a) = Inc (my_read' a) my_read' (EIsZ a) = IsZ (my_read' a) my_read' (EPair a b) = Pair (my_read' a) (my_read' b) my_read' (EIf p t e) = If (my_read' p) (my_read' t) (my_read' e) my_read' (EFst a) = Fst (my_read' a) my_read' (ESnd a) = Snd (my_read' a) ...That looks nice and simple, but it doesn't type check. GHCi-6.6 complains... Couldn't match expected type `a' (a rigid variable) against inferred type `Int' `a' is bound by the type signature for `my_read' at eval_gadt_wobbly.hs:45:24 Expected type: Term a Inferred type: Term Int In the expression: Lit a In the definition of `my_read': my_read (ELit a) = Lit a ...No surprise there, since there is no way to fail in the event of a maltyped Expr. The next thing to try is a type class solution... class MyRead a where my_read :: Expr - Term a instance MyRead Int where my_read (ELit a) = Lit a my_read (EInc a) = Inc (my_read a) my_read (EIf p t e) = If (my_read p) (my_read t) (my_read e) my_read (EFst a) = Fst (my_read a :: MyRead b = Term (Int,b)) --my_read (ESnd a) = Snd (my_read a)instance MyRead Bool where my_read (EIsZ a) = IsZ (my_read a) my_read (EIf p t e) = If (my_read p) (my_read t) (my_read e) --my_read (EFst a) = Fst (my_read a) --my_read (ESnd a) = Snd (my_read a) instance (MyRead a, MyRead b) = MyRead (a,b) where my_read (EPair a b) = Pair (my_read a) (my_read b) my_read (EIf p t e) = If (my_read p) (my_read t) (my_read e) --my_read (EFst a) = Fst (my_read a) --my_read (ESnd a) = Snd (my_read a) This just about works, except for the definitions for the Fst and Snd constructors. The compiler complains... Ambiguous type variable `b' in the constraint: `MyRead b' arising from use of `my_read' at eval_gadt_wobbly.hs:65:28-36 Probable fix: add a type signature that fixes these type variable(s) ...Of course, that makes perfect sense, since, if we're applying Fst to a term, then we don't care about the other branch of the Pair. You can get it accepted by the type checker by making the types more concrete... my_read (EFst a) = Fst (my_read a :: Term (Int,Int)) ...or... my_read (EFst a) = Fst (my_read a ::
Re: [Haskell-cafe] Simple GADT parser for the eval example
Just noticed Joost Visser's message but since I had (essentially a very similar) response I thought I might send it off as well ... It includes the conditional cases. Regards, -d {-# OPTIONS_GHC -fglasgow-exts #-} module Main where data Term a where Lit :: Int - Term Int Inc :: Term Int - Term Int IsZ :: Term Int - Term Bool If :: Term Bool - Term a - Term a - Term a Pair :: Term a - Term b - Term (a,b) Fst :: Term (a,b) - Term a Snd :: Term (a,b) - Term b data Expr = ELit Int | EInc Expr | EIsZ Expr | EPair Expr Expr | EIf Expr Expr Expr | EFst Expr | ESnd Expr deriving (Read,Show) -- Give a GADT for representation types data R a where Rint :: R Int Rbool :: R Bool Rpair :: R a - R b - R (a,b) -- Give an existential type with a type representation data TermEx where MkTerm :: R a - Term a - TermEx -- we use Weirich's higher-order type-safe cast to avoid deep traversals -- one can replace the type_cast with a more simple traversal-based -- version. data CL c a d = CL (c (d,a)) data CR c a d = CR (c (a,d)) type_cast :: forall a b c. R a - R b - c a - c b type_cast Rint Rint x = x type_cast Rbool Rbool x = x type_cast (Rpair (ra::(R a0)) (rb::(R b0))) (Rpair (ra'::(R a0')) (rb'::(R b0'))) x = let g = (type_cast ra ra' :: ( (CL c b0) a0 - (CL c b0) a0' )) h = (type_cast rb rb' :: ( (CR c a0') b0 - (CR c a0') b0')) in case (g (CL x)) of CL x' - case (h (CR x')) of CR y' - y' type_cast _ _ _ = error cannot cast! -- give only the cases for Eif and Elit, the others are similar my_read :: Expr - TermEx my_read (ELit i) = MkTerm Rint (Lit i); my_read (EIf p t e) = case (my_read p) of MkTerm rb b - case rb of Rbool - case (my_read t) of MkTerm r1 t1 - case (my_read e) of MkTerm r2 t2 - MkTerm r2 (If b (type_cast r1 r2 t1) t2) _ - error conditional not boolean! ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] YAHT: searchAll5
I can't get searchAll5[1] in Yet Another Haskell Tutorial to run. Ghci complains that it can't find a MonadPlus that satisfies the required type; it needs a MonadPlus. I suspect this is due to the use of 'mzero' and 'mplus', without making StateT a MonadPlus. My thought for this was to push mzero into the inner monad and have 'mplus' pass on to the inner monad: instance Monad m = MonadPlus (StateT state m) where mzero = StateT (\s - return (s, mzero)) (StateT m1) `mplus` (StateT m2) = StateT (\s - do (s1, a) - m1 s (s2, b) - m2 s1 return (s2, a `mplus` b)) What's above isn't accepted by ghci, and I don't even know for sure that my thought makes sense. /M [1]: http://en.wikibooks.org/wiki/Haskell/YAHT/Monads#Monad_Transformers -- Magnus Therning (OpenPGP: 0xAB4DFBA4) [EMAIL PROTECTED] Jabber: [EMAIL PROTECTED] http://therning.org/magnus Software is not manufactured, it is something you write and publish. Keep Europe free from software patents, we do not want censorship by patent law on written works. Finagle's Fifth Law: Always draw your curves, then plot your readings. pgpCi3BAvGSwu.pgp Description: PGP signature ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] YAHT: searchAll5
Disclaimer: I've never read through YAHT, so I don't know if I'm missing any context... Your intuition was correct: you do want to lift the MonadPlus property through the StateT transformer. This is the key to the transformer libraries, each transformer both contributes a computational feature (MonadState, MonadReader, MonadPlus, MonadError, ...) as well as maintains all features of the monad it's transforming. You've noticed that we need an instance in order to have the StateT monad transformer maintain the MonadPlus property of its inner monad. Beyond the encouragement that your intuition was dead on, I would suggest tryng to use mzero and mplus sooner than you are doing so. In other words, your method defintions should be simpler. Good luck! Nick On 10/30/06, Magnus Therning [EMAIL PROTECTED] wrote: I can't get searchAll5[1] in Yet Another Haskell Tutorial to run. Ghci complains that it can't find a MonadPlus that satisfies the required type; it needs a MonadPlus. I suspect this is due to the use of 'mzero' and 'mplus', without making StateT a MonadPlus. My thought for this was to push mzero into the inner monad and have 'mplus' pass on to the inner monad: instance Monad m = MonadPlus (StateT state m) where mzero = StateT (\s - return (s, mzero)) (StateT m1) `mplus` (StateT m2) = StateT (\s - do (s1, a) - m1 s (s2, b) - m2 s1 return (s2, a `mplus` b)) What's above isn't accepted by ghci, and I don't even know for sure that my thought makes sense. /M [1]: http://en.wikibooks.org/wiki/Haskell/YAHT/Monads#Monad_Transformers -- Magnus Therning (OpenPGP: 0xAB4DFBA4) [EMAIL PROTECTED] Jabber: [EMAIL PROTECTED] http://therning.org/magnus Software is not manufactured, it is something you write and publish. Keep Europe free from software patents, we do not want censorship by patent law on written works. Finagle's Fifth Law: Always draw your curves, then plot your readings. ___ 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