Re: [Haskell] WxHaskell
Here the question: Is there some workaround to make WxHaskell running with my sistem (GHC 6.4.1) or I should downgrade to GHC 6.4? I think there are two options: 1) downgrade to GHC 6.4 2) build wxHaskell yourself for GHC 6.4.1 Regards, Arjan ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
Re: [Haskell-cafe] Shortening if-then-else
Is there a shorter way to write the if-then-else part below? if (cmdType cmd) /= (CmdSitError Server) then return $ Just seat_num else return Nothing return $ if cmdType cmd /= CmdSitError Serv then Just seat_num else Nothing Arjan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell] why don't we have const Ptrs?
Hello all, David darcs Roundy wrote: I was thinking this morning as I lay on the floor (where I sleep) about static typechecking, [...] I think we should get together and collect some money for David to buy a bed. Maybe a Paypal button at the darcs site? Maybe use the time we save by not using CVS anymore to get a second job and send our income to David? Just some suggestions. Cheers, Arjan ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
Re: [Haskell-cafe] Parsec, state and/of my cluelessness
Hi Niklas, ctrlBodyParser :: CharParser ([Value], [Property], [Control]) ([Value], [Property], [Control]) ctrlBodyParser = do { c - ctrlParser -- parse child control ; (vs, ps, cs) - getState ; setState (vs, ps, (c : cs)) ; ctrlBodyParser } | do { p - propParser -- parse child property ; (vs, ps, cs) - getState ; setState (vs, (p : ps), cs) ; ctrlBodyParser } | do { v - valueParser -- parse value ; (vs, ps, cs) - getState ; setState ((v : vs), ps, cs) ; ctrlBodyParser } | do { getState } -- we're finished, return children Uhm, maybe I'm being clueless here but I never use state to pass around results. This looks like a place where you want to parse many subparsers: ctrlBodyParser = many parseOneCtrlBody parseOneCtrlBody = do { c - ctrlParser; return (Control c)} | do { p - propParser; return (Property p)} | do { v - valueParser; return (Valuev)} data CtrlBody = Control | Property | Value Of course, ctrlBodyParser then has type [CtrlBody] so if you want your triple of lists you have to postprocess the list. Anyway, I don't think parsec state is what you want to use here and explicit recursion of parsers can often be avoided using the many (pun intended) combinators of Parsec. Cheers, Arjan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell] Dazzle sources
Hello everyone, After the Dazzle presentation at the Haskell workshop, several people have asked us whether the source code is available. There is the possibility of commercialising Dazzle at some point in the future and for that reason we don't want to give away all our algorithms. However, the diagram editor part of Dazzle is something we would like to share with the community. Already Malcolm Wallace has been using this as a basis for another editor and has made some really nice improvements and generalisations. We plan to make an open-source project out of the diagram editor because we think that that is the part people will be most interested in. Here are some of the features of the diagram editor that will be called Blobs: - editing diagrams - arcs with via points, in other words polylines - saving to and reading from file, XML format (using HaXml) - unlimited undo redo (using the PersistentDocument library) - printing a diagram - save a diagram to JPG/PNG - labels at nodes and arcs - resizing a diagram - based on wxHaskell and can therefore run on Windows, Linux and Mac OS X - the XTC library (eXtended and Typed Controls) will be included - and much more Our plan is to set up a project website, a version management system and to reintegrate Dazzle with Malcolm's extended Blobs. Once we feel people can start using it, we will make an official announcement. Regards, the Dazzle team (Martijn Schrage Arjan van IJzendoorn) ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
[Haskell] readline troubles
Hello all, Using GHCi 6.2.2 and HaXml-1.12 gives you the output below on Windows with Cygwin. I've seen this message on several other occasions and I finally managed to fix this using info at: http://www.haskell.org/pipermail/glasgow-haskell-users/2004-November/007370.html (thank you, Sigbjorn!) However, this is no trivial job and everyone who wants to compile a project using readline on Windows needs to patch this. My question is: has this been solved in GHC 6.4 and if not, can this easily be solved? Maybe by including some version of readline in the Windows GHC installation? Cheers, Arjan van IJzendoorn --- GHCi output [...header...] Loading package base ... linking ... done. Loading package lang ... linking ... done. Loading package haskell98 ... linking ... done. Loading package concurrent ... linking ... done. Loading package QuickCheck ... linking ... done. Loading package readline ... linking ... c:/apps/ghc/HSreadline.o: unknown symbol `_rl_redisplay_function' ghc.exe: unable to load package `readline' ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
Re: [Haskell-cafe] Existential problem
Haha! I like the subject of this message :) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] GUI
However, I want to know if there has been any practical standardisation in the GUI area. Last time I looked at this it seemed some decisions had been made (bind to existing api - wxWindows?). I am waiting for some real standardisation and a mature API before I jump ship from Java for my day-to-day programming. wxHaskell is available at http://www.wxhaskell.sfnet.org/ It runs on Windows, Linux and MacOS X. It has many GUI controls, database access, is well documented and perfectly stable. We use this toolkit for a Bayesian network tool, Dazzle. See http://www.cs.uu.nl/dazzle/images/screenshot.jpg for a screenshot. Have fun, Arjan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] GUI
It seems a bit of a stretch to call wxhaskell perfectly stable, when it seems that the API changes with each release... It's definitely a working interface, but I wouldn't really call it a stable one. I guess it is stable in the sense that it doesn't crash. Yes, you are right. I meant the latter meaning of the word 'stable'. The interface has changed considerably at version 0.8 but will hardly (if at all) be changed at 0.9. Maybe Daan himself can shed some more light on the matter. Cheers, Arjan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: Emitting java bytecode?
Hello Tomasz, I am mainly interested in making GHC more portable. Haskell is a great application programming language, but there are some concerns about portability of applications. What kind of concerns? We develop an application with GUI, a lot of file I/O and that interfaces with a C++ library. It compiles fine on Windows and Linux. If the C++ library would be available for the Mac, we could compile it on MacOS X, too. Cheers, Arjan ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
[Haskell] PersistentDocument: A library for dealing with undo and file management in Haskell
Hello all, In our Bayesian network editor Dazzle with a wxHaskell GUI there were two places where we needed to maintain a document that can be saved to disk. And we wanted to have undo (and redo) in both places. Of course, we didn't want to write this functionality twice. After factoring out the common parts the library is so general that it might be useful for others writing editors, too. The library takes care of maintaining a document, keeping track of whether it is dirty (changed w.r.t. disk version), providing save and save as functionality, enabling and disabling menu items, updating the title bar, warning if you try to close a document that is dirty, dealing with unlimited undo/redo and more. The reason for combining undo/redo and file management is because there is interaction between them. For example, when you save a file, the versions of the document in the undo and redo buffers become dirty. All in all, it is quite subtle code that you don't want to write time after time. If you are writing some kind of editor and are interested in using the library, check out the (heavily documented) source code at: http://www.cs.uu.nl/~afie/pd09122004.zip The zip contains three files: 1) PersistentDocument.hs: the implementation of what is described above. This module is not dependent on wxHaskell by the way. 2) PDDefaults.hs: default implementations of the call-back functions in wxHaskell 3) PDDemo.hs: a demo application allowing you to edit a list of strings. It uses the two other files and thus supports undo/redo and cool file management for free. In the demo file you can see how to start it. If you have suggestions for better names, need functions that are not in the interface or you have any other comment, send it to [EMAIL PROTECTED] At some point this functionality will be added to the wxHaskell distribution. However, I first want to let other people have a look at it and process their comments. Have fun, Arjan PS: If you want to see what our Dazzle editor looks like, go to http://www.cs.uu.nl/dazzle/ ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
Re: Using GHC and wxHaskell
Hi Miren, As I need to implement a graphical interface, I was thinking of using wxHaskell. Is that a good option? How can I use the wxHaskell libraries with GHC? I´m working under Windows XP. Yes, wxHaskell is a good option. As far as I know there are two options for writing GUIs that run under Windows: HToolkit and wxHaskell. I only have experience using wxHaskell; see the NetEdit application on http://wxhaskell.sourceforge.net/applications.html Using wxHaskell is easy. Download the appropriate distribution from http://wxhaskell.sourceforge.net/download.html and click on the register batch file. You can then use wxHaskell in both GHCi and GHC. Good luck, Arjan ___ Glasgow-haskell-users mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
6.2.1 vs 6.0.1
Hello, Thanks for all your replies to my previous message about the overflown relocation field. I was trying to find a bug that makes my application crash. I failed at that but when I switched from using GHC 6.2.1 to version 6.0.1 (on Windows XP) the bug disappeared! That makes me happy because now I can release my software to my customers again. Still, it should work with 6.2.1, too. The bug only shows up now and then, completely impredictable, it seems. It complete crashes my program and I get a Windows dialogue asking me whether I want to send an error report to Microsoft :-) If I debug in Visual Studio the stack trace points into my code and not into the libraries I use (wxHaskell and SMILE (a C++ library for probabilistic networks)). So, I have a quite big application (a graphical editor for probabilistic networks) that uses two complicated libraries that crashes every once in a while under GHC 6.2.1 and not under 6.0.1. I was wondering how to report this problem to you. Has there been a significant change in the code generator since 6.0.1? I know that Martijn Schrage had exactly the same problem (random crashes) with his (huge) Proxima editor. That application also uses wxHaskell so it could be an interaction between GHC's code and wxHaskell... Cheers, Arjan ___ Glasgow-haskell-bugs mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
Re: [Haskell] Monadic Loops
Hello, Vivian uses this while function: while test body = do (cond,res) - body if (test cond) then do rs - while test body return (res:rs) else return [res] However, when I run the program, the interpreter falls over after a few thousand iterations, running out of space. Maybe making it tail-recursive helps. Let me think.. untested code ahead: while test body = do res - funnyWhile test body [] return (reverse res) funnyWhile test body revResult = do (cond, res) - body if test cond then while test body (res:revResult) else return revResult Greetings, Arjan ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
[Haskell] Space behaviour hyperseq
Hello Haskellers, I supervise a student who uses Haskell for simulating neural nets. A lot of computation goes on there and the program cannot handle as many iterations as we would like. We have improved performance by a factor of more than ten by putting strictness annotations in all data types. But the problem is that there are lists within these data structures and they are not strict. By using a trick I have now found that making the whole program state strict the program gets a much better looking heap profile. The trick I use is by writing a function hyperseq and then applying it before the next iterations begins: hyperseq x y = if x==x then y else error this is very unlikely This is very expensive and I chose to apply the function only once every 100 iterations. This gives reasonable performance. Two questions remain: 1) Is there a more efficient definition of hyperseq that does not traverse the data structure twice? The show function traverses the structure once but I found it to be much slower. 2) In this application the uses of lazy evaluation are rare and easily eliminated (zip xs [1..] and so on); is there some hidden GHC option that evaluates everything strictly? I realise that this would invalidate optimisations relying on certain laws but I just wonder how difficult this would be. Somebody must have given this a thought at one point. Cheers, Arjan ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
Panic
Hello GHC people, I'm having a lot of fun with GHC and wxHaskell, but at one point something unwanted happened. I created a version of wxHaskell from source with extra GHC options -prof -auto-all; I wanted to have a profiling version of wxHaskell so I can get a stack trace when my program crashes. The creation and installation of that version of wxHaskell went fine. When I tried to load my project NetEdit into ghci, I got the message at the end of this e-mail. Using ghc (instead of GHCi) gives another message: src/Common.hs:3: Failed to load interface for `Graphics.UI.WX': Could not find interface file for `Graphics.UI.WX' (use -v to see a list of the files searched for) Cheers, Arjan -- C:\dev\netedit\NetEditghci -package wx -lsmilec -ilib\DData:src src\Main.hs ___ ___ _ / _ \ /\ /\/ __(_) / /_\// /_/ / / | | GHC Interactive, version 6.2.1, for Haskell 98. / /_\\/ __ / /___| | http://www.haskell.org/ghc/ \/\/ /_/\/|_| Type :? for help. Loading package base ... linking ... done. Loading package haskell98 ... linking ... done. Loading package lang ... linking ... done. Loading package concurrent ... linking ... done. Loading package QuickCheck ... linking ... done. Loading package util ... linking ... done. Loading package data ... linking ... done. Loading package wxcore ... linking ... WARNING: Overflown relocation field (# re locs found: 30765) C:/cygwin/usr/local/lib/wxcore0.o: unknown symbol `_CC_LIST' ghc.exe: panic! (the `impossible' happened, GHC version 6.2.1): can't load package `wxcore' Please report it as a compiler bug to [EMAIL PROTECTED], or http://sourceforge.net/projects/ghc/. ___ Glasgow-haskell-bugs mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
Re: Finalizers and FFI
HI Gracjan, I would like to attach finalizer (written in Haskell) to some pointer. When the pointer won't be needed any more, finalizer should run. So here is the code: import Foreign.ForeignPtr I couldn't get finalisers to work either with the newForeignPtr from this module. I didn't know how to create a proper FunPtr. In Foreign.Concurrent there is a newForeignPtr that is easier to use: newForeignPtr :: Ptr a - IO () - IO (ForeignPtr a) This one worked beautifully for me. In your code something like: import Foreign.ForeignPtr hiding (newForeignPtr) import Foreign.Concurrent ... fptr - newForeignPtr ptr (finDoIt ptr) Hope this helps, Arjan ___ Glasgow-haskell-users mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: Compiling data
Hi Ketil, For a benchmark, I'd like to include a bit of data in the form of a list of integer matrices (i.e. [[[Int]]]). While I have about 1 of them, sized about twenty square, even 100 of them takes extremely long to compile. Is there a trick to make this faster? Could you put the data in a file and then read it in? main = do contents - readFile aLotOfNumbers.txt let hugeMatrix = ( read contents ) :: [[[Int]]] ... Cheers, Arjan ___ Glasgow-haskell-users mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: [Haskell] HToolkit HSQL on Windows/GHC
Hi Clive, Is there a way to build the HToolkit HSQL library for GHC (6.0.1 when I tried, 6.2.1 now) on windows (particularly MySQL/Windows XP, but I wont say no to postgresql, ODBC sqlite)? I don't know. What I do know is that wxHaskell works great under Windows and has database access for a number of databases (including MySql): http://wxhaskell.sourceforge.net/doc/Graphics.UI.WXCore.Db.html If you want to try wxHaskell: http://wxhaskell.sourceforge.net/ The good thing is that you also get a powerful GUI library for free. Greetings, Arjan ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
Re: [Haskell-cafe] ????Pattern match(es) are overlapped???
newtype Method = Method String getMethod = Method GET putMethod = Method PUT [...] doMeth getMethod = ... doMeth putMethod = ... For Haskell the last two lines look both like pattern-matching on a variable which always matches. You might as well have written: doMeth x = ... doMeth y = ... There is no macro facility in Haskell so you cannot give patterns a name like you do in line 2 and 3. You will have to write: doMeth (Method GET) = ... doMeth (Method PUT) = ... Good luck, Arjan ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: Haskell performance
Hello S\'ebastien, I am a Haskell newbie, but have been interested in Haskell (and generally speaking ML-derivates) for some time. I am currently evaluating different languages for implementing an application which will have to manipulate large graphs representing the structure of programs and their evolution. Maybe you should consider using a combination of Haskell and C++. I bet there are good graph libraries in C++ available so that would save a lot of work. Using Haskell for the front end is a lot more fun than C++ or Java, I think. As you say you are a Haskell newbie I must warn you that linking to a C++ library is not trivial and that's not a Haskell problem but more a compiler-options-problem. What I suggest is exactly what I am doing at the moment; I am building a tool to edit Bayesian networks and to apply inference algorithms to them. The GUI is written in Haskell (wxHaskell) and the inference is a C++ library I am reusing. The choice for C++ was not speed but reuse. I have never come across a problem for which Haskell was too slow, but maybe that depends on my choice of problems. The tool I am writing now runs smoothly on an ancient (700Mhz) computer. Good luck, Arjan ___ Glasgow-haskell-users mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
[Haskell] Re: Haskell performance
Hello S\'ebastien, I am a Haskell newbie, but have been interested in Haskell (and generally speaking ML-derivates) for some time. I am currently evaluating different languages for implementing an application which will have to manipulate large graphs representing the structure of programs and their evolution. Maybe you should consider using a combination of Haskell and C++. I bet there are good graph libraries in C++ available so that would save a lot of work. Using Haskell for the front end is a lot more fun than C++ or Java, I think. As you say you are a Haskell newbie I must warn you that linking to a C++ library is not trivial and that's not a Haskell problem but more a compiler-options-problem. What I suggest is exactly what I am doing at the moment; I am building a tool to edit Bayesian networks and to apply inference algorithms to them. The GUI is written in Haskell (wxHaskell) and the inference is a C++ library I am reusing. The choice for C++ was not speed but reuse. I have never come across a problem for which Haskell was too slow, but maybe that depends on my choice of problems. The tool I am writing now runs smoothly on an ancient (700Mhz) computer. Good luck, Arjan ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
Re: [Haskell-cafe] Dividing integers?
I don't understand why I get this error. I mean, apparently / is not defined for integers but I don't know how to cast the result of the length function into a Double... Use div for dividing integers with loss of precision: 3 `div` 2 (or: div 3 2) == 1 Casting an Int to a Float/Double can be done using fromIntegral: fromIntegral (length [1,2]) / 3 == 0. Besides, a simple integer division works: Prelude 2 / 3 0. This is not an integer division. Writing down a literal (like 2 or 3) denotes a number, not necessarily an Int. The context will influence what type it will be. Something I find really confusing myself, too (which is why it is not in Helium :-). Greetings, Arjan ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Building Haddock on Windows
Hello Alistair, Where can I find instructions for use? I see haddock.sgml in haddock-0.6/haddock/doc but reading sgml hurts. Is there an html version of this somewhere? Haddock is very well documented at http://www.haskell.org/haddock/ Greetings, Arjan ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell] GHC Core backend
Hello all, Is anybody using GHC's backend as a backend for their own compiler? In the paper An external representation for the GHC Core Language the introduction states that there are many (undocumented) idiosyncracies in the way GHC produces Core from source Haskell. And that it will be hard to produced Core that can be integrated with GHC-produced core, and we don't aim to support this. Has this changed since the time of writing this paper? It would be cool if, let's say, Helium (http://www.cs.uu.nl/helium) could use all of GHC's libraries... Regards, Arjan van IJzendoorn ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
Re: Haskell History
Hello Steffen, I need a lot of material relating the following topics: - from lambda calculus to functional programming - other roots of Haskell (e.g. Gofer, ...) - genesis of the well known and beloved standard Haskell98 See Conception, evolution, and application of functional programming languages by Paul Hudak. That's a great starting point for a History of Haskell page: http://portal.acm.org/citation.cfm?doid=72551.72554 Matthew Donadio suggested it to me for the Learning Haskell page, but your future history page seems like a better place to me. You're welcome to steal the simple layout of the Learning Haskell page and maybe someone will make you a logo... Greetings, Arjan ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
Learning Haskell, update
Hi all, I've removed the frequently asked questions box at the bottom. It was unused. Fritz Ruehr made a nice Learning Haskell logo. Thank you, Fritz! NHC is compilable under Windows now, so the remark no windows version has been removed. Is there someone who wants to make a more decent language comparison table? If not, I'm thinking of removing it. Many things are said about it already in the comp.lang.functional FAQ. Greetings, Arjan ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
ANNOUNCE: Helium, for Learning Haskell, version 1.1
Dear all, We are proud to announce version 1.1 of Helium. It can be found at the Helium website: http://www.cs.uu.nl/~afie/helium/ Version 1.1 has the following improvements: - An installer for Windows systems for an improved out-of- the-box experience. - A cool Java-based graphical interpreter called Hint written by a student at our institute. It has a nice GUI with colours, toolbar buttons and menu's. The best feature is that it integrates with your favourite editor and you can jump to the exact locations of messages by clicking on them! - New warnings and hints for common mistakes: sin .3, X = 5 (see below for examples of messages) - Completely new presentation of type errors with more information - Much improved syntax error messages thanks to a new lexer. And thanks to Parsec we can tell not only what was unexpected, but also what would be legal at that position. - The command-line interpreter is now called 'texthint' to avoid conflicts with hmake's 'hi' (sorry!). TextHint is improved in many ways. For one, it now accepts file paths after :l. Other improvements can be found if you type :? - User manuals for the different tools (helium, hint, texthint) and other helpful information on the Helium website - We've compiled Helium with Oxygen (ghc -O2) and this makes the compiler twice as fast. Great work, GHC people! - One well-placed 'seq' makes Helium another 25% faster. - Very many minor bug fixes - The webpage is simpler, wider and easier to navigate thanks to a road map Have fun! the Helium team -- Examples of Helium messages These messages where generated by typing expressions on the texthint prompt. If you compile a file with these errors you will get exact error locations. Prelude [(1, 3] Unexpected close bracket ']' Hint: Expecting a close bracket for '(' Prelude sinn .2 Warning: Function composition (.) immediately followed by number Hint: If a Float was meant, write 0.2 Otherwise, insert a space for readability Undefined variable sinn Hint: Did you mean sin ? Prelude map [1..10] even Type error in application expression : map [1 .. 10] even term : map type : (a - b) - [a] - [b] does not match : [Int]- (Int - Bool) - c probable fix : re-order arguments Prelude let X = 5 in X Left hand side pattern defines no variables Undefined constructor X Hint: Use identifiers starting with a lower case letter to define a function or a variable Undefined constructor X Prelude 1+chr '0' Type error in variable expression : chr type : Int - Char expected type : Char - Int probable fix : use ord instead ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
Re: need help with list comprehension
Hi Mike, GameState = GameState Int Int Int Int Int movePlayers :: GameState - [GameState] movePlayers (GameState p1 p2 p3 p4 p5) = [ (GameState p1' p2' p3' p4' p5') | p1' - outlets (p1), p2' - outlets (p2), p3' - outlets (p3), p4' - outlets (p4), p5' - outlets (p5)] [...] It had to check the inequality of p1' against p2-p5, then p2' against p1' and p3-p4, and so on. Does anyone know of a better way to do this? [ (GameState p1' p2' p3' ...) | p1' - outlets p1, p2' - outlets p2, ... , p5' - outlets p5, allDifferent [p1', p2', p3', p4', p5'] ] allDifferent :: Eq a = [a] - Bool allDifferent list = length list == length (nub list) Not very efficient, though. (nub removes duplicates from a list, so if the original list is just as long as with the duplicates removed, the elements must have been unique) Arjan ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
Learning Haskell moved
Hello all, The Learning Haskell page has moved to a better place, the official Haskell homepage. You can now find it at http://www.haskell.org/learning.html and through a link on the Haskell homepage index. Jerzy wrote: I would add some significant papers, such as John Hughes' Why functional programming matters, etc. I've added that paper to the introduction. Other suggestions are welcome. and perhaps - for some, a little bit advanced readers - some other papers, introducing type classes, perhaps monads (Wadler) I have added a link to the comp.lang.functional FAQ. It answers many questions beginners might have about functional programming in general, but also about specific languages. And it tells you which papers to read about monads. [...] perhaps be a good idea to put down a relatively comprehensive, easy comparison between Haskell and other languages, notably functional: Clean, also: Scheme, absolutely: ML variants, and Erlang. Good idea. I've started a table which you can find a link to in the Learning Haskell introduction. If people have suggestions for other columns, can fill in question marks, know of more important languages, tell us. Or, if you have writing permissions on the Haskell homepage, update the table. Cheers, Arjan ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
Re: a monadic if or case?
whatisit :: String - IO String whatisit f = do ifM doesDirectoryExist f then return dir else ifM doesFileExist f then return file else return nothing Is there any way I could do something like this? Not with the syntactic sugar of 'if'. But you can write [warning: untested code ahead] ifM :: IO Bool - IO a - IO a - IO a ifM test yes no = do b - test if b then yes else no And then ifM (doesDirectoryExist f) (return dir) (ifM (doesFileExist f) (return file) (return nothing)) ) Arjan ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Learning Haskell moved
Hello all, The Learning Haskell page has moved to a better place, the official Haskell homepage. You can now find it at http://www.haskell.org/learning.html and through a link on the Haskell homepage index. Jerzy wrote: I would add some significant papers, such as John Hughes' Why functional programming matters, etc. I've added that paper to the introduction. Other suggestions are welcome. and perhaps - for some, a little bit advanced readers - some other papers, introducing type classes, perhaps monads (Wadler) I have added a link to the comp.lang.functional FAQ. It answers many questions beginners might have about functional programming in general, but also about specific languages. And it tells you which papers to read about monads. [...] perhaps be a good idea to put down a relatively comprehensive, easy comparison between Haskell and other languages, notably functional: Clean, also: Scheme, absolutely: ML variants, and Erlang. Good idea. I've started a table which you can find a link to in the Learning Haskell introduction. If people have suggestions for other columns, can fill in question marks, know of more important languages, tell us. Or, if you have writing permissions on the Haskell homepage, update the table. Cheers, Arjan ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
ANNOUNCE: Learning Haskell portal, version 0.1
Hello all, Often we see messages from people who want to learn Haskell (something we applaud), but don't know where to begin. The Haskell homepage offers a lot of information, links and papers, but there is no page aimed specifically at beginning programmers. That's why I started to collect some links and put them on one single webpage. I thought about what the target audience would be interested in: getting an implementation, buying a book, reading course material, looking up functions in references and so on. The page I have now is a first start and I will work on it more. I've probably overseen many good tutorials, maybe a book here or there, listed an incorrect pro or con of an implementation and what not. Please tell me about it. If you have useful contributions ( nice slides, exercises with(out) solutions, some handout you give to your students which everyone could benefit from ) tell me about it, too. Enough talk: http://www.cs.uu.nl/~afie/haskell/LearningHaskell.html Cheers, Arjan PS: As one of the people in the Helium team I would not recommend beginners to use Helium yet. The absence of classes which leads to simpler types and messages is just not compatible with the text books and other teaching materials. Our plan is to add enough support for classes so that you can use the books without modification. This can be expected this summer. From that moment on, I will definitely recommend Helium to beginners since the feedback from the system is really great. ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
Re: [OT] Teaching Haskell in High School
Michael Sperber writes: This seems like a backwards way of approaching teaching the intro course. I like to look at it as a a track. (Besides, is this really suitable material for beginners, let alone high school students?) Ah, there's the catch. They are not beginners; they are CS students who already learned about Java. When it comes to other disciplines and high school students you're right that TeachScheme is ahead of us and we know we have a long way to go. Cheers, Arjan ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
Re: [OT] Teaching Haskell in High School
Hello all, Michael Sperber wrote: I really recommend looking at the TeachScheme! curriculum and the How to Design Programs curriculum. Here are two URLs: I believe that the environment students work in is very important and can help them learn languages quicker. And so the TeachScheme programming environment is something I'm jealous of and my compliments to the people who made it. Here in Utrecht we will try to do the same for Haskell with Helium: a cool programming environment and the best compiler messages ever (we still have some tricks up our sleeve for the near future). http://www.teach-scheme.org/ I've looked at the PPT presentation and it looks like a fine commercial for functional programming. It could easily be adapted to Haskell and the syntax would be even closer to their mathematical definitions. But I don't want to argue about syntax, because that will not get us anywhere. Let the people who love Haskell try and make an environment (and by that I also include books, presentations and what not) that will make functional programming nice to learn, maybe even in high school. We will do our bit here with Helium so that the Haskell textbooks can be used with Helium. Yes, that does mean adding type classes, but not the whole machinery. If we support Eq, Ord, Show and Num with a limited number of instances, chapters 1 to 11 of Hudak's book can be used without modification. And importantly, the type errors can still be clear! No Cannot find Num instance of Char for the expression 1+'a' but The character 'a' is not a number and + expects one (or something along that line). Oh yes, we'll need SOEGraphics, too, but who knows... If we think Haskell is good for high schools and for using in other courses (like logic and so on), let's try and prove it! Kind regards, Arjan van IJzendoorn PS: What does [OT] stand for? Off topic? I don't think this is off topic. ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
Re: [OT] Teaching Haskell in High School
Hello all, Michael Sperber wrote: - With the programming environment, it isn't just a question of being easier to use: in my experience, environments like Hugs (or any Scheme environment other than DrScheme) work for some, but frustrate many beginners because they don't enable them to fix trivial mistakes which they're bound to make in the first couple of weeks. I completely agree. I've downloaded and installed DrScheme and I must say the environment is really nice: it looks good, helps you to layout your program, matches parentheses and so on. The quality of the messages, however, is not as good as I would have expected. I am a beginning Scheme programmer and here's something I encountered: (define (length2 xs) (cond [(empty? xs) 0] [else (+1 (length2 (rest xs)))])) (length2 (cons 3 (cons 7 empty))) procedure application: expected procedure, given: 1; arguments were: 1 The definition is accepted but when use it I get an error I don't understand. I should note that the environment neatly indicates that (+1 (length2 (rest xs))) is the problem. I've browsed the documentation, found a definition of length and saw that the only difference was a space character between + and 1. That couldn't be it, could it? But it was. Apparently Scheme supports a unary plus, but still the message was wrong and should have read: procedure application: expected procedure, given: +1; arguments were: 1 I think it is important that error messages show exactly what was entered by the user (+1 and not 1) and that's why in Helium we remember each little detail in the abstract syntax tree. I still don't know what arguments were: 1 means. Does it refer to the number of arguments? The TeachScheme! folks had to work a long time on getting DrScheme to provide the feedback needed to alleviate this problem. That's a really good point. We should look at the errors students actually make and not at the errors we make or just make an educated guess. For that reason, Helium has a logging facility built in which sends a server the programs containing errors. This wealth of information can now be used to give hints for type errors that occur often and to improve other kinds of errors. [Don't worry, the version distributed via the web does not contain the logging facility; only the version in our labs has that piece of code compiled in]. - In theory, static typing is good because it helps spot bugs in your program early. However, the current state of the art is such that the type error messages in Haskell systems are not sufficiently helpful (in fact, often misleading) when it comes to finding the actual source of the problem. True. I've also seen people being disappointed in the language Haskell because of the message of the compiler/interpreter. But then I wondered: how can dynamic typing improve on this? So I made a type error in my length2 example: (define (length2 xs) (cond [(empty? xs) 0] [else (+ 1 (rest xs))])) (length2 (cons 2 empty)) +: expects type number as 2nd argument, given: empty; other arguments were: 1 Perfect. I know immediately what the problem is and I can fix it. [The fact that a type error only shows up when you actually reach to code is a pity, because you may submit a lab assignment that still somewhere tries to add a number to a list.] But how is this different from the Helium message: (2,20): Type error in infix application *** Expression : 1 + xs *** Term : xs *** Type : [a] *** Does not match : Int It contains exactly the same information; invisible to the user for now is that we also now where the expresion ends so that we can do highlighting in the future. Maybe Michael is referring to what Hugs says about this program: ERROR C:\docs\Bla.hs:1 - Illegal Haskell 98 class constraint in inferred type *** Expression : mylength2 *** Type : Num [a] = [a] - [a] Wrong line number and a very confusing message. We must keep in mind though that no Haskell compiler so far was designed primarily with helpful messages in mind. Again, Helium may be an improvement, but I suspect that the underlying problem is deeply rooted. The underlying problem may be the inference algorithm used in most compilers. We use a radically different approach which allows us to determine much more information and point at different origins of the error when compared to Hindley Milner based inferencing. If there are three uses of a variable as a Bool and one as an Int we can say that probably the Int usage is wrong. - The syntax for ordinary variables and type variables are the same. That's just how you teach it. You can 'raise' hords of students believing that type variables are always called a, b and c and normal variables use longer, more informative names. As Larry Wall put it: you can write assembly in any language. - The same holds generally for the type syntax which is analogous to the value syntax. I use different
Re: [OT] Teaching Haskell in High School
Hello again, Kevin suggested: Then you should have set the language to Beginning Student or Beginning Student with List Abbreviations. You're right. That makes the messages much better. I switched to 'Advanced' level because I thought that something was possibly not accepted because it was too difficult. My fault. Wolfgang asked: [...logging facility in Helium...] Do you tell your students about the existence of this facility? We certainly do. They don't seem to mind; I even feel that they think it's nice to help research. I just have had a look at Helium and think that at least a deriving mechanism is absolutely needed. There is 'show' function for each data type you write down. Eq and Ord are not generated but we will do that; we will need it anyway for our simple class system. Furthermore, I think, the need to state equality functions explicitely as paramters of certain functions makes learning harder and not easier. I don't know. Could be. We'll probably provide two different Preludes, one with and one without overloading. This would compare to the language levels in DrScheme. A lot is possible in this area. But it's an interesting project. Keep going on it. Don't worry. We just started... Cheers, Arjan ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
Re: Looking for large Haskell programs
Hi Tobias, GHC has too many mutually recursive modules to be useful, otherwise it would be great! But I will look more into the other compilers, are they written in Haskell?, thanks for the suggestion! The Helium compiler is 28000 lines of Haskell code; however, many of those lines are generated from attribute grammars ( http://www.cs.uu.nl/~arthurb/ag.html ) and do not really look like human written code. Anyway, http://www.cs.uu.nl/~afie/helium/ Greetings, Arjan PS: Approximately how many lines of code is GHC these days? ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
Re: [OT] Teaching Haskell in High School
John Peterson wrote: The downside of Haskell is that none of the regular implementations (ghc, hugs) are really right for this level of student. Type inference is an especially nasty problem. There also a number of gotcha's lurking in the language that cause problems. For exactly these reasons we have implemented Helium; not for replacing Haskell (we're very happy with Haskell), but for *learning* Haskell. There is no overloading, so types and type errors are easier to understand. The Helium compiler produces warnings for situations that are probably incorrect. I've found myself look at a program with a comparable problem as the one below for fifteen minutes until I saw what was happening (please look at the program with a non-proportional font like Courier for optimal confusion): filterr :: (a - Bool) - [a] - [a] filterr p [] = [] fi1terr p (x:xs) = if p x then x : filterr p xs else filterr p xs Hugs, which we used for teaching, doesn't say a word. GHC does if you helpful warnings if you pass the -Wall flag. Helium says: (2,9): Variable p is not used (3,1): Missing type signature: fi1terr :: (a - Bool) - [a] - [a] (3,1): Suspicious adjacent functions fi1terr and filterr I'm curious what the other gotcha's are that John refers to because it might give us inspiration for more warnings/language design decisions. Arjan http://www.cs.uu.nl/~afie/helium/ ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
Re: [OT] Teaching Haskell in High School
John Peterson wrote: The downside of Haskell is that none of the regular implementations (ghc, hugs) are really right for this level of student. Type inference is an especially nasty problem. There also a number of gotcha's lurking in the language that cause problems. For exactly these reasons we have implemented Helium; not for replacing Haskell (we're very happy with Haskell), but for *learning* Haskell. There is no overloading, so types and type errors are easier to understand. The Helium compiler produces warnings for situations that are probably incorrect. I've found myself look at a program with a comparable problem as the one below for fifteen minutes until I saw what was happening (please look at the program with a non-proportional font like Courier for optimal confusion): filterr :: (a - Bool) - [a] - [a] filterr p [] = [] fi1terr p (x:xs) = if p x then x : filterr p xs else filterr p xs Hugs, which we used for teaching, doesn't say a word. GHC does give helpful warnings if you pass the -Wall flag. Helium says: (2,9): Variable p is not used (3,1): Missing type signature: fi1terr :: (a - Bool) - [a] - [a] (3,1): Suspicious adjacent functions fi1terr and filterr I'm curious what the other gotcha's are that John refers to because it might give us inspiration for more warnings/language design decisions. Arjan http://www.cs.uu.nl/~afie/helium/ ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
ANNOUNCE: Helium, for learning Haskell
=== Helium (for learning Haskell) 1.0 === We are pleased to announce the first public release of the Helium system, consisting of a language, compiler and interpreter designed especially for education in functional programming. It is being developed at the Software Technology group of the Institute of Information and Computing Sciences of Utrecht University in the Netherlands. CURRENT RELEASE The language is a (large) subset of Haskell 98. Most notable difference is the absence of type classes. Without type classes, types are simpler and more specific type errors can be given. The compiler gives high-quality error messages with exact locations and sometimes hints (e.g. in the case of misspelled names). Warnings are given for unused parameters, shadowing and more. The most sophisticated part is the type checker which uses a novel constraint-based inferencer to improve type error messages. The compiler generates portable byte codes for the Lazy Virtual Machine (cf. JVM for Java) resulting in a system that is a magnitude faster than Hugs. The Helium interpreter Hi is a Hugs-like application which is built on top of the compiler. Together these features make Helium a fine tool for teaching environments. We have experienced that friendlier compiler messages make learning functional programming more fun for our students. More information and downloads can be found at the Helium homepage: http://www.cs.uu.nl/~afie/helium/index.html FUTURE ENHANCEMENTS - User manuals for the different tools - (Closed world) type classes - A more visually pleasing and powerful interpreter - More libraries (e.g. GUI) - Binary distributions for more platforms With kind regards, the Helium team ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
The impossible happened
Hi, GHC gives me this message when compiling with the -O flag (it doesn't happen without it): ghc: panic! (the `impossible' happened, GHC version 5.02): Rules/Deprecations parse failed ./staticanalysis/Constraints.hi:63: error in character literal Please report it as a compiler bug to [EMAIL PROTECTED], or http://sourceforge.net/projects/ghc/. The platform is Windows 2000. Constraints.hi is attached. Greetings, Arjan Constraints.hi Description: Binary data
Re: Beginner's question: Memo functions in Haskell
Hallo Matthias, However, the runtime performance is less pleasing as certain subexpressions are computed over and over again There is a Memo module included with Hugs. I justed (profiling with ghc showed that the function k' (see code below) is called 1425291 times in a toy example). In a non-functional implementation I would now set up an auxillary data structure (e.g. a hash table) for caching/memorizing some intermediate results. How would this be done (elegantly, efficiently, by a Haskell-beginner) in Haskell? So far, I have seen code using lists to speed up fib(n). In my case the arguments of k' are Int - String - String, and I don't expect a simple list of tuples (Int, String, String, RESULT) to be efficient. Thank you very much for you help, Matthias [1] Huma Lodhi, Craig Saunders, John Shawe-Taylor, Nello Cristianini, Chris Watkins: Text Classification using String Kernels, Journal of Machine Learning Research, 2(Feb):419-444, 2002. Available online at http://www.ai.mit.edu/projects/jmlr/papers/volume2.html [2] My code (actually the first 'real' piece of code I wrote in Haskell) is the following: module SKernel where k' :: Double - Int - String - String - Double k' lambda 0 s t = 1 k' lambda i s t = if min (length s) (length t) i then 0 else (lambda * (k' lambda i s' t)) + sum [ lambda^((length t) - j + 2) * (k' lambda (i-1) s' t') | j - [1..length t], t!!(j-1) == last s, t' - [take (j-1) t] ] where s' = take ((length s) - 1) s k :: Double - Int - String - String - Double k lambda i s t = if min (length s) (length t) i then 0 else k lambda i s' t + sum [ lambda^2 * (k' lambda (i-1) s' t') | j - [1..length t], t!!(j-1) == last s, t' - [take (j-1) t] ] where s' = take ((length s) - 1) s nk :: Double - Int - String - String - Double nk lambda n s t = (k lambda n s t) / sqrt ((k lambda n s s) * (k lambda n t t)) -- a toy example would be the call nk 0.5 5 This is a string. Here we have another string. ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
Re: query about precedence: $, the lazy function application operator
Hi Mark, Suppose I have functions f :: Int - Int f x - x * x I suppose you mean: f x = x * x g :: Int - Int g x - x + 1 The lazy application operator $ allows me to do: f $ g x instead of f (g x) But I don't understand why it works this way! Let me explain. f is a function, and application has highest precedence, so unless it sees a bracket, it should take the next thing it sees as an argument. Yes, but $ cannot be an argument. In the Haskell grammar for expressions ( http://www.haskell.org/onlinereport/exps.html ) an application (fexp) consists of one or aexp's and an aexp cannot be an operator (at least not, without parentheses around it). A simpler way to see this is to write application as an explicit operator. Let's call it @. Above expression then reads f $ g @ x And @ binds stronger than $, alas f $ (g @ x) Arjan ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
Re: Read File
Hello, text file has [1,2,3,5] and when I read this data from file I handeled it as string. What can I do to get it as integer list. Apply read: [Warning untested code ahead] main :: IO () main = do contents - readFile myFileWithNumbers let intList = read contents :: [Int] print intList Arjan ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
Re: help need
Hi Benny, instance (Float a) = Num (Poly a) where x + y = addPoly x y I got the Cannot use type synonym in instance head error message when I was trying to compile the above code. Can you tell me why and how to solve it? Unfortunately, you can not instantiate a class with a type synonym. The solution is to make a data type: data Poly = Poly [Float] deriving (Eq, Show) instance Num Poly where (Poly xs) + (Poly ys) = Poly (zipWith (+) xs ys) Note: to be instance of Num a type first has to be instance of Eq and Show Greetings, Arjan ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
Re: ANNOUNCE: Object I/O released
Hi, [...Object I/O download problems...] Try again. The trouble is resolved The quick reference still gives problems. And as for the binary package, I'm still waiting. 47 bytes/sec.. :-( I really want to see this library! Arjan ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
Re: For the Heskell
Hi, Hugs (a Haskell interpreter) can be downloaded at http://cvs.haskell.org/Hugs/pages/downloading.htm Arjan ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
Re: which to download for SuSE7.0
Hi Jeroen, Can I use hugs98 on mij Linux SuSE7.0 computer? I think you can. Download hugs98-Dec2001.tar.gz under Generix Unix at http://cvs.haskell.org/Hugs/pages/downloading.htm and compile it yourself. How to do this, can be found in the file Install inside the archive. Greetings, Arjan van IJzendoorn ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
Re: Functional programming in Python
For humans, it is quite natural to use visual cues (like layout) to indicate semantics. I agree, but let us not try to do that with just two (already overloaded) symbols. (let ((a 0) (b 1)) (+ a b)) let { a = 0; b = 1; } in a + b is valid Haskell and the way I use the language. Enough and more descriptive visual cues, I say. Using layout is an option, not a rule (although the thing is called layout rule...) But all this is not very constructive, because Haskell is not going to change into a fully parenthesized prefix syntax at my wish. Thank god :-) Arjan ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Exceptions
Hi there, I just installed ghc-4.08.1 on a Win2k computer. Then I tried to compile a program that uses exceptions. Compilation succeeds, but running the program causes a "Application Error" dialog to appear. It says "The application failed to initialize properly (0xc005). Click on OK to terminate the application.". Here is the Haskell program: -- module Main(main) where import Exception main = catchAllIO (putStrLn (head ([] :: [String]))) (\e - putStrLn "hi" ) -- Compiled it with ghc-4.08.1 -i/apps/ghc/lib/imports/lang -syslib lang Main.hs Can you help me? Arjan ([EMAIL PROTECTED]) ___ Glasgow-haskell-bugs mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
Re: string to Integer
Hello Friedrich, Turning a string into an integer is easy with the Prelude function 'read': n :: Integer n = read "-34232" Your own function can be made to work for negative numbers by a simple wrapper: stringToInteger :: String - Integer stringToInteger ('-':rest) = -string_to_integer rest stringToInteger string = string_to_integer string string_to_integer :: String - Integer string_to_integer = string_to_int_list .| int_list_to_integer Bye, Arjan
Re: The Clean type system
Hello Ian, I'm interested in this; does "parts of the type checker that were undefined" mean that they just hadn't been written, or that the type system itself is unclear? The former. Those parts had not been written (yet). Hopefully now that they are writing their type checker in a higher-level language (Clean) it is easier to implement it correctly. Is the Clean type system known to be consistent? I don't know about that. Maybe one of the members of the Clean team is reading this? Arjan
Re: Haskell Clean
Hello Nguyen, So what are the important differences between Clean Haskell? Input and output in Haskell is done through the use of monads. In Clean uniqueness typing is used. There are some small syntax differences: Haskell vs. Clean (x:xs) vs [x:xs] (a - b) - [a] - [b] vs (a - b) [a] - [b] f . g vs f o g -5 vs ~5 (unary minus) And the class mechanisms in the two languages are different. However, these differences do not show up in simple cases. So you're right: the languages Haskell and Clean are quite similar. Arjan
Re: Clean and Haskell
Hello Jan, [..write your own Clean compiler...] How difficult would this be? Writing it from scratch would be lots and lots of work. Translating to Haskell would also be far from easy. You can not simply throw away uniqueness information. It is essential for doing side-effects. type checking the uniqueness annotations would be possible Type checking in the presence of uniqueness annotations and classes is ridiculously hard. When I tried to implement monads with unique types I bumped into parts of the type checker that were undefined; resulting in a compiler crash. I think by now they have solved this, but reinventing this yourself can take a long, long time. What would be the best approach to tackle this problem? I would suggest not to do it. Use Haskell if you want to fool around with the source code of the compiler. Bye, Arjan
Re: Clean and Haskell
Hello Steve, I just want to say that Haskell is a fat old slow dinosaur compared with Clean. [...] By Haskell you probably mean the Glasgow Haskell Compiler (GHC). And compilation by GHC is certainly slower than by the Clean compiler. On the other hand, the generated code is comparable, sometimes faster, sometimes slower. See: Benchmarking implementations of lazy functional languages II -- Two years later ( http://hypatia.dcs.qmw.ac.uk/SEL-HPC/Articles/GeneratedHtml/functional.imp lemen.html#HartelPH1994a ) In this article you can read that GHC has improved considerably since the first article and Clean "not significantly". If this is a trend then by now (four years later) GHC's code could be always faster than Clean's. Maybe it's time for a new benchmark. The reason that GHC's compilation times are longer is that it is written in Haskell (as opposed to C for the Clean compiler). However, during development many people use the Haskell interpreter Hugs. This interpreter is fast, interactive and light-weight. So by using both GHC and Hugs you can get speed in both areas. An advantage of a compiler written in Haskell is that it is easier to maintain and that more people can experiment with it. The source code of the Clean compiler is a secret. Another thing you mention is that Haskell is old. This remark shows that you have not been paying attention to the Haskell community. Things move rather fast. So fast that it has been decided to freeze Haskell at a certain point (Haskell 98). But research continues on what you might call Haskell 2 or Haskell 2000. Some features that have been implemented lately include implicit arguments, extensible records and class constraints. I've used both languages a lot and I like them both. Where Clean stands out in comparison to Haskell is that it has a library for making platform-independent GUIs. In the Haskell world there is not yet a standard GUI framework. I would love to see a library with the simplicity of TkGofer for Hugs and/or GHC. In Haskell I like the IO monad very much. It gives you input and output, exceptions and mutable variables. In combination with implicit arguments it allows you to elegantly write down inherently imperative code. As a teacher I think the type systems of both languages are very complex, possibly too complex. Therefore, error messages are often hard to understand. If we want to make (more) students enthusiastic about functional programming this is a problem that should be tackled in the near future. Arjan teacher, former member of the Clean team, Haskell enthusiast and Mondrian hacker
Re: dataflow from non-haskell program
Hello Matthias, Now the data flow shows up as a critical performance bottleneck: Instead of writing the data to a file and then reading it back, you could consider using something like HaskellDirect. With this tool you can interface to other languages. See http://www.dcs.gla.ac.uk/fp/software/hdirect for more information. Although, this site was down when I checked a minute ago. Y2K? Happy newyear, Arjan
Re: Hugs bug with `x = 1'?
Hello Fergus, x = 1 The monomorphism restriction means that functions without parameters should in principle not be overloaded. The fact that Hugs doesn't complain is probably because some "default" mechanism is at work. And it happens to choose Integer as a default. If you want the more general type for x you have to write it down yourself. And then the program works perfectly. x :: Num a = a x = 1 Why GHC does accept this program is a mystery to me. Unfortunately I cannot try it myself (yet). Kind regards, Arjan -- Arjan van IJzendoorn (http://www.cs.uu.nl/~afie) Teacher and part-time Mondrian hacker
VisualHaskell
[.. VisualHaskell ..] John Atwood wrote: I'm aware of John Reekie's version [1] and I see another [2], but I suspect you refer to yet another "Visual Haskell"; can you elaborate? Is it "Visual" in the language sense, or the IDE sense? It is "Visual" in the IDE sense. It is a plugin for Visual Studio and it provides an integrated editor, syntax colouring and some project maganement. Kind regards, Arjan -- Arjan van IJzendoorn ([EMAIL PROTECTED])
Some useful libraries
In recent weeks we have been organising and polishing our locally produced Haskell software. Most of this software was written for educational purposes, but may be quite useful for a wider audience. At: http://www.cs.ruu.nl/groups/ST/Software/index.html you can find links and information about the following modules and packages: HASKELL-RELATED * Pretty-Printing combinators A set of combinators for writing pretty printers, which are fast and user friendly and enable you to formulate in an intuitive way a set of alternative layouts to choose from. We did quite some polishing on this recently, so if you have a previous version please throw it away. * Parsing combinators A set of combinators for writing deterministic error-correcting parsers, which are fast and user friendly. With it you get a parametrisable scanner, too. Note that these combinators are completely different from the monadic style combinators of Hutton and Meijer. * ActiveHaskell, Haskell/COM integration * Partial evaluator You may have a look at this to see how to use the pretty printing and parser combinators. * Micro attribute system You may have a look at this to see how to use the pretty printing and parser combinators. OTHER SOFTWARE * LRC, attribute grammar system * Lilypond, music typesetter If you like something of the above or have comments please let us know. I am sure you will like at least some of it! Doaitse Swierstra -- PLEASE NOTE THAT THE DOMAIN NAME ruu HAS BEEN CHANGED TO uu I HONESTLY APOLOGIZE FOR THE INCONVENIENCES THIS CAUSES TO YOU, BUT IT HAS BEEN ENFORCED UPON US BY THE UNIVERSITY BOARD. The old domain will remain functioning for a long time, but you cannot say that you have not been warned. __ S. Doaitse Swierstra, Department of Computer Science, Utrecht University (Prof. Dr)P.O.Box 80.089, 3508 TB UTRECHT, the Netherlands Mail: mailto:[EMAIL PROTECTED] WWW: http://www.cs.uu.nl/ PGP Public Key: http://www.cs.uu.nl/people/doaitse/ tel: +31 (30) 253 3962, fax: +31 (30) 2513791 __