Re: [Haskell-cafe] New slogan for haskell.org

2007-11-26 Thread Thomas Schilling
On Thu, 2007-10-04 at 10:36 -0700, Don Stewart wrote:
 It was raised at CUFP today that while Python has:
 
 Python is a dynamic object-oriented programming language that can be
 used for many kinds of software development. It offers strong
 support for integration with other languages and tools, comes with
 extensive standard libraries, and can be learned in a few days. Many
 Python programmers report substantial productivity gains and feel
 the language encourages the development of higher quality, more
 maintainable code.
 
 With the links from the start about using Python for various purposes,
 along with reassuring text about licenses and so on. 
 
 Note its all about how it can help you.
 
 The Haskell website has the rather strange motivational text:
 
 Haskell is a general purpose, purely functional programming language
 featuring static typing, higher order functions, polymorphism, type
 classes, and monadic effects. Haskell compilers are freely available
 for almost any computer.
 
 Which doesn't say why these help you.
 
 Any suggestions on a 2 or 3 sentence spiel about what's available?
 
 Here's some quick points:
 
 General purpose: applications from OS kernels to compilers to web dev to 
 ...
 Strong integration with other languages: FFI, and FFI binding tools
 Many developer tools: debugger, profiler, code coverage, QuickCheck
 Extensive libraries: central library repository, central repo hosting 
 Productivity, robustness, maintainability: purity, type system, etc
 Parallelism!
 


Haskell is a general-purpose, pure functional programming languages
that puts many interesting results from research into a practical
programming language.  It's features include:

 * Static typing with type inference: enables writing robust and fast
   programs quickly and makes large code bases maintainable.

 * Higher-order functions, polymorphism, and laziness: enables higher
   levels of abstraction, more composable, thus reusable code.

 * Purity: helps keeping your code maintainable and testable.

Haskell comes with many libraries, freely available compilers for
almost any computer, debuggers, profilers, code coverage and testing
tools.


That seems short enough to me.  Things that could find their way in are:

  monads: for the embedded DSL angle
  paralellism: mention STM and high-level combinators




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


Re: [Haskell-cafe] Building MissingH on Windows

2007-11-26 Thread Thomas Schilling
On Mon, 2007-11-26 at 21:24 +0100, [EMAIL PROTECTED] wrote:
 Hi,
 
 I'm trying to build MissingH (0.18.6) on Windows, but it looks like
 (probably because of changes in Cabal) the Setup.hs is broken. Im using GHC
 6.8.1. Following message:
 
 $ runhaskell Setup.hs configure
 
 Setup.hs:19:35:
 Couldn't match expected type `(Either
  GenericPackageDescription
 PackageDescription,
HookedBuildInfo)'
against inferred type `PackageDescription'
 In the first argument of `(confHook defaultUserHooks)', namely
 `mydescrip'
 In the expression:
 let
   mydescrip = case os of
 mingw32 - ...
 _ - ...
 in (confHook defaultUserHooks) mydescrip flags
 In the definition of `customConfHook':
 customConfHook descrip flags
  = let mydescrip = ...
in (confHook defaultUserHooks) mydescrip flags
 
 I'm new to Cabal and I couldn't see a fast way to fix it.
 
 Thanks,
 Nicu

Try replacing the original files with the attached files.
-- arch-tag: MissingH main description file
Name: MissingH
Version: 0.18.6
Cabal-Version: = 1.2
License: GPL
Maintainer: John Goerzen [EMAIL PROTECTED]
Author: John Goerzen
Copyright: Copyright (c) 2004-2007 John Goerzen
license-file: COPYRIGHT
extra-source-files: COPYING
homepage: http://software.complete.org/missingh
Category: Unclassified
synopsis: Large utility library
Description:  MissingH is a library of all sorts of utility functions for
 Haskell programmers.  It is written in pure Haskell and thus should
 be extremely portable and easy to use.
Stability: Beta

Library
 Hs-Source-Dirs: src

 Exposed-Modules: Data.String, System.IO.Utils, System.IO.Binary, Data.List.Utils,
  System.Daemon,
  Text.ParserCombinators.Parsec.Utils,
  Test.HUnit.Utils,
  Network.Email.Mailbox,
  Control.Concurrent.Thread.Utils,
  Network.Email.Sendmail,
Data.CSV,
  System.Cmd.Utils,
  Data.Progress.Tracker,
  Data.Progress.Meter,
  Data.Quantity,
  Data.Map.Utils, System.Path, System.Path.NameManip,
System.Path.WildMatch, System.Path.Glob,
  System.Time.Utils, System.Time.ParseDate,
  Network.Utils,
  Network.SocketServer,
  Data.Either.Utils,
  Data.Maybe.Utils,
  Data.Bits.Utils,
  Data.Hash.CRC32.Posix, Data.Hash.CRC32.GZip,
   Data.Hash.MD5, Data.Hash.MD5.Zord64_HARD,
  Data.Compression.Inflate,
  System.FileArchive.GZip,
  System.IO.HVFS,
System.IO.HVFS.Combinators,
System.IO.HVFS.InstanceHelpers,
System.IO.HVFS.Utils,
  System.IO.HVIO, System.IO.StatCompat, System.IO.WindowsCompat,
System.IO.PlafCompat, System.Posix.Consts,
  System.Debian, System.Debian.ControlParser,
  Data.MIME.Types,
  System.Console.GetOpt.Utils
 Extensions: ExistentialQuantification, OverlappingInstances, 
   UndecidableInstances, CPP
 Build-Depends: network, parsec, base,
   haskell98, mtl, HUnit, regex-compat, QuickCheck, filepath,
   hslogger
 if !os(windows)
  Build-Depends: unix

 GHC-Options: -O2

Executable runtests
 Buildable: False
 Main-Is: runtests.hs
 HS-Source-Dirs: testsrc, .
 Extensions: ExistentialQuantification, OverlappingInstances,
UndecidableInstances, CPP
#!/usr/bin/env runhaskell
module Main where
import Distribution.Simple
main :: IO ()
main = defaultMain
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Building MissingH on Windows

2007-11-26 Thread Thomas Schilling
See also:  http://haskell.org/haskellwiki/Upgrading_packages

You probably have to adjust the build-depends field, due to the base
split up. 

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


Re: [Haskell-cafe] Cabal and DB packages

2007-11-25 Thread Thomas Schilling
On Sun, 2007-11-25 at 18:49 +0100, manu wrote:
 Hello,
 
 I'm trying to do something that should be fairly simple, installing  
 some DB package so I can use MySQL or SQLite.
 
 However I've had troubles building HSQL, HaskellDB and Takusen before  
 giving up (I am using ghc 6.8.1 and Cabal-1.2.2.0).
 
 --
 
 with HSQL :
 
 Database/HSQL.hsc:66:7:
  Could not find module `System.Time':
it is a member of package old-time-1.0.0.0, which is hidden
 
 so I added 'old-time' to the 'build-depends' line in the .cabal file
 
 but then it fails building with
 
 Building hsql-1.7...
 [1 of 2] Compiling Database.HSQL.Types ( Database/HSQL/Types.hs, dist/ 
 build/Database/HSQL/Types.o )
 
 Database/HSQL/Types.hs:134:18: Not in scope: type variable `forall'
 
 Database/HSQL/Types.hs:134:25: Not in scope: type variable `a'
 
 Database/HSQL/Types.hs:134:27:
  Illegal operator `.' in type `forall a . (Int
- FieldDef
   - (FieldDef -  
 CString - Int - IO a) - IO a)'
(Use -XTypeOperators to allow operators in types)
 

This means you need -XRank2Polymorphism
or maybe -XExistentialQuantification.

 etc...
 
 At this point, it goes over my head...
 
 ---
 
 What the hell, I'll use HaskellDB and FlatDB, but then I get this  
 message while building HaskellDB :
 
 src/Database/HaskellDB/HDBRec.hs:106:11:
  Illegal signature in pattern: l f a
  Use -XPatternSignatures to permit it
 
 when I add 'PatternSignatures' to the 'Extensions:' line in .cabal,  
 it fails configuring with :
 
 Setup.hs: haskelldb.cabal:8: Parse of field 'extensions' failed:
 
 Jsus, nevermind, I'll try Takusen

Are you sure you specified the right extensions? (correct spelling,
correct separators)  Unfortunately readP doesn't give you nice error
messages.

 
 ---
 
 with Takusen :
 
 $ runhaskell Setup.hs configure
 
 Setup.hs:26:7:
  Could not find module `Distribution.Program':
Use -v to see a list of the files searched for.
 
 I give up...
 
 

That means that Takusen requires an older Cabal.  I'd have to look at
the code to see how hard it would be to fix this.

 Is there any simple way to do it though ? Is there any problems with  
 Cabal that I need to work around ?
 
 Help !!
 
 Manu
 
 
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe

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


Re: [Haskell-cafe] Re: Composing monads

2007-11-23 Thread Thomas Schilling
On Fri, 2007-11-23 at 23:01 +0100, Roberto Zunino wrote:
 Maurí­cio wrote:
  main = mapM_ ((putStrLn ) * putStrLn) $
map show [1,2,3]
 
 Using only standard combinators:
 
 main = mapM_ ((putStrLn  ) . putStrLn) $ map show [1,2,3]

  == mapM_ ((putStrLn  ) . putStrLn . show) [1,2,3]

  == mapM_ ((putStrLn  ) . print) [1,2,3]

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


Re: [Haskell-cafe] Problems with do notation

2007-11-22 Thread Thomas Schilling
On Thu, 2007-11-22 at 09:19 +0100, Peter Verswyvelen wrote:
 worksFine = 
   if True
   then putStrLn True
   else putStrLn False
 
 worksNOT = do
   if True
   then putStrLn True
   else putStrLn False
 
 worksAgain = do
   if True
 then putStrLn True
 else putStrLn False
 
 Of course the worksFine function returns an IO action, so has
 different behavior, but I mean the indentation is different. Is this
 by design?
 
 
 Also the following is rather strange:
 
 doubleDefError = let x = 1
 x = 2
 in x * x
 
 alsoDoubleDefError = do
   let x = 1
   x = 2
   return (x*x)
 
 doubleDefNOERROR = do
   let x = 1
   let x = 2
   return (x*x)
  
 Now I understand why this is (the second let starts a new invisible
 scope no?), but for newbies, this is all very strange :-)

Now go and read about 'mdo' (recursive 'do' notation) ;) 

BTW, don't you get the same behaviour?

foo = let x = 1 in
  let x = 2 in
x * x



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


Re: Re[2]: [Haskell-cafe] expanded standard lib

2007-11-21 Thread Thomas Schilling
On Wed, 2007-11-21 at 12:19 +0300, Bulat Ziganshin wrote:
 Hello Thomas,
 
 Tuesday, November 20, 2007, 6:35:00 PM, you wrote:
 
  Using DocBook, however, has some nice advantages.  For example, the
  possibility to generate documentation in different formats.  Something
  more easily accessible (from the internet) would certainly be much more
  convenient, though.
 
 zoho writer: online, not xml editor, but at least able to export into
 pdf/html/doc/..
 

It's not open source + it doesn't do what we need - Bang!  \also they
host stuff for you, and only have limited room for free usage.  Relying
on a company is not the way to go here (think of BitKeeper). 

TinyMCE [1], however, seems like a good start.  It is open source, seems
relatively mature, supports plugins, and runs completely in JavaScript,
thus should be independent from the server technology.  

I actually had something in mind like WYMeditor [2], but it seems not
very mature, yet.

[1] .. http://tinymce.moxiecode.com/
[2] .. http://www.wymeditor.org/en/



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


Re: [Haskell-cafe] expanded standard lib

2007-11-20 Thread Thomas Schilling
On Tue, 2007-11-20 at 12:33 +, Krzysztof Kościuszkiewicz wrote:
 On Tue, Nov 20, 2007 at 08:55:47AM +, Simon Peyton-Jones wrote:
 
  But we're just not sure how to do it:
 
  * What technology to use?
 
  * Matching up the note-adding technology with the existing
  infrastructure - GHC's user manual starts as XML and is generated into
  HTML by DocBook - In contrast, the library documentation is generated
  by Haddock.
 
 I would advocate using a comment system that is similar to the one
 at http://djangobook.com/. In terms of user manual comments might be
 attached to sections and paragraphs in the document. Haddock already
 generates HTML anchors for every type, variable and class, so these are
 good candidates to attach user comments to.

I'm pretty sure Brian O'Sullivan has written a Haskell implementation of
this for the Real World Haskell book.  I guess, they will publish the
source once the book is out.  Maybe the RWH guys can give some feedback
on how this works, they seem to have very similar goals.

/ Thomas

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


Re: [Haskell-cafe] expanded standard lib

2007-11-20 Thread Thomas Schilling
On Tue, 2007-11-20 at 16:00 +0100, Ketil Malde wrote:
 Thomas Schilling [EMAIL PROTECTED] writes:
 
  I would advocate using a comment system that is similar to the one
  at http://djangobook.com/. 
 
  I'm pretty sure Brian O'Sullivan has written a Haskell implementation of
  this for the Real World Haskell book.
 
 While the technology is there (or will be), I worry if this is the
 right solution for something else than soliciting comments on a
 (fixed, non-editable) text.
 
 I can all to easily imagine a situation where any documentation is
 riddled with a plethora of notes, questions, answers, comments etc,
 with nobody to clean up the mess every now and then.  For user-edited
 documentation, a wiki seems a much better fit - where each author 
 make some effort to leave pages as self-contained consistent
 documents.

Hm.  The GHC user's guide currently is generated from a DocBook
(XML-based) language, but when I extended the Cabal documentation (which
also is DocBook) I wasn't very impressed by DocBook.  It isn't
particularly well-documented and editing raw XML is never fun, even with
the right Emacs mode.  One could hope that a standard format would come
with many tools, but I didn't get the impression that the tools are
great, either.  They're also not easy to set up.  (On Mac OS I had to
manually add a symlink to fix a script.  Installation only worked with
fink, not with Macports.  I wouldn't be surprised if it were even harder
to set up on Windows.  Ubuntu worked fine, though.) 

Using DocBook, however, has some nice advantages.  For example, the
possibility to generate documentation in different formats.  Something
more easily accessible (from the internet) would certainly be much more
convenient, though.  It would be nice, though, to preserve semantic
markup.  Aren't there some usable web-based WYSIWYG editors that edit
XML rather than HTML?  Also, it should be possible to have branches in
this wiki-system, so that you can associate it with a particular
release, but still update when necessary.  (I.e., just linking to a
particular version is not sufficient.)
 
Does anyone know of a system that comes close to those requirements?

Do we need more features from DocBook for GHC or the libraries, or both?



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


Re: [Haskell-cafe] expanded standard lib

2007-11-20 Thread Thomas Schilling
On Tue, 2007-11-20 at 12:03 -0800, Keith Fahlgren wrote:
 On 11/20/07 7:35 AM, Thomas Schilling wrote:
  On Tue, 2007-11-20 at 16:00 +0100, Ketil Malde wrote:
  Thomas Schilling [EMAIL PROTECTED] writes:
 
  I can all to easily imagine a situation where any documentation is
  riddled with a plethora of notes, questions, answers, comments etc,
  with nobody to clean up the mess every now and then.  For user-edited
  documentation, a wiki seems a much better fit - where each author 
  make some effort to leave pages as self-contained consistent
  documents.
  
  Hm.  The GHC user's guide currently is generated from a DocBook
  (XML-based) language, but when I extended the Cabal documentation (which
  also is DocBook) I wasn't very impressed by DocBook.  It isn't
  particularly well-documented 
 
 Hi,
 
 [Disclosure: I'm a large part of O'Reilly's re-adoption of DocBook internally
 and a member of the OASIS DocBook SubCommittee for Publishers]
 
 I'm particularly surprised by this last sentence on the lack of documentation,
 as the DocBook standard has a definitive, comprehensive, freely available 
 manual
 at http://www.docbook.org/tdg/en/html/docbook.html that I've always found very
 usable. Were there particular things that you missed?

Right.  I should have been more specific.  I certainly like the idea of
Docbook.  But in an open source project documentation is written in
small parts and by many different people.  I personally didn't care to
read a whole book just to be able write a few pages of documentation.
Thus I tried to use it as a reference.  This worked reasonably well, but
could have been a way more comfortable experience.  Some quick-access /
lookup table, would have been nicer.  Maybe also a little more pretty
than gray and standard link blue.  (Even the W3C specs look rather
nice.)

My point is, for a casual editor trying to write or edit DocBook
documents based on this book is rather tedious.  I think my Emacs mode
didn't do as nice completion as it should have (based on DTD and
everything.)

 
  and editing raw XML is never fun, even with
  the right Emacs mode.  One could hope that a standard format would come
  with many tools, but I didn't get the impression that the tools are
  great, either.  
 
 The state of GUI XML editors has advanced significantly over the last year 
 with
 the continued work on both XXE (http://www.xmlmind.com/xmleditor/) and 
 oXygen's
 latest release (http://www.oxygenxml.com/docbook_editor.html), for example. 
 That
 said, there are not as many tools for editing DocBook XML as HTML, for 
 example.

The latter is not available for free (only trial).  The former seems to
be free for non-commercial use.  I haven't tried either (*Java Runtime
rant elided*).  The real problem remains:  Even if you were to install a
special program to (reasonably) edit a DocBook file, we still don't have
the immediacy of a Wiki.  

  Using DocBook, however, has some nice advantages.  For example, the
  possibility to generate documentation in different formats.  Something
  more easily accessible (from the internet) would certainly be much more
  convenient, though.  It would be nice, though, to preserve semantic
  markup.  Aren't there some usable web-based WYSIWYG editors that edit
  XML rather than HTML? 
 
 Not that I've found. I'd be delighted to hear about possibilities. 

There seem to be some.  But I could only find commercial ones.

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


Re: [Haskell-cafe] expanded standard lib

2007-11-19 Thread Thomas Schilling
On Mon, 2007-11-19 at 12:17 -0800, Don Stewart wrote:
 andrewcoppin:
 
  Hackage seems like a nice idea in principle. However,
 
 I think in practice too: we had no central lib archive or dependency
 system, now we have 400 libraries, and a package installer, 10 months 
 later. Until Hackage, there was a strong pressure not to reuse other 
 people's libraries.
 
  - The packages seem to be of quite variable quality. Some are excellent, 
  some are rather poor (or just not maintained any more).
  
  1. Welcome to the internet.

Sure, but this doesn't mean we couldn't implement some mechanisms to
improve the situation.  Some things I could think of:

  - Have Hackage display a information of whether a package builds on a
particular platform.  Information could be provided by cabal-install (if
the user agrees, of course.)  

  - Allow uploaded packages receive minor patches, i.e., fixing .cabal
file.  This will probably be a recurring problem, since packages will be
updated and base will be split up further.

  - I don't know if a commenting system on hackage would be more useful
than on a package's homepage.  At least it would be useful to have a
package homepage and bug-tracker for each package.  Both could simply be
a code.google.com site.

Alltogether, I'm quite happy with Hackage.  There's room for
improvement, sure, but I think we're on the right track ...



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


Re: [Haskell-cafe] Fun with Cabal on Windows! [Stream fusion for Hackage]

2007-11-19 Thread Thomas Schilling
On Mon, 2007-11-19 at 20:29 +, Andrew Coppin wrote:
 Don Stewart wrote:
  Just a quick announce: the stream fusion library for lists, 
  that Duncan Coutts, Roman Leshchinskiy and I worked on earlier this year
  is now available on Hackage as a standalone package:
 
  
  http://hackage.haskell.org/cgi-bin/hackage-scripts/package/stream-fusion-0.1.1
 
  As described in the recent paper:
 
  Stream Fusion: From Lists to Streams to Nothing at All
  Duncan Coutts, Roman Leshchinskiy and Don Stewart. ICFP 2007
 
  This is a drop-in replacement for Data.List.

 
 Well, I just tried to install this, and as per usual, Cabal has having 
 none of it.
 
 C:\fusion\ runhaskell Setup configure
 Configuring stream-fusion-0.1.1...
 Setup: ld is required but it could not be found.
 
 Well, no, this is Windoze, we don't have ld here...
 
 On the other hand... hold on, doesn't GHC use GCC and ld?
 
 On closer inspection, it seems that there *is* an LD.EXE on my 
 harddrive. Cabal is simply failing to find it. Great.
 
 It turns out, the standard GHC installer automatically adds 
 C:\ghc\ghc-6.8.1.\bin to the search path. This contains GHC.EXE (and 
 other things), but LD.EXE and friends aren't in there. Those are found 
 in C:\ghc\ghc-6.8.1\gcc-lib. If you temporarily add *that* to your path...
 
 C:\fusion\ set PATH=%PATH%;C:\ghc\ghc-6.8.1\gcc-lib
 C:\fusion\ runhaskell Setup configure
 Configuring stream-fusion-0.1.1...

Hm, this actually is supposed to work.  Could you please re-run this
procedure with the original path and with maximum verbosity?  I.e.:

   runhaskell Setup configure -v3

In any case though, if you have problems with Cabal or cabal-install,
send a bug report -- Windows might not be number one priority (since
most of the developers don't use it (often)) don't expect us to fix bugs
that we don't know about.  (Naturally.)

Thanks,

/ Thomas

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


Re: [Haskell-cafe] expanded standard lib

2007-11-19 Thread Thomas Schilling
On Mon, 2007-11-19 at 21:22 +, Andrew Coppin wrote:

 Where is the correct place for Cabal bugs?

This and other questions are explained at .. *drumroll* .. the Cabal
Homepage!! -- http://www.haskell.org/cabal/

:)

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


Re: [Haskell-cafe] Re: Scheme in Haskell, Parsec Example, how to add scheme comments

2007-11-18 Thread Thomas Schilling
On Sun, 2007-11-18 at 19:37 -0500, Berlin Brown wrote:
 On Nov 18, 2007 7:32 PM, Berlin Brown [EMAIL PROTECTED] wrote:
  I am sure many of you have looked at the scheme in haskell example that
  is on the web by Jonathan Tang. If you are familiar with the code, I
  need a little help trying to add scheme style comments:
 
  ; This is my comment

The preferred way to do that is to use a token helper function:

  token :: P a - P a
  token p = do r - p
   whiteSpace
   return r

  -- or, if you add a Control.Applicative instance for your 
  -- parser type, this is just: token p = p * whiteSpace

Then you handle comments as whitespace:

  whiteSpace :: P ()
  whiteSpace = skipMany $
spaces 
| (char ';'  skipMany (satisfy (/='\n')))

Then you just use that like this:

  symbol :: P String
  symbol = token $ many1 $ satisfy $ not . (`elem` ()[]; )

See also Parsec's TokenParser.

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


Re: [Haskell-cafe] let vs. where

2007-11-13 Thread Thomas Schilling
On Tue, 2007-11-13 at 13:08 -0800, Donn Cave wrote:
 On Tue, 13 Nov 2007, Neil Mitchell wrote:
 
  This depends on whether you are an expression style or declaration
  style programmer.
http://www.haskell.org/haskellwiki/Declaration_vs._expression_style
http://www.haskell.org/haskellwiki/Let_vs._Where
  
Monadification is a refactoring.  You want IDE support for this
anyways, so I don't think one should prefer let over where solely for
the purpose that one day you might do this transformation.  I personally
prefer where clauses, since code becomes very readable if you name your
functions well.

However, if you refer to variables bound inside monadic code, you simply
have to use 'let'.  

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


Re: [Haskell-cafe] O'Reilly Real World Haskell book

2007-11-10 Thread Thomas Schilling
On Sat, 2007-11-10 at 17:50 -0600, Galchin Vasili wrote:
 Hello,
 
  What is the proposed table of contents for Real World Haskell?

http://www.realworldhaskell.org/blog/2007/05/23/real-world-haskell-its-time/

as of May 2007

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


Re: [Haskell-cafe] Disable echo in POSIX terminal

2007-11-09 Thread Thomas Schilling
On Fri, 2007-11-09 at 10:59 -0500, Taylor Venable wrote:
 Hello all,
 
 I've written a little Haskell program to get information from a MySQL
 database (great thanks to anybody reading this who works on HSQL, by
 the way) but I want to keep the user's password concealed, obviously.
 Currently I prompt for it from the terminal, but the problem is that
 it's echoed just like all other input.  I would like to disable input
 echo when asking for the password, but I'm not sure how.  I notice
 there's a System.POSIX.Terminal module, but I have no idea how to use
 it, or whether it will do what I want.  Any ideas would be greatly
 appreciated.
 
 Best regards.
 

In C you usually use:  getpasswd
  (http://docsrv.sco.com:507/en/man/html.S/getpasswd.S.html)

I cannot find it System.Posix, so you might have to write your own FFI
bindings.  Otherwise, you can play around with the terminal modes from:

http://haskell.org/ghc/docs/latest/html/libraries/unix-2.2.0.0/System-Posix-Terminal.html#t%3ATerminalMode

Good luck!


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


Re: [Haskell-cafe] Flymake Haskell

2007-11-08 Thread Thomas Schilling
On Thu, 2007-11-08 at 12:57 +0900, Daisuke IKEGAMI wrote:
 Hello emacsen users, 
 
 Here is a setting to check your Haskell code /on-the-fly/ 
 with 'flymake-mode'.
 
   (require 'flymake)
   
   ;; flymake for Haskell
   (defun flymake-Haskell-init ()
 (flymake-simple-make-init-impl
   'flymake-create-temp-with-folder-structure nil nil
   buffer-file-name
   'flymake-get-Haskell-cmdline))
   (defun flymake-get-Haskell-cmdline (source base-dir)
 (list ghc (list --make (concat -i base-dir) source)))
   (push '(.+\\.hs$ flymake-Haskell-init)
 flymake-allowed-file-name-masks)
   (push '(.+\\.lhs$ flymake-Haskell-init)
 flymake-allowed-file-name-masks)
   (push '(^\\(.*\\):\\([0-9]+\\):\\([0-9]+\\): \\(.*\\)$ 1 2 3 4)
 flymake-err-line-patterns)
 
 The 'flymake-mode' has been developed at http://flymake.sourceforge.net/
 Emacs22 has this mode already.
 
 dons recommends to me at IRC to write this code into the wiki, however, 
 I don't know where we should put the snippet.
 
 You can watch a short demo at the following blog:
   http://madscientist.jp/~ikegami/diary/20071108.html#p01
 
 I have some complaints though it works:
   - it's slow (hmm)

Try using:

(defun flymake-get-haskell-cmdline (source base-dir)
  `(ghc (--make -fno-code ,(concat -i base-dir) ,source)))

This avoids any kind of code-generation, so only syntax and types are
checked.

   - error and warning seems not distinguished
   (we may have to modify 'flymake-err-line-patterns')
 Any comment is appreciated.

It seems you need multi-line pattern matching.  Note that shim already
can do this, but it doesn't do it automatically.  Unfortunately, shim
chokes on files that need pre-processing.  There's probably a way to
integrate these two.

 
 Best regards,
 Ike
 
 P.S.
 I like vi-clone, such as vim, too. ;-)
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe

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


Re: [Haskell-cafe] About Fibonacci again...

2007-11-08 Thread Thomas Schilling
On Thu, 2007-11-08 at 00:56 +0100, [EMAIL PROTECTED]
wrote:
 Don't shoot me... 
 
 The last exchange with Andrew Bromage made me recall a homework which was
 given to some students by a particularly nasty teacher I happen to know. 
 
 The question is to generate the whole infinite Rabbit Sequence in one
 shot (co-recursive, selbstverständlich). 
 
 The Rabbit Sequence:
 1,0,1,1,0,1,0,1,1,0,1,1,0,1,0,1,1,0,1,0,1,1,0,1,1,0,1,0,1,1,0,1,1,0,...
 may be obtained in two ways. 
 
 A.
 1. Begin with one *young* rabbit: 0.
 2. In one unit of time a young rabbit grows, becomes *old*: 1.
 3. In one unit of time an old rabbit has an offspring, transmutes into [1,0]
   (Yes, the rewriting order is meaningful). 

Don't rabbits ever die?

Guess they just become zombie rabbits ... [1]

But that still doesn't work, because those would then eat all those
other rabbits ...

Hm ...


[1] ..
http://www.ebsqart.com/Artists/cmd_3739_profile_portfolio__3_3_G.htm

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


Re: [Haskell-cafe] Haskell performance question

2007-11-08 Thread Thomas Schilling
On Fri, 2007-11-09 at 00:51 +0600, Mikhail Gusarov wrote:
 Dan Piponi [EMAIL PROTECTED] writes:
 
  Even though 'n' is 10 times bigger in the C program it runs much
  faster than the Haskell program on my MacBook Pro with Haskell 6.6.1.
  I've tried lots of different combinations of flags that I've found in
  various postings to haskell-cafe but to no avail.
 
 import Data.List
 
 main = do
   print $ foldl' (+) 0 $ take 1 [1.0,1.0..]
 
 works 10 times faster than your C version. You just need to adapt to the
 radically different style of programming.
 
 Real Fortran programmer may write Fortran programs on any programming
 language :)

Good point, but this is not true for the OP.  Take a look at Dan's blog.
It's linked on planet.haskell.org.

BTW. I prefer:

  print 1000.0

;)

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


Re: [Haskell-cafe] Building Haskell stuff on Windows

2007-11-08 Thread Thomas Schilling
On Thu, 2007-11-08 at 18:34 +, Andrew Coppin wrote:
 Neil Mitchell wrote:
  Windows and Haskell is not a well travelled route, but if you stray of
  the cuddly installer packages, it gets even worse.

 
 Is that why Cabal packages never ever install on Windows?

Could you be more specific what your problems are?

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


Re: [Haskell-cafe] Haskell performance question

2007-11-08 Thread Thomas Schilling
On Thu, 2007-11-08 at 10:33 -0800, Dan Piponi wrote:
 I see lots of shootout examples where Haskell programs seem to perform
 comparably with C programs, but I find it hard to reproduce anything
 like those figures when testing with my own code. So here's a simple
 case:
 
 I have this C program:
 
 #include stdio.h
 
 #define n 1
 
 double a[n];
 
 int main()
 {
int i;
for (i = 0; in; ++i)
{
a[i] = 1.0f;
}
for (i = 0; in-1; ++i)
{
a[i+1] = a[i]+a[i+1];
}
printf(%f\n,a[n-1]);
 }
 
 And this Haskell program:
 
 import Data.Array.IO
 import Control.Monad
 
 n = 1000
 
 main = do
a - newArray (0,n-1) 1.0 :: IO (IOUArray Int Double)
forM_ [0..n-2] $ \i - do { x - readArray a i; y - readArray a
 (i+1); writeArray a (i+1) (x+y) }
x - readArray a (n-1)
print x
 
 Even though 'n' is 10 times bigger in the C program it runs much
 faster than the Haskell program on my MacBook Pro with Haskell 6.6.1.
 I've tried lots of different combinations of flags that I've found in
 various postings to haskell-cafe but to no avail.
 
 What flags do I need to get at least within a factor of 2 or 3 of C?
 Am I using the wrong kind of array? Or is Haskell always going to be
 15-20 times slower for this kind of numerical work?

I tried both, but it would be really helpful to see your command line
options.  I used:

$ gcc -O3 ghc-bench.c -o ghcbC
ghc-bench.c: In function ‘main’:
ghc-bench.c:16: warning: incompatible implicit declaration of built-in
function ‘printf’

$ ghc --make -O2 ghc-bench.hs

and got:

$ time ./ghc-bench 
2.0e7

real0m0.714s
user0m0.576s
sys 0m0.132s

$ time ./ghcbC 
2000.00

real0m0.305s
user0m0.164s
sys 0m0.132s

This is on a first-gen Macbook running Ubuntu.  1GB RAM.  1.83Ghz Core
Duo

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

$ gcc --version
gcc (GCC) 4.1.2 (Ubuntu 4.1.2-0ubuntu4)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is
NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.


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


Re: [Haskell-cafe] Haskell performance question

2007-11-08 Thread Thomas Schilling
On Thu, 2007-11-08 at 10:33 -0800, Dan Piponi wrote:
 I see lots of shootout examples where Haskell programs seem to perform
 comparably with C programs, but I find it hard to reproduce anything
 like those figures when testing with my own code. So here's a simple
 case:
 
 I have this C program:
 
 #include stdio.h
 
 #define n 1
 
 double a[n];
 
 int main()
 {
int i;
for (i = 0; in; ++i)
{
a[i] = 1.0f;
}
for (i = 0; in-1; ++i)
{
a[i+1] = a[i]+a[i+1];
}
printf(%f\n,a[n-1]);
 }
 
 And this Haskell program:
 
 import Data.Array.IO
 import Control.Monad
 
 n = 1000
 
 main = do
a - newArray (0,n-1) 1.0 :: IO (IOUArray Int Double)
forM_ [0..n-2] $ \i - do { x - readArray a i; y - readArray a
 (i+1); writeArray a (i+1) (x+y) }
x - readArray a (n-1)
print x
 
 Even though 'n' is 10 times bigger in the C program it runs much
 faster than the Haskell program on my MacBook Pro with Haskell 6.6.1.
 I've tried lots of different combinations of flags that I've found in
 various postings to haskell-cafe but to no avail.
 
 What flags do I need to get at least within a factor of 2 or 3 of C?
 Am I using the wrong kind of array? Or is Haskell always going to be
 15-20 times slower for this kind of numerical work?

Wow.  You should *really* try using GHC 6.8.1:

GHC 6.6.1  (-O2)

real0m7.062s
user0m5.464s
sys 0m0.288s

GHC 6.8.0.20071019 

real0m0.723s
user0m0.616s
sys 0m0.100s

result is 2.0e7 for both


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


Re: [Haskell-cafe] Haskell performance question

2007-11-08 Thread Thomas Schilling
On Thu, 2007-11-08 at 16:24 -0800, Stefan O'Rear wrote:
 On Thu, Nov 08, 2007 at 07:57:23PM +0100, Thomas Schilling wrote:
  
  $ ghc --make -O2 ghc-bench.hs
  
  and got:
  
  $ time ./ghc-bench 
  2.0e7
  
  real0m0.714s
  user0m0.576s
  sys 0m0.132s
  
  $ time ./ghcbC 
  2000.00
  
  real0m0.305s
  user0m0.164s
  sys 0m0.132s
  
  This is on a first-gen Macbook running Ubuntu.  1GB RAM.  1.83Ghz Core
  Duo
  
  $ ghc --version
  The Glorious Glasgow Haskell Compilation System, version 6.8.0.20071019
  
  $ gcc --version
  gcc (GCC) 4.1.2 (Ubuntu 4.1.2-0ubuntu4)
  Copyright (C) 2006 Free Software Foundation, Inc.
  This is free software; see the source for copying conditions.  There is
  NO
  warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
  PURPOSE.
  
  
  ___
  Haskell-Cafe mailing list
  Haskell-Cafe@haskell.org
  http://www.haskell.org/mailman/listinfo/haskell-cafe
  $ gcc -O3 ghc-bench.c -o ghcbC
  ghc-bench.c: In function ‘main’:
  ghc-bench.c:16: warning: incompatible implicit declaration of built-in
  function ‘printf’
 
 -O3 is worse than -O0, DO NOT USE IT.
 
 I reported the bug several months ago.  In the meantime, use -O2.
 
 (there are no high optimizations, it's just that the option parser
 misparses -O3)
 
 Stefan

Even for GCC (/not/ G_H_C)?  I know about the GHC bug, that's why I used
-O2 for GHC/Haskell and -O3 for GCC/C.

/Thomas

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


Re: [Haskell-cafe] hoogle broken?

2007-11-07 Thread Thomas Schilling
On Tue, 2007-11-06 at 19:20 -0800, Michael Vanier wrote:
 It looks as if hoogle isn't working.  I get 404s whenever I try to do any 
 search on hoogle.
 
 Mike

Yes, that's because the ghc-docs now have been slightly reorganized.
Neil said he's working on it.


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


Re: [Haskell-cafe] type/class question: toString

2007-11-06 Thread Thomas Schilling
On Tue, 2007-11-06 at 09:18 -0500, Graham Fawcett wrote:
 Hi folks,
 
 Is there a way to declare a 'toString' function, such that
 
 toString x | x is a String = x
 toString x | x's type is an instance of Show = show x
 
 Perhaps, in the type system, there's a way to declare a ToString
 class, and somehow inherit all instances of Show as ToString
 instances?

I think the simpler solution (for your particular problem) is to tag
strings that should be printed as-is:

newtype Literal = Literal String

instance Show Literal where show (Literal x) = x

lit :: String - Literal
lit = Literal 

I generally try to keep the law

  read . show == id

Thus, for anything that needs to be printed in a nicer way I use
something like this:

class PPrint a where
  pretty :: a - Doc   


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


Re: [Haskell-cafe] FP design

2007-11-06 Thread Thomas Schilling
On Tue, 2007-11-06 at 10:32 +1030, Levi Stephen wrote:
 Hi,
 
 I'm was wondering how most people work during when designing a functional 
 program. Do you create data structures/types first? Do you work from some 
 type 
 signatures?

As others have mentioned: both.  But there's a third thing that you can
do, other than start implementing:  think about the laws/properties that
should hold.  That's not always simple, in fact, it rarely is.  But it
helps you get one step closer to what you need to implement.  If you can
find useful properties, though, you get lots of test-cases for free by
formulating and testing them using QuickCheck.

Then, when implementing, you probably realize that you might need some
more combinators.  I usually then stop and implement the combinator
first, test it and continue.  

Some other guidelines I recommend: 

 * Try not to be too abstract in the first place.  Try implementing a
specialized version first, and then see how you can abstract it, once
you implemented all facets.  Sometimes, you need to add some instance
constraints, but the compiler will tell you where.

 * Test early and often.  Note that in Haskell you can get the compiler
to typecheck successfully by adding dummy-definitions using _ and
undefined.  E.g.:

foo :: A - B - C
foo _ _ = undefined

 * Define abstract types, or at least type synonyms.  It's so easy to
define new abstract types in Haskell, that you should do it often.  This
makes it much easier to later choose the proper data structure, once you
know what details you need.  Also, it's implicit documentation, compare

type Author = String;  type Title = String
addPost :: Author - Title - String - Blog - Blog

and

addPost :: String - String - String - Blog - Blog

 * Think about complexity of your primitives.  This is hard to fix
later, so it should be taken into account early on.  Of course, there's
sometimes a fine line between mature and premature optimizations.

 * As Don often says, try to keep things pure wherever possible.  It
will make your code so much more compositional, easier to test and
correct.

There's more, but I'll stop here for now...


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


Re: [Haskell-cafe] viewing HS files in Firefox

2007-10-27 Thread Thomas Schilling
On Sat, 2007-10-27 at 18:48 -0400, Isaac Dupree wrote:
 When I try to go to one of the Module.hs files, e.g. on 
 darcs.haskell.org, it now has type HS and Firefox refuses to display it 
 (and only lets me download it).  Does anyone know how to make Firefox 
 treat certain file types as others (HS as plain text, in particular)? 
 so that I can browse them with any convenience


I believe those kinds of problem have to do with the MIME-encoding on
the server side:  The server uses text/x-haskell.  For Firefox to
display the document inline it probably has to be text/plain.  Not sure
what the proper fix is, though.

/ Thomas

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


Re: [Haskell-cafe] Manual constructor specialization

2007-10-09 Thread Thomas Schilling
On Tue, 2007-10-09 at 17:40 +0200, Johan Tibell wrote:
 On 10/9/07, David Benbennick [EMAIL PROTECTED] wrote:
  On 10/9/07, Johan Tibell [EMAIL PROTECTED] wrote:
   data Rope = Empty
 | Leaf
 | Node !Rope !Rope
 
   The point is that Empty
   can only appear at the top by construction
 
  How about indicating this in your data type?  I.e.,
 
  data Rope = Empty | NonEmptyRope
  data NonEmptyRope = Leaf | Node !NonEmptyRope !NonEmptyRope
 
 
 That would be an idea. What are the performance effects of this? I'm
 trying to not have too many layers of indirection (I will spend quite
 some time reading -ddumpsimpl to optimize this library so anything
 that makes that simpler is a Good Thing.)

Another approach would be to define your invariant as a QuickCheck
property.  If you run your test suite often enough you will still find
errors quickly.

W.r.t. performance, note that allocating data on the C-stack might be
slow, so make sure you also measure this.

/ Thomas

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


Re: [Haskell-cafe] transparent parallelization

2007-09-18 Thread Thomas Schilling
On Tue, 2007-09-18 at 18:13 +0200, Thomas Girod wrote:
 Hi there. Beeing rather new to the realm of Haskell and functional
 programming, I've been reading about how is easier it is to
 parallelize code in a purely functional language (am I right saying
 that ?).
 
 My knowledge of parallelization is also very weak, but I've been
 thinking about this and I have a question. Let's say we take a small
 piece of code, like the quicksort algorithm.
 
  qsort [] = []
  qsort (x:xs) = qsort lesser ++ [x] ++ qsort greater 
  where lesser = filter (x) xs
greater = filter (=x) xs
 
 (actually I didn't test this code, this is just for the example)
 
 Here, computing lesser and greater are two disjoint actions - we
 don't need the result from one to compute the other, and haskell does
 not allow one to alter data so that would change the behaviour of the
 other. So I guess those could be run in parallel. 
 
 Would it be fairly simple to automatically determine parts of code
 that can be run in parallel, and parts that cannot (at least in
 non-monadic code) ?
 
 So the final question is : if it is possible to automatically define
 segments of code that can be run in parallel, is [insert compiler name
 here] compiling this code as a one thread thing, or as a multithreaded
 version ? 
 
 I guess on single processor machines, it is more efficient to do it as
 a single thread - but with those many-cores processors that are
 coming, it probably won't be true anymore.
 
 Sorry if this post is blowing off open doors (I guess this doesn't
 mean anything in english but it sounds cool) ... 
 

Detecting parallelism is possible, but generally rather fragile.
Coarse-grained parallelism in form of threads (or processes) is only
efficient if enough data can be processed in parallel.  This in turn is
determined by the data-dependencies, which are hard to detect
automatically.  To preserve program semantics the analysis has to be
conservative, i.e., assume that two parts of a program depend on each
other unless it can prove otherwise.  (OpenMP relies on the programmer
to explicitly declare what to parallelize.)

A better way is to let the user specify the algorithm at a higher level.
One very promising technique to do this is explored in Data Parallel
Haskell (DPH) [1].  In DPH you specify your algorithm as functional
programs operating on vectors, and even allows nested parallelism, i.e.,
you can call parallel functions inside parallel functions.  If
implemented naïvely, this could easily lead to inefficiencies due to too
little workload per thread.  This is where GHCs rewriting capabilities
kick in and transform nested parallel programs into flat parallel
programs.  I really recommend reading the paper(s) (see [1]).

/ Thomas

[1] .. http://haskell.org/haskellwiki/GHC/Data_Parallel_Haskell


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


Re: [Haskell-cafe] Monad.Reader 8: Haskell, the new C++

2007-09-13 Thread Thomas Schilling
On Fri, 2007-09-14 at 10:42 +1200, ok wrote:
 I wrote:
  Since not all Turing machines halt, and since the halting problem is
  undecidable, this means not only that some Haskell programs will make
  the type checker loop forever, but that there is no possible meta-
  checker that could warn us when that would happen.
 
 On 13 Sep 2007, at 4:27 pm, Stefan Holdermans wrote:
  Do not forget that both functional dependencies and associated  
  types come with syntactic restrictions that are there just to  
  tame the Turing completeness, i.e., to guarantee that type  
  checking will actually terminate.
 
 I don't know anything about associated types, so can't comment on those.
 But on the subject of functional dependencies, you and the author of the
 article in Monad.Reader 8 *cannot* both be right, because the whole
 point of that article is to explain how to program in the type system,
 using, amongst other things, conditionals and recursion, in such a way
 that a Turing machine can surely be simulated.  If there is some
 restriction to guarantee termination, then those techniques can't work.
 
 
  Admittedly, it's my experience that whenever one wants to do  
  something interesting (and here I mean interesting in a way that  
  you would probably label as rather twisted ;-)), one has to  
  bypass these restrictions (and, hence, allow for potentially  
  undecidable instances).
 
 Ah, now we have it.  To quote Conrad Parker:
  This tutorial uses the Haskell98 type system extended with
  multi-parameter typeclasses and undecidable instances.
  We need to enable some GHC extensions to play with this type- 
 hackery:
  $ ghci -fglasgow-exts -fallow-undecidable-instances
 
 That is the combination I'm talking about.
 
  Now, I haven't really worked with associated types (or, for that  
  matter, associated type synonyms), but my hope is that, when using  
  those, turning off the checks is needed less often. We'll see.
 
 If you hope that, then we probably agree more than you might think.
 My point is that the combination exists and is being explained so that
 people can use it, and that the result is comparable in C++.  (Imagine
 Dame Edna Everage saying I mean that in a loving way, possums.)

The type system doesn't help you avoid writing non-terminating programs,
so i see no problem with it being possible giving programmers the power
to express and check more complex properties of their programs -- as
long as type-checking remains sound.  From a practical standpoint,
non-terminating type checks are just as much a bug as non-terminating
library functions.  Type systems need more thought anyways, so why not
make sure it's terminating, too?  The other extreme is to use dependent
types everywhere, but this has a bit more drastic consequences to the
accessibility and practicality of the language.

I don't think this will become a mainstream tool any time soon, but it
may turn out to be very valuable to library authors.  We also shouldn't
forget that this is a brand-new feature and requires proper evaluation;
how better could this be achieved than by having it included as an
optional feature in a mature and well-used compiler?  I am glad that
Haskellers try to integrate theory and practice that nicely.

/ Thomas

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


Re: [Haskell-cafe] haskell on llvm?

2007-09-13 Thread Thomas Schilling
On Thu, 2007-09-13 at 15:58 -0700, Don Stewart wrote:
 clawsie:
  has anyone ever considered using llvm as a infrastructure for haskell
  compilation? it wold seem people are looking at building frontends for
  scheme, ocaml, etc. i don't know if an alternate backend is
  appropriate, but it would seem to be an interesting way to aggregate
  the best thinking for various optimizations over a more diverse group
  of developers.
 
 People are definitely interested in it. Needs some people with compiler
 experience and GHC experience to tackle it seriously, I suspect.

Reading and writing llvm files could also be useful to
prototype/implement compiler passes using Haskell.

/ Thomas

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


Re: [Haskell-cafe] haskell on llvm?

2007-09-13 Thread Thomas Schilling
On Thu, 2007-09-13 at 15:55 -0700, brad clawsie wrote:
 has anyone ever considered using llvm as a infrastructure for haskell
 compilation? it wold seem people are looking at building frontends for
 scheme, ocaml, etc. i don't know if an alternate backend is
 appropriate, but it would seem to be an interesting way to aggregate
 the best thinking for various optimizations over a more diverse group
 of developers.

I applied for Google Summer of Code with the suggestion to write a
library to generate (and compile) LLVM code (not my idea in the first
place, but I liked it), but it didn't get into the top 9 (i.e., funded)
projects.  It's certainly not a bad idea, but the immediate use to the
community would admittedly not be too great.  Targeting an existing
Haskell compiler would probably be doable, but I am unsure what the big
advantages would be.  Many optimizations implemented for llvm are more
high-level in nature and wouldn't make much sense for Haskell compilers,
since translating to llvm would lose some information, and Haskell,
being a lazy language, requires/enables non-standard transformations.
Haskell-compilers currently require better low-level optimizations
(instruction scheduling, register allocation, maybe memory locality
optimazitions).  I'm not up to date with how well llvm scores in these
areas, but last time I checked it was slower than ghc, and ghc already
isn't too great at this kind of stuff (compared to icc).

I could however see some applications of an llvm-generation library for
DSLs that require high performance, and currently have to invoke gcc at
runtime.

/ Thomas

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


Re: [Haskell-cafe] Data.Binary Endianness

2007-09-10 Thread Thomas Schilling
On Mon, 2007-09-10 at 11:10 +0100, Jules Bean wrote:

 The docs are not as well interlinked as you might hope.

In fact, the docs on hackage are interlinked nicely.  That is, for
packages for which the documentation builds.

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


Re: [Haskell-cafe] Data.Binary Endianness

2007-09-10 Thread Thomas Schilling
On Mon, 2007-09-10 at 16:17 +0100, Jules Bean wrote:
 Thomas Schilling wrote:
  On Mon, 2007-09-10 at 11:10 +0100, Jules Bean wrote:
  
  The docs are not as well interlinked as you might hope.
  
  In fact, the docs on hackage are interlinked nicely.  That is, for
  packages for which the documentation builds.
 
 On the documentation page:
 
 http://www.cse.unsw.edu.au/~dons/binary/Data-Binary.html
 
 I see no links to Data.Binary.Put, nor anything to make me even suspect 
 that there is another page I should be reading. Nor anythign to suggest 
 that Data.Binary is split into two levels in the way I outlined in my 
 earlier message.
 
 Jules

No offence was intended.  I was simply mentioning a feature that might
be overlooked by many.  If you look at

  http://hackage.haskell.org/cgi-bin/hackage-scripts/package/binary-0.3

You can find links to the various modules provided by that package and
will notice that links to parts exported by other packages work nicely.
(In this case it is only base-2.0, I think.)

Your clarification is probably worth including into the package
documentation, but I think you have to talk to dons for that to happen.

/ Thomas

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


Re: [Haskell-cafe] Data.Binary Endianness

2007-09-10 Thread Thomas Schilling
On Mon, 2007-09-10 at 18:11 +0200, Sven Panne wrote:
 On Monday 10 September 2007 17:17, Jules Bean wrote:
  On the documentation page:
 
  http://www.cse.unsw.edu.au/~dons/binary/Data-Binary.html
  [...]
 
 Just a small hint: That page seems to be out of date compared to:
 
http://hackage.haskell.org/cgi-bin/hackage-scripts/package/binary-0.3
 
 The library looks quite nice, but I'm missing support for reading/writing 
 Int{8,16,32,64}

maybe this?

http://hackage.haskell.org/packages/archive/binary/0.3/doc/html/Data-Binary-Get.html#v%3AgetWord8
 

Also note that many Haskell standard types are instances of the Binary
class.  I might have misunderstood what you're asking for, though...

  and Float/Double (in IEEE format, currently *the* binary 
 representation in most formats I know) in LE/BE/host byte order. Have I 
 overlooked something? Using unsafeCoerce# and friend there are probably 
 workarounds for this, but having it in the official API would be quite 
 helpful for I/O of real-world formats.
 
 Cheers,
S.

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


Re: [Haskell-cafe] Data.Binary Endianness

2007-09-10 Thread Thomas Schilling
On Mon, 2007-09-10 at 18:40 +0200, Sven Panne wrote:

 Type classes might be used to get a slightly smaller API, but I am unsure 
 about the performance impact and how much this would really buy us in terms 
 of the ease of use of the API.

There shouldn't be any problem w.r.t. performance, the compiler can
specialize and inline.  What's the problem with reading custom data?

data MP3 = MP3 { ... }

instance Binary MP3 where
  get = MP3 $ getHeader * getData -- [*]
where getHeader = do magic - getWord32le
 case magic of
   ... 
  ...

  put = ...

to read a (IEEE) double you use

  do x - (get :: Double); ...

but most of the time the right type will be inferred from the context.
If there are serious performance problems it'd could probably be
attacked using some more use of inline declarations or maybe use of
compiler rewrite rules (in the library).  I don't expect things to work
as smoothly as they maybe could (the package is in version 0.3), but so
far things don't seem too bad.  Did you do any benchmarks?

/ Thomas 

[*] .. note that $ .. * is just a more convenient way of writing:
   do hdr - getHeader
  dat - getData
  return (MP3 hdr dat)
Those operators live in Control.Applicative and are included in
recent versions of the 'base' package.  (

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


Re: [Haskell-cafe] Haddock/hscolour integration broken on Hackage?

2007-09-10 Thread Thomas Schilling
On Mon, 2007-09-10 at 14:11 -0400, David Menendez wrote:
 I was looking at the Data.Binary documentation[1] on Hackage, and I've
 noticed some problems with the associated source listings[2].
 
 First, none of the Source links work. They all refer to fragment IDs
 (e.g., #Binary) that are not defined. I'm not sure if this is a
 problem with hscolor, haddock, or hackage.
 
 Second, the source listing itself[2] is invalid HTML[3]. The W3C
 validator lists 678 errors. Of these, 677 are have to do with the line
 number anchors, all of which start with parentheses. This is bad not
 only because HTML requires fragment ids to start with a letter, but
 because parentheses are not allowed to occur in URIs. As a result,
 links to line numbers will come out looking like
 Data-Binary.html#%28line100%29.
 
 [1] 
 http://hackage.haskell.org/packages/archive/binary/0.3/doc/html/Data-Binary.html
 [2] 
 http://hackage.haskell.org/packages/archive/binary/0.3/doc/html/src/Data-Binary.html
 [3] 
 http://validator.w3.org/check?uri=http%3A%2F%2Fhackage.haskell.org%2Fpackages%2Farchive%2Fbinary%2F0.3%2Fdoc%2Fhtml%2Fsrc%2FData-Binary.htmlcharset=%28detect+automatically%29doctype=Inlinegroup=1
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe

This might be related to the error message in the build log [1]

  Warning: Data.Binary: the following names could not be resolved:
v

which comes from the example in the description of the 'Binary' class.  I think 
the problem is the use of 'v' instead of @[EMAIL PROTECTED]

Interestingly, it works for the other modules like Data.Binary.Put and .Get

[1] .. http://hackage.haskell.org/packages/archive/binary/0.3/log

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


Re: [Haskell-cafe] Tiny documentation request

2007-09-10 Thread Thomas Schilling
On Mon, 2007-09-10 at 20:28 +0100, Ian Lynagh wrote:

 Would it be better to have a separate page with a package index,
 containing the description of each package and a link to each of the
 modules that it provides?

+1

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


Re: [Haskell-cafe] Tiny documentation request

2007-09-10 Thread Thomas Schilling
On Mon, 2007-09-10 at 19:51 +0100, Andrew Coppin wrote:
 Brent Yorgey wrote:
  And if you use Firefox, you can even install Hoogle as one of the 
  search engines in the upper-right search box.  Nice and fast!
 
 I've never really understood what the benefit of this is... I mean, 
 Google make the Google toolbar, but what's the point? Why not just 
 click on the Google bookmark and type in your search? What benefits does 
 installing a special addon provide?

Well, for the default Google searchbox the advantage is:

  Ctrl-K search phrase ENTER

versus

  grab mouse .. point ... click ... move hand back to keyboard ... type
search phrase, ENTER

I never used any of the secondary search bars.  Unless I can define a
shortcut to access hoogle quickly there's no advantage.


However, regarding the modules list.  I think it should be easy to have
optional javascript functionality to toggle the visibility of the module
tree.  The default visibility could be customized using a cookie.

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


Re: [Haskell-cafe] is there a way to patch the build-depends line of a cabal file without breaking backwards compatibility?

2007-08-20 Thread Thomas Schilling


On 20 aug 2007, at 18.37, Thomas Hartman wrote:



cafe, is there a way to patch the build-depends line of a cabal  
file without breaking backwards compatibility?


I just patched HDBC head to compile under ghc 6.7. Unfortunately it  
now won't compile in 6.6.1.


is there a way for build-depends to detect which version of ghc  
you're on?


also I seem to recall that -fglasgow-exts was deprecated under 6.7.  
is there a better way to beat back the error message below than this?




The next release of Cabal (and the current HEAD) supports  
conditionals to test for flags, os/arch, and implementation  
(+version).  Note that the problem isn't the GHC version, but the new  
base version, in which the old base was split up into smaller  
packages, so we have something roughly like:  base-1.0 = base-2.0 +  
bytestring + old-time + mtl.  Take a look at the Cabal.cabal file,  
how this is solved, atm.  Please also note that this might not be the  
best way to use the new features;  as I suggested in another thread,  
simulating base-1.0 on systems with base-2.0 is probably best handled  
with a base.cabal file that imports base-2.0, old-time, etc. and re- 
exports all imported modules to get a virtual base-1.0.


/ Thomas

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


Re: [Haskell-cafe] is there a way to patch the build-depends line of a cabal file without breaking backwards compatibility?

2007-08-20 Thread Thomas Schilling


On 20 aug 2007, at 20.58, Thomas Hartman wrote:



 Take a look at the Cabal.cabal file, how this is solved, atm.

where is this, how can I take a look at it?


http://darcs.haskell.org/cabal/Cabal.cabal

See below for a little more explaination.



 The next release of Cabal (and the current HEAD) supports   
conditionals


I couldn't install head, but since I'm running 6.7, do I already  
have it?




Yes, you already have it.  It should be in ghc/libraries/Cabal, or  
contrib/Cabal


[EMAIL PROTECTED]:~/installs/cabal-head/cabalrunghc Setup.lhs  
configure


Distribution/Simple/InstallDirs.hs:267:36:
Not in scope: `dropDrive'

[EMAIL PROTECTED]:~/installs/cabal-head/caballs -l `which ghc`
lrwxrwxrwx 1 root root 31 2007-08-20 11:08 /usr/local/bin/ghc - / 
usr/local/bin/ghc-6.7.20070816




See Neil's reply.



[EMAIL PROTECTED]:~/installs/cabal-head/cabalghc-pkg list | grep - 
i cabal

Cabal-1.1.7

  Please also note that this might not be the
 best way to use the new features;  as I suggested in another thread,
 simulating base-1.0 on systems with base-2.0 is probably best  
handled

 with a base.cabal file that imports base-2.0, old-time, etc. and re-
 exports all imported modules to get a virtual base-1.0.

I'm interested in seeing how this works, but I couldn't find that  
other thread.




There is no formal proposal, yet, and I think the note was in a  
recent thread on cabal-devel or libraries.  Therefore, I won't  
discuss it here.  I can tell you the current solution, though.


Where is the documentation for the new functionality in cabal head,  
or do you just have to read the source code for now?


Performing (in the Cabal directory) make doc should build the  
haddocks and the latest user's guide.  Performing make users-guide  
should only build the user's guide, but since that requires some  
tools which might be non-trivial to set up on some systems, I didn't  
recommend it.


So here's the relevant part of how Cabal.cabal does it:

  if flag(small_base) {
-- For ghc 6.2 you need to add 'unix' to Build-Depends:
Build-Depends: base, filepath, pretty, directory, old-time,  
process, containers

  } else {
Build-Depends: base, filepath
  }

Note, that the format changed to a sectioned format, and that it is  
quite likely that it will still change slightly before the release.   
Consult the Cabal user's guide or (probably easier) take a look at  
other .cabal files in the ghc tree.  It's quite straightforward,  
actually.


The interesting feature here is that unless overridden explicitly,  
the flag small_base will be assigned to a value appropriate for the  
system, thus, if you don't have any of the packages pretty,  
directory, etc, it will automatically be assigned to false. (I think  
it better should be base = 2.0, though.)


(Also, the comment can now be replaced by an actual test like: if impl 
(ghc =6.2) ..)


HTH
/ Thomas


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


Re: [Haskell-cafe] Syntax for lambda case proposal could be \of

2007-08-16 Thread Thomas Schilling


On 16 aug 2007, at 13.46, Bertram Felgenhauer wrote:


Duncan Coutts wrote:

On Wed, 2007-08-15 at 11:06 -0700, Stefan O'Rear wrote:


foo = getSomethingCPS $ \ arg -
  moreStuff

is now a syntax error (\ { varid - } matches no productions).


I'm not sure I follow.

The patterns would have to match up in a column, so

foo = getSomethingCPS $ \ arg -
  moreStuff

should be fine, to add another alternative it'd have to be:

foo = getSomethingCPS $ \ Pat1 -
  moreStuff
  Pat2 -
  evenMoreStuff


I don't like this - it's not in the spirit of the existing layout
rule at all. You should have to indent 'moreStuff' deeper than
Pat1 I think;


foo = getSomethingCPS $ \ Pat1 -
  moreStuff
  Pat2 -
  evenMoreStuff


would be (visually) ok. But then Stefan's point is valid.

So there should be two productions, I think, one for non-case
lambdas and one for case-lambdas, like this:

non-case-lambda:
  '\' apat+ '-' expr

case-lambda:
  '\' '{' ( apat+ '-' expr ';' )* '}'

Unfortunately this naive approach would add another point of
arbitrarily large look-ahead to the grammar. The easiest way to
resolve this is to add some keyword before or after '\',
bringing is back to the previous proposals.

I like both

   \of x y z - ...
   a b c - ...

and

   case \ of x y z - ...
 a b c - ...

(I'd add the space here, viewing \ as a pseudo-expression)

In the spirit of the \\ proposal, while \\ itself is an operator,

  \ \ x y z - ...
  a b c - ...

is still available as a syntax, but may be confusing.


  .\ x y z - ...
 a b c - ...

or just require unicode \lambda ;)

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


Re: [Haskell-cafe] Using haskell with emacs

2007-08-06 Thread Thomas Schilling


On 6 aug 2007, at 22.11, Paulo J. Matos wrote:


Hi all,

I'm starting to learn haskell by my own, being currently mostly a
Common Lisp, Scheme, C++ programmer... I've got the haskell emacs mode
but can't find a manual. Moreover, I've found some keybindings on the
net but nothing that allows me to start an interpreter in emacs and
send definitions, one by one to the interpreter. Is this possible? Is
there any good reference of the emacs keybindings for haskell mode?


If you're used to Slime+Paredit, then there isn't something really  
comparable, but you get some basic interactive programming with the  
standard key-bindings:


  C-c C-b ... when pressed for the first time this will start an  
interpreter (ghci or hugs most of the time), when pressed with a  
running interpreter it'll switch to that buffer.


  C-c C-l ... Load the current file into the editor.  There is no  
function-wise compilation.


With the latest Haskell mode, you get clickable error messages, too.

Then there is shim[1], which is a start of a Slime-like emacs mode,  
it can:


 - compile and show compile errors directly in the source (C-c C-k)

 - insert the type of a function (C-c C-t)

The big problem with shim is, that it is only really useful as long  
as your code compiles.  To have anything more useful you need to have  
good (incremental) parsing facilities, which Emacs isn't particularly  
good at.  Every once in a while I do some hacking towards this goal,  
but it's rather low-priority (and I'm no particular Emacs guru  
either, though with (require 'cl) it get's somewhat more fun.)


Many Haskell hackers also prefer Vim, so that doesn't help, either ;)

Oh, and there's hoogle.el, which is pretty similar to Hyperspec  
lookup (actually, I think it's better; more like Lisp-doc lookup).


Regards,
/ Thomas


[1] ..  http://shim.haskellco.de/trac/shim
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] RE: Speedy parsing

2007-07-22 Thread Thomas Schilling


On 22 jul 2007, at 23.46, Benjamin Franksen wrote:

On a different note: I've been wondering how difficult it would be to
re-write Parsec so that it doesn't act on a /list/ of tokens but on a
Sequence (defined in Data.Collections from collections package).  
Because

this would mean one could use String as well as ByteString.


That's (Summer of Code) work in progress:

   http://code.google.com/soc/2007/haskell/appinfo.html? 
csaid=B97EF4562EF3B244


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


Re: [Haskell-cafe] let vs do?

2007-06-29 Thread Thomas Schilling

On 29 jun 2007, at 16.26, Dave Bayer wrote:

That way you would have to use monads everywhere.


As you already hinted at in a later message, this has to do with  
let-bindings being potentially polymorphic and monadic bindings  
being necessarily monomorphic:


Are there papers that prove this need be the case in any language,  
or are we simply now trapped into this for the moment by some  
design choices?


The big design choice is to have non-strict evaluation semantics.   
Monads re-sequence instructions for cases where you need it.  Recall  
that in Haskell


  let x = foo bar baz
  y = error Gotcha.
  in (x, y)

isn't equivalent to

  (let ((x (foo bar baz))
(y (error Gotcha.)))
 (values x y)

because Lisp is strict.  In Lisp this would result in an error, even  
if y is never used, in Haskell only once y is actually used.


To simulate this in Haskell you'd have to write:

  do x - foo bar baz
 y - error baz
 return (x, y)

and choose the monad according to your semantics.

I take it, your claim now is that by choosing the Identity monad,  
we'd get normal Haskell semantics (modulo polymorphic types?) and  
using any other monad we'd get any other semantics?


Some problems I can see with this is:

  - Monads aren't transparent to the compiler.  The compiler would  
still have to transform it into a pure intermediate form.


  - Most importantly, monads sequence computation.  But I guess you  
can get around it.  After all, you can simulate Haskell in strict  
lisp via:


  (let ((x (delay (foo bar baz)))
(y (delay (error Gotcha
 (delay (values x y)))

  - So, I assume the big question is how not to lose type inference,  
and get used to the less pretty syntax ;)


Maybe, others can comment on these issues.

/ Thomas

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


Re: [Haskell-cafe] Newbie question: alternative for toInt/fromInt

2007-06-28 Thread Thomas Schilling

toInt = id
fromInt = id

?

On 28 jun 2007, at 21.16, peterv wrote:

I’m trying to get the SOE graphics library to compile for Win32  
using the latest libraries.




I fixed a couple of imports, but in the file GraphicsTypes.hs, the  
functions toInt/fromInt are used, which are now obsolete:




type Dimension = Int

toDimension:: Win32.INT - Dimension

fromDimension  :: Dimension - Win32.INT

toDimension   = toInt

fromDimension = fromInt



I don’t have a clue how to fix this, as I can’t find alternatives  
for toInt/fromInt (except toInteger/fromInteger, but that would  
convert to heavyweight ints), but I guess it must be really easy?




Thanks,

Peter





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


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


Re: [Haskell-cafe] let vs do?

2007-06-28 Thread Thomas Schilling


On 28 jun 2007, at 21.17, Greg Meredith wrote:


Once you have a polymorphic let, why do you need 'let' in the base  
language, at all? Is it possible to formulate Haskell entirely with  
do-notation where there is a standard monad for let environments?  
Probably this was all discussed before in the design deliberations  
for the language standard. Pointers would be very much appreciated.




  let x = ... in ...

is only equal

  do x - ...; ...

in the Identity monad.  Also, why would do be more primitive than  
let.  That way you would have to use monads everywhere.  Also, let  
is treated specially by the type checker (IIRC) and there are many,  
many other reasons not to do that.


Why would you consider the syntactic sugar do { x - e; .. } which is  
just a different way of writing function binding (e = \x - ...)  
consider more primitive than let?


/ Thomas

 
___

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


Re: [Haskell-cafe] let vs do?

2007-06-28 Thread Thomas Schilling


On 28 jun 2007, at 22.02, Greg Meredith wrote:


Thomas,

Thanks for the reply. My thinking was that once you have a  
polymorphic form, why single out any other? Less moving parts makes  
for less maintenance, etc.




Ok, sorry if my reply seemed harsh.  You are of course right, that  
having few primitives is better.  In Haskell you have two primives:   
function binding and let-binding.  Let bindings are always recursive,  
thus


  let x = e in body   =/=   (\x - body) e

because x also is bound to itself in e.

Since, do-binding is defined in terms of normal lambda-binding, there  
are no more primitives.


/ Thomas


PS: let is treated specially by the type-checker too.  The  
technical term is let-polymorphism, but I couldn't find any good  
results, using a quick google search.  Hopefully, others will chime in.

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


[Haskell-cafe] Cabal Configurations - Beta-Testers Wanted

2007-06-27 Thread Thomas Schilling

Hello Cafe!

Cabal configurations are an often-requested new feature of Haskell's  
packaging system Cabal.  As part of my Google Summer of Code project  
I implemented it with the feature set of the latest proposal[1].  I  
would now like people to try it out and give some feedback if it  
solves their problems, if there are bugs with the current  
implementation, or if it breaks any install scripts.


So, if you have written a package and think your package could profit  
from Cabal configurations, please adjust your package description and  
try to build it on as many systems as possible and report any  
problems (or successes).


Following are some instructions to get started.

Thanks,

/ Thomas



INSTALLING

[Note: The following build instructions are for a recent GHC.  If you  
have another Haskell compiler/interpreter you'll probably have to  
adjust these steps a bit.  Please report any problems you encounter.]


You should be able to get Cabal with configurations via:

  $ darcs get --partial http://code.haskell.org/~nominolo/src/cabal 
+configs/


Before installing you might want to hide the current cabal package  
using (tt shouldn't be necessary, though) via


  $ ghc-pkg hide Cabal

or

  $ sudo ghc-pkg hide Cabal

depending on where Cabal is installed.

Installing the new Cabal should be as simple as:

  $ cd cabal+configs
  $ make install user=y PREF=~/sw

This will build Cabal with version 1.1.7, register it in the current  
user's package database, and install it to the sw directory of the  
current user home directory.  Adjust the parameters to your needs.


To remove use:

  $ make remove user=y PREF=~/sw



NEW FEATURES

The new constructs didn't integrate well with the conventional  
syntax, so I changed it to a C-style block-style syntax.  (This is  
consistent with Haskell's use of { .. } in do-blocks; adding or  
replacing this with an indentation-based approach is thinkable and  
might actually integrate better with the rest of Cabal file syntax.   
So yell if you want it--but no bike sheds please! ;)


The new syntax structures cabal files like this:

global properties

optional flags descriptions

Library {
  library build properties and conditionals
}

Executable name {
  executable build properties and conditionals
}

For an example, see below.

Inside the Library and executable sections you can now use  
conditionals with the syntax:


  body: cabal_stanza \n body
  | if conditional { body } [ else { body  
} ] body

  | nothing

  conditional:  os( string )
  | arch( string )
  | flag( flagname )
  | True
  | False
  | ! conditional
  | conditional || conditional
  | conditional  conditional
  | ( conditional )

Note that you cannot test for dependencies directly.  The user either  
specifies certain features she wants by switching flags on or off  
during the configure step or Cabal picks a suitable flag assignment  
for you, depending on which dependencies are available.  Unless  
specified otherwise, flag assignments default to True.


ATM, the only field specifying dependencies is build-depends.   
Options specified inside a conditional are (mostly) added to the  
values specified outside.  E.g.


  GHC-Options: -Wall
  if flag(debug) {
GHC-Options: -DDEBUG
  }

when built with flag debug set to True will be built with

  GHC-Options: -Wall -DDEBUG

For a more detailed description see[1].  The following example .cabal- 
file should demonstrate the features (it is also available and  
updated at[2]):


Name: Test1
Version: 0.0.1
Cabal-Version: = 1.1.7
License: BSD3
-- License-File: LICENSE
Author: Thomas Schilling [EMAIL PROTECTED]
Maintainer: Thomas Schilling [EMAIL PROTECTED]
--Homepage: http://www.example.com/
Synopsis: Test package to test configurations
Description:
See synopsis.
.
Really.
Category: Useless

Flag Debug {
  Description: Enable debug support
  Default: False
}

Flag NoBuild {
  Description: Inhibit building this package.
  -- defaults to True
}

Library {
  Build-Depends:   base
  Exposed-Modules: Testing.Test1
  Extensions:  CPP

  -- flag names are case insensitive
  if flag(debuG) {
CC-Options: -DDEBUG
GHC-Options: -DDEBUG
  }

  if flag(NoBuild) {
Build-Depends: nonexistentpackage
  }
}

Executable test1e {
  Main-is: T1.hs
  Other-modules: Testing.Test1

  if flag(debug) {
CC-Options: -DDEBUG
GHC-Options: -DDEBUG
  }
}

When configuring it with the usual command line, you now get an  
additional line, showing which flags were chosen:


$ ./Setup.lhs configure
configure: Reading installed packages...
Configuring Test1-0.0.1...
configure: Flags chosen: nobuild=False, debug=False
Setup.lhs: Warning: No license-file field.
configure: Dependency base-any: using base-2.1.1
  [...]

Note

Re: [Haskell-cafe] Collections

2007-06-25 Thread Thomas Schilling

On 25 jun 2007, at 20.38, Andrew Coppin wrote:


Lennart Augustsson wrote:
If you don't run into graphs you are either solving very peculiar  
problems, or you don't recognize them when you see them.  They are  
everywhere.


I see lots of *trees*, but no general graphs. (As in, *data*  
structures having cycles in them. My *code* is often cyclic...)


Graphs may appear as infinity trees, you know.

data Tree = L Int | B Tree Tree deriving Show

t1 = B (L 42) (B (L 23) t1)

= B (L 42) (B (L 23) (B (L 42) (B (L 23) (B (L 42) (B (L 23) (B (L  
42) ...

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


Re: [Haskell-cafe] Installing HOpenGL

2007-06-24 Thread Thomas Schilling
That looks like a missing C macro definition.  It should probably  
expand to either stdcall or ccall.  A bit more information would be  
helpful.



On 24 jun 2007, at 13.11, Jimmy Miller wrote:


I'm trying to install HOpenGL 2.1, with ghc 6.6 on Windows XP.
runghc Setup.hs configure seems to work fine.  It gives messages about
things missing, like sh, but there are no errors.

When I run runghc Setup.hs build, I get the following error:

[ 4 of 81] Compiling Graphics.Rendering.OpenGL.GL.Extensions  
( Graphics/Renderin
g/OpenGL/GL/Extensions.hs, dist\build/Graphics/Rendering/OpenGL/GL/ 
Extensions.o

)

Graphics/Rendering/OpenGL/GL/Extensions.hs:46:15:
   parse error on input `CALLCONV'

Does anyone know what might be going wrong?

--
a href=http://www.spreadfirefox.com/? 
q=affiliatesid=153516t=1textarea

rows=3 cols=40Get Firefox!/a
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


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


Re: [Haskell-cafe] Installing HOpenGL

2007-06-24 Thread Thomas Schilling
No, ffi is no extra package.  It would be helpful if you posted you  
configure output though.


BTW, please CC the list when replying.  The easiest way should be to  
use the reply all feature of your mail client.


Thanks,

Thomas


On 24 jun 2007, at 15.24, Jimmy Miller wrote:


That's all I know right now.  Is there another package I need to
install for the C FFI?  Also, is there any problem in Setup.hs saying
that sh was not found?

On 6/24/07, Thomas Schilling [EMAIL PROTECTED] wrote:

That looks like a missing C macro definition.  It should probably
expand to either stdcall or ccall.  A bit more information would be
helpful.


On 24 jun 2007, at 13.11, Jimmy Miller wrote:

 I'm trying to install HOpenGL 2.1, with ghc 6.6 on Windows XP.
 runghc Setup.hs configure seems to work fine.  It gives messages  
about

 things missing, like sh, but there are no errors.

 When I run runghc Setup.hs build, I get the following error:

 [ 4 of 81] Compiling Graphics.Rendering.OpenGL.GL.Extensions
 ( Graphics/Renderin
 g/OpenGL/GL/Extensions.hs, dist\build/Graphics/Rendering/OpenGL/GL/
 Extensions.o
 )

 Graphics/Rendering/OpenGL/GL/Extensions.hs:46:15:
parse error on input `CALLCONV'

 Does anyone know what might be going wrong?

 --
 a href=http://www.spreadfirefox.com/?
 q=affiliatesid=153516t=1textarea
 rows=3 cols=40Get Firefox!/a
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe





--
a href=http://www.spreadfirefox.com/? 
q=affiliatesid=153516t=1textarea

rows=3 cols=40Get Firefox!/a


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


Re: [Haskell-cafe] Installing HOpenGL

2007-06-24 Thread Thomas Schilling


On 24 jun 2007, at 19.53, Jimmy Miller wrote:


Thanks, didn't know that.
Here's the configure output:

Configuring OpenGL-2.1...
configure: C:\ghc\ghc-6.6\bin\ghc-pkg.exe
configure: Dependency base-any: using base-2.0
configure: Using install prefix: C:\Program Files
configure: Binaries installed in: C:\Program Files\Haskell\bin
configure: Libraries installed in: C:\Program Files\Haskell 
\OpenGL-2.1\ghc-6.6

configure: Private binaries installed in: C:\Program Files\OpenGL-2.1
configure: Data files installed in: C:\Program Files\Common Files 
\OpenGL-2.1

configure: Using compiler: C:\ghc\ghc-6.6\bin\ghc.exe
configure: Compiler flavor: GHC
configure: Compiler version: 6.6
configure: Using package tool: C:\ghc\ghc-6.6\bin\ghc-pkg.exe
configure: Using ar found on system at: C:\ghc\ghc-6.6\bin\ar.exe
configure: No haddock found
configure: No pfesetup found
configure: No ranlib found
configure: Using runghc found on system at: C:\ghc\ghc-6.6\bin 
\runghc.exe

configure: No runhugs found
configure: No happy found
configure: No alex found
configure: Using hsc2hs: C:\ghc\ghc-6.6\bin\hsc2hs.exe
configure: No c2hs found
configure: No cpphs found
configure: No greencard found
Setup.hs: Cannot find: sh



Oh.  This is an error during configuration.  I guess we could make  
cabal be more clear about this.


You probably have to install cygwin, I don't have any Windows system,  
so I don't know.  I presume the easiest option would be some binary  
distribution.  Isn't OpenGL part of GHC's extra packages?




On 6/24/07, Thomas Schilling [EMAIL PROTECTED] wrote:

No, ffi is no extra package.  It would be helpful if you posted you
configure output though.

BTW, please CC the list when replying.  The easiest way should be to
use the reply all feature of your mail client.

Thanks,

Thomas


On 24 jun 2007, at 15.24, Jimmy Miller wrote:

 That's all I know right now.  Is there another package I need to
 install for the C FFI?  Also, is there any problem in Setup.hs  
saying

 that sh was not found?

 On 6/24/07, Thomas Schilling [EMAIL PROTECTED] wrote:
 That looks like a missing C macro definition.  It should probably
 expand to either stdcall or ccall.  A bit more information  
would be

 helpful.


 On 24 jun 2007, at 13.11, Jimmy Miller wrote:

  I'm trying to install HOpenGL 2.1, with ghc 6.6 on Windows XP.
  runghc Setup.hs configure seems to work fine.  It gives messages
 about
  things missing, like sh, but there are no errors.
 
  When I run runghc Setup.hs build, I get the following error:
 
  [ 4 of 81] Compiling Graphics.Rendering.OpenGL.GL.Extensions
  ( Graphics/Renderin
  g/OpenGL/GL/Extensions.hs, dist\build/Graphics/Rendering/ 
OpenGL/GL/

  Extensions.o
  )
 
  Graphics/Rendering/OpenGL/GL/Extensions.hs:46:15:
 parse error on input `CALLCONV'
 
  Does anyone know what might be going wrong?
 
  --
  a href=http://www.spreadfirefox.com/?
  q=affiliatesid=153516t=1textarea
  rows=3 cols=40Get Firefox!/a
  ___
  Haskell-Cafe mailing list
  Haskell-Cafe@haskell.org
  http://www.haskell.org/mailman/listinfo/haskell-cafe




 --
 a href=http://www.spreadfirefox.com/?
 q=affiliatesid=153516t=1textarea
 rows=3 cols=40Get Firefox!/a





--
a href=http://www.spreadfirefox.com/? 
q=affiliatesid=153516t=1textarea

rows=3 cols=40Get Firefox!/a


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


Re: [Haskell-cafe] Installing HOpenGL

2007-06-24 Thread Thomas Schilling
Yes, the OpenGL website seems unmaintained.  I presume the easiest  
way to set it all up is to use the installer from

  http://www.haskell.org/ghc/download_ghc_661.html#windows

From the size of it it seems to include all the extra packages.

/ Thomas

On 24 jun 2007, at 21.50, Jimmy Miller wrote:


I already installed Cygwin; I'll go over the INSTALL file and make
sure I have all the required packages.

And there was an HOpenGL tutorial from 2001 that said OpenGL would
eventually be packaged with ghc, but I tried -package OpenGL and that
didn't work, and I'm not sure where else I could download it.

On 6/24/07, Thomas Schilling [EMAIL PROTECTED] wrote:


On 24 jun 2007, at 19.53, Jimmy Miller wrote:

 Thanks, didn't know that.
 Here's the configure output:

 Configuring OpenGL-2.1...
 configure: C:\ghc\ghc-6.6\bin\ghc-pkg.exe
 configure: Dependency base-any: using base-2.0
 configure: Using install prefix: C:\Program Files
 configure: Binaries installed in: C:\Program Files\Haskell\bin
 configure: Libraries installed in: C:\Program Files\Haskell
 \OpenGL-2.1\ghc-6.6
 configure: Private binaries installed in: C:\Program Files 
\OpenGL-2.1

 configure: Data files installed in: C:\Program Files\Common Files
 \OpenGL-2.1
 configure: Using compiler: C:\ghc\ghc-6.6\bin\ghc.exe
 configure: Compiler flavor: GHC
 configure: Compiler version: 6.6
 configure: Using package tool: C:\ghc\ghc-6.6\bin\ghc-pkg.exe
 configure: Using ar found on system at: C:\ghc\ghc-6.6\bin\ar.exe
 configure: No haddock found
 configure: No pfesetup found
 configure: No ranlib found
 configure: Using runghc found on system at: C:\ghc\ghc-6.6\bin
 \runghc.exe
 configure: No runhugs found
 configure: No happy found
 configure: No alex found
 configure: Using hsc2hs: C:\ghc\ghc-6.6\bin\hsc2hs.exe
 configure: No c2hs found
 configure: No cpphs found
 configure: No greencard found
 Setup.hs: Cannot find: sh


Oh.  This is an error during configuration.  I guess we could make
cabal be more clear about this.

You probably have to install cygwin, I don't have any Windows system,
so I don't know.  I presume the easiest option would be some binary
distribution.  Isn't OpenGL part of GHC's extra packages?


 On 6/24/07, Thomas Schilling [EMAIL PROTECTED] wrote:
 No, ffi is no extra package.  It would be helpful if you posted  
you

 configure output though.

 BTW, please CC the list when replying.  The easiest way should  
be to

 use the reply all feature of your mail client.

 Thanks,

 Thomas


 On 24 jun 2007, at 15.24, Jimmy Miller wrote:

  That's all I know right now.  Is there another package I need to
  install for the C FFI?  Also, is there any problem in Setup.hs
 saying
  that sh was not found?
 
  On 6/24/07, Thomas Schilling [EMAIL PROTECTED] wrote:
  That looks like a missing C macro definition.  It should  
probably

  expand to either stdcall or ccall.  A bit more information
 would be
  helpful.
 
 
  On 24 jun 2007, at 13.11, Jimmy Miller wrote:
 
   I'm trying to install HOpenGL 2.1, with ghc 6.6 on Windows  
XP.
   runghc Setup.hs configure seems to work fine.  It gives  
messages

  about
   things missing, like sh, but there are no errors.
  
   When I run runghc Setup.hs build, I get the following error:
  
   [ 4 of 81] Compiling Graphics.Rendering.OpenGL.GL.Extensions
   ( Graphics/Renderin
   g/OpenGL/GL/Extensions.hs, dist\build/Graphics/Rendering/
 OpenGL/GL/
   Extensions.o
   )
  
   Graphics/Rendering/OpenGL/GL/Extensions.hs:46:15:
  parse error on input `CALLCONV'
  
   Does anyone know what might be going wrong?
  
   --
   a href=http://www.spreadfirefox.com/?
   q=affiliatesid=153516t=1textarea
   rows=3 cols=40Get Firefox!/a
   ___
   Haskell-Cafe mailing list
   Haskell-Cafe@haskell.org
   http://www.haskell.org/mailman/listinfo/haskell-cafe
 
 
 
 
  --
  a href=http://www.spreadfirefox.com/?
  q=affiliatesid=153516t=1textarea
  rows=3 cols=40Get Firefox!/a




 --
 a href=http://www.spreadfirefox.com/?
 q=affiliatesid=153516t=1textarea
 rows=3 cols=40Get Firefox!/a





--
a href=http://www.spreadfirefox.com/? 
q=affiliatesid=153516t=1textarea

rows=3 cols=40Get Firefox!/a


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


Re: [Haskell-cafe] Installing HOpenGL

2007-06-24 Thread Thomas Schilling


On 25 jun 2007, at 00.18, Jimmy Miller wrote:

I've installed ghc 6.6.1, but when I try to compile and OGL program  
like this:


ghc -package GLUT ogl.hs

I get the error:
Failed to load interface for `GLUT':
 Use -v to see a list of the files searched for.

I tried running -v, but it doesn't tell me anything useful.


Can you post the output of ghc-pkg list?  If that doesn't list  
GLUT, then it is not installed (or not correctly).  If it is  
installed, you can try


  ghc --make ogl.hs

That usually takes care of all the required packages (so can avoid a  
lot of fiddling around).


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


Re: [Haskell-cafe] Installing HOpenGL

2007-06-24 Thread Thomas Schilling

I found the examples included in the source code very helpful.

  http://darcs.haskell.org/packages/GLUT/examples/

I think the RedBook directory contains the most examples.

If you want to know the modules a package exports you can use, e.g..

$ ghc-pkg describe OpenGL
name: OpenGL
version: 2.2.1
license: BSD3
copyright:
maintainer: [EMAIL PROTECTED]
stability:
homepage:
package-url:
description:
category:
author:
exposed: True
exposed-modules: Graphics.Rendering.OpenGL.GL.Antialiasing
 Graphics.Rendering.OpenGL.GL.BasicTypes
 [...]

These are the full names of the modules, you have to use to import  
them.  For GLUT there's one module that re-exports all others, iirc.


/ Thomas

On 25 jun 2007, at 01.21, Jimmy Miller wrote:


I got the packages imported by using the full names (Graphics.UI.GLUT
and Graphics.Rendering.OpenGL.GL).  The compiler doesn't recognize
names like WindowPosition and WindowSize, but I assume that's because
the code is so out of date (this is from the 2001 tutorial).  I'll
look in the docs to see how to procede.

On 6/24/07, Jimmy Miller [EMAIL PROTECTED] wrote:

Here it is.  Both OpenGL and GLUT are installed:
Cabal-1.1.6.2, GLUT-2.1.1, HUnit-1.1.1, OpenGL-2.2.1,
QuickCheck-1.0.1, Win32-2.1.1, base-2.1.1, cgi-3001.1.1,  
fgl-5.4.1,

filepath-1.0, (ghc-6.6.1), haskell-src-1.0.1, haskell98-1.0,
html-1.0.1, mtl-1.0.1, network-2.0.1, parsec-2.0, regex- 
base-0.72,

regex-compat-0.71, regex-posix-0.71, rts-1.0, stm-2.0,
template-haskell-2.1, time-1.1.1, xhtml-3000.0.2

I tried using --make, but ghc said could not find module GL

On 6/24/07, Thomas Schilling [EMAIL PROTECTED] wrote:

 On 25 jun 2007, at 00.18, Jimmy Miller wrote:

  I've installed ghc 6.6.1, but when I try to compile and OGL  
program

  like this:
 
  ghc -package GLUT ogl.hs
 
  I get the error:
  Failed to load interface for `GLUT':
   Use -v to see a list of the files searched for.
 
  I tried running -v, but it doesn't tell me anything useful.

 Can you post the output of ghc-pkg list?  If that doesn't list
 GLUT, then it is not installed (or not correctly).  If it is
 installed, you can try

ghc --make ogl.hs

 That usually takes care of all the required packages (so can  
avoid a

 lot of fiddling around).

 / Thomas



--
a href=http://www.spreadfirefox.com/? 
q=affiliatesid=153516t=1textarea

rows=3 cols=40Get Firefox!/a




--
a href=http://www.spreadfirefox.com/? 
q=affiliatesid=153516t=1textarea

rows=3 cols=40Get Firefox!/a


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


Re: [Haskell-cafe] Lambdabot

2007-06-23 Thread Thomas Schilling


On 22 jun 2007, at 22.17, Derek Elkins wrote:

[blah blah blah]


A less (potentially) offensive way of formulating this is:

  [...]

or

  -snip-

(You know, we don't want to accidentally piss of any newcomers.  So  
just saying .. :)


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


Re: [Haskell-cafe] Building Yi (and wider Cabal stuff)

2007-06-19 Thread Thomas Schilling


On 18 jun 2007, at 18.31, Jaap Weel wrote:

If you want to install into a nonstandard directory, do

runhaskell Setup.hs configure --prefix /bla/di/bla


Are you sure this works?  I think it is important that there be no  
whitespace between flag and parameter:



runhaskell Setup.hs configure --prefix=/bla/di/bla


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


Re: [Haskell-cafe] To yi or not to yi, is this really the question? A plea for a cooperative, ubiquitous, distributed integrated development system.

2007-06-19 Thread Thomas Schilling


On 18 jun 2007, at 16.01, Pasqualino 'Titto' Assini wrote:

Having just presented a case for the possible rationality of the  
irrational
decision of creating an Emacs-like IDE in Haskell, I wonder if we  
should not
be even more irrational and contemplate the possibility of using  
Haskell to

create a radically different kind of IDE.


I agree, that just duplicating Emacs in Haskell is a rather useless  
endeavor.  If you want any chance of building up sufficient momentum  
to be superseded by a good-enough emacs module you have to provide  
killer-features that are hard to do in emacs.


Here are some ideas I've been collecting over the years.

* Structural (optionally Type-Directed) Editing

Structural editing means that your code is always (mostly)  
syntactically correct, and in case of haskell maybe also type- 
checked.  This also implies that edit operations have syntactic  
awareness.  paredit[1] emulates this quite nicely for lisp, Proxima  
does something like this in Haskell for Haskell and XML-based  
languages.  This also needs some way of incremental parsing, for  
which good techniques already exist[3].



* Choose a more flexible editor model

Emacs (and probably Vi too) has a really old-fashioned editor model.   
It represents the complete file as a flat array (gap-buffer) of  
characters.  The Dylan-editor Deuce[2] wisely chose to use  
polymorphic lines, which requires greater storage overhead but is far  
more flexible.  It allows for easy embedding of different fonts,  
graphical and interactive objects, folding, and automatically  
generated objects (like callers, callees, etc.)



* Micro-versioned documents

With a little care, you can support lightweight, because incremental,  
tools and you get undo for free.  (You don't need redo, since that's  
just undoing an undo.)  This also should be pretty functional.   
Coupling this with an easy-to-use version-control goes without saying.



* No hardcoded editing model

Support Emacs-, Vim- or Mac/Windows-style usage.  This is important  
for adoption.



* Don't optimize for a console-based interface

And there so many more things to do, but I think if you have these  
much just falls off naturally.  Yi is still young, so it's not too  
late to get on the right track :)


I intend to help, as soon as I can find some time for this.


[1] .. http://www.emacswiki.org/cgi-bin/wiki/ParEdit

[2] .. http://wiki.opendylan.org/wiki/view.dsp? 
title=AppleDylanScreenshots


  The Deuce source code is available online as part of the  
functional developer source code:
  http://www.opendylan.org/cgi-bin/viewcvs.cgi/trunk/fundev/sources/ 
deuce/


[3] .. http://harmonia.cs.berkeley.edu/papers/twagner-parsing.pdf


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


Re: [Haskell-cafe] Sneaking haskell in the workplace -- cleaning csv files

2007-06-15 Thread Thomas Schilling


On 15 jun 2007, at 18.13, Jim Burton wrote:



import qualified Data.ByteString.Char8 as B



Have you tried

import qualified Data.ByteString.Lazy.Char8 as B

?



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


Re: [Haskell-cafe] Sneaking haskell in the workplace -- cleaning csv files

2007-06-15 Thread Thomas Schilling


On 15 jun 2007, at 21.14, Jim Burton wrote:


Thomas Schilling wrote:

On 15 jun 2007, at 18.13, Jim Burton wrote:

import qualified Data.ByteString.Char8 as B


Have you tried
import qualified Data.ByteString.Lazy.Char8 as B
?



No -- I'll give it a try and compare them. Is laziness preferable  
here?


yes, since you were talking of big files.  if you don't have to keep  
the data around lazy bytestrings will keep the memory footprint low.


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


Re: [Haskell-cafe] IDE?

2007-06-15 Thread Thomas Schilling
Yes this is kind of sad.  FWIW, here's how I currently approximate  
these features using Emacs + Haskell mode:


On 15 jun 2007, at 23.38, [EMAIL PROTECTED] wrote:

I've searched the internet for an Haskell IDE that supports the  
following:


- syntax highlighting


haskell mode


- cross module refactoring


there is HaRe, haven't tried it.

changing a function's type and then recompiling gives you a pretty  
useful todo-list though.  :)



- quick navigation (goto symbol,


if you run hasktags you can use M-.


goto instance,


not sure, maybe one could cook something up using grep or even hasktags


find usages, etc)


M-x grep RET downarrow RET



- code completion


either you use shim or the built-in M-/, which completes everything  
(not semantically sensitive, though)



- debugging (not imperative debugging, so no breakpoints, but just
plugging in a visualizer/pretty printer for a function in a separate
dedicated window, like what http://www.apple.com/shake does on each  
node)


i don't know shake, can you explain a bit more?

ghc HEAD has the ghci debugger, haven't tried it



So a bit what Jetbrains Resharper does for Visual Studio, but for  
Haskell.

IntelliJ and Eclipse also do this for Java.

This does not seem to exist? If this is correct, this is a real shame,
because although I read that the productivity increases a lot when  
correctly
using Haskell, it would increase even more when such an IDE is  
available.


i agree

/ Thomas


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


Re: [Haskell-cafe] Just curios

2007-06-11 Thread Thomas Schilling

On 6/11/07, Andrew Coppin [EMAIL PROTECTED] wrote:

  Of course, our biggest mistake was using the word 'monad'. We should
have called it 'warm fuzzy thing'...


You know that thing called Google? ;)

 http://lambda-the-ultimate.org/node/92

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


Re: [Haskell-cafe] equations and patterns

2007-05-31 Thread Thomas Schilling

On 5/31/07, Stefan Holdermans [EMAIL PROTECTED] wrote:

Dan,

 If you want to enforce associativity just create your own Eq
 instance and
 make it a pattern there.

Could you elaborate on that? It's still early here and I've had only
one cup of of coffee yet.

Cheers,

   Stefan


QuickCheck allows you to approximately verify properties by testing
them on randomly generated input.  The stated properties thus cannot
formally be proved, but they act as a pretty good formal
specification.  (Full automatic theorem proving for a language as
expressive as Haskell is impossible or infeasible. So we have to
approximate.)

prop_assocJoin x y z = join x (join y z) == join (join x y) z

-- or, more generally

associative :: (Eq a) = (a - a - a) - a - a - a - Bool
associative f x y z = f x (f y z) == f (f x y) z

prop_assocJoin = associative join

-- to check this for a given implementation of join, you need to:

import Test.QuickCheck

Main quickCheck  prop_assocJoin

This also requires that QC can generate arbitrary values of type e.
See the QuickCheck documentation for more infos on that:

http://www.cs.chalmers.se/~rjmh/QuickCheck/manual.html

/ Thomas
--
Remember! Everytime you say 'Web 2.0' God kills a startup! -
userfriendly.org, Jul 31, 2006
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] updating packages

2007-05-31 Thread Thomas Schilling

Have you tried cabal-install?  It may or may not work.  (It should
have come with Cabal.)

On 5/31/07, jeff p [EMAIL PROTECTED] wrote:

Hello,

  I just moved to ghc-6.6.1and was wondering if there is an automatic
way to update the various packages I had installed previously.

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




--
Remember! Everytime you say 'Web 2.0' God kills a startup! -
userfriendly.org, Jul 31, 2006
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] enumFrom* strangeness on GHC?

2007-05-31 Thread Thomas Schilling

On 5/31/07, Felipe Almeida Lessa [EMAIL PROTECTED] wrote:

BTW, how do you usually proceed when finding out why your code said
Segmentation fault.?  (should this question move to a new thread?)


$ gdb my_crashing_program
[wait till crush]
[on the gdb command line:]
$ bt
[prints backtrace]

If you're lucky, this helps a little. ;)
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Has anyone looked into adding subtyping to Haskell?

2007-05-31 Thread Thomas Schilling

I bring this up because I have been working on a Scheme compiler in
Haskell for fun, and something like polymorphic variants would be quite
convinent to allow you to specify versions of the AST (input ast, after
closure conversion, after CPS transform, etc.), but allow you to write
functions that work generically over all the ASTs (getting the free
vars, pretty printing, etc.).


Proper subtyping or at least extendable ADTs would be nicer, but you
can have type-checked progress flags using phantom types, e.g.:

data LT flag = L String (LT flag) | A (LT flag) (LT flag) | Var String

data Input
data Renamed
data CPSed
data ConstPropd

rename :: LT Input - LT Renamed
cps :: LT Renamed - LT CPSed
constantPropagate :: LT CPSed - LT ConstPropd

dumpExpr :: (forall a. LT a) - String   -- ignores progress flag

This way you have at least a way to check that the proper phases have
been run before.

It might even be possible to store different things in the nodes (not
tested), like in:

newtype Ident = MkIdent String

class VarType flag vt | flag - vt
instance VarType Input String
instance VarType Renamed Ident
instance VarType CPSed Ident
instance VarType ConstPropd Ident

data LT flag = (VarType flag vt = L vt (LT flag)) | ...

(This probably doesn't work, but you get the idea.)

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


Re: [Haskell-cafe] OpenGL

2007-05-30 Thread Thomas Schilling

See the examples/RedBook directory in the source code.  It gives you a
good idea how the C-idioms are translated.

For an actual documentation on OpenGL you'll better take a look at
general OpenGL literature and translate them into Haskell.  Note that
it's quite complex, though.

On 5/31/07, Jon Harrop [EMAIL PROTECTED] wrote:


I've found HOpenGL and the Debian package libghc6-opengl-dev. The former seems
to be very out of date (last release 2003) but I can't find any demos for the
latter.

Where should I go to get started with OpenGL and Haskell?

--
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
OCaml for Scientists
http://www.ffconsultancy.com/products/ocaml_for_scientists/?e
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe




--
Remember! Everytime you say 'Web 2.0' God kills a startup! -
userfriendly.org, Jul 31, 2006
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Curiose types

2007-05-27 Thread Thomas Schilling

On 5/27/07, Andrew Coppin [EMAIL PROTECTED] wrote:

  map :: (a - b) - [a] - [b]
  map :: (a - b) - ([a] - [b])

Which is beautifully symmetric. Alternatively, you can think about how
you actually use it:

  map :: ((a - b) - [a]) - [b]


No, now you're confusing things.  The uncurried function looks like this:

uncurry map :: (a - b, [a]) - [b]

Note that map :: (  ) - [b]  only takes one argument, not two

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


[Haskell-cafe] Network.HTTP+ByteStrings Interface--Or: How to shepherd handles and go with the flow at the same time?

2007-05-23 Thread Thomas Schilling

Hello Cafe!

I'd greatly appreciate any ideas/comments on the design of the
interface to the Network.HTTP library with a LazyByteString (LBS)
backend.

As has been discussed previously on this list [1] lazy evaluation can
complicate resource management, which is especially critical if
resources are seriously limited--in this case network sockets and/or
file handles.

In [2] Oleg shows how we can use left folds as a general mechanism to
traverse collections and shows that this is superior to cursors,
generators or streams.  I agree with his arguments, however, I still
don't see that this can be a good interface for the http library.

For a start, what should the collection type be?  Word8, Char8,
(strict) ByteString (BS)?  Unless we get some kind of fusion for the
first two we're pretty much stuck with the latter.  The interface
could look like this (untested):

import Data.ByteString (ByteString)  -- i.e., strict BSs
import qualified Data.ByteString as BS

handleRequest :: MonadIO m = Request - a - (ByteString - a - m
(Either a a)) - m a

Ignoring error handling for now, this might be implemented as:

handleRequest req seed processor = do
   a - iter seed bodySize
   closeConnection req
   return a
 where
   iter seed 0 = return seed
   iter seed n = do
   let c = min chunkSize n
   bs - liftIO $ readBlock req c  -- calls BS.hGet handle c
   next - processor bs seed
   case next of
 Left rslt - return rslt
 Right seed' - iter seed' (n-c)
   -- insert catchError stuff here (requires signature change, of course)

This should work fine and if the 'processor' function does not hold on
to the chunk would run in constant space.  Unfortunately, this has a
big disadvantage.  Most operations on the returned data will probably
be stream-like functions, such as parsing the data into some kind of
tree.  [2] shows a method how to convert enumerators to streams, but
the used stream type

data MyStream m a = MyNil (Maybe a) | MyCons a (m (MyStream m a))

is incompatible with [a] which is used by lazy ByteStrings due to the
embedding of m.  I also don't know if fusion can work on monads.  My
current suggestion would therefore be a less save[*] solution
(again, untested and modulo error handling).

-- | Execute the request and call @f@ with the returned response body.
-- The socket will be closed immediately after @f@ terminates.  You
must therefore
-- make sure that any data you might want to returned has to be
forced, e.g. using
-- (length . take) lbs
withRequest :: MonadIO = Request - a - (LazyByteString - a - m a) - m a

The implementation would lazily read the contents (implemented as
described in [3]) and forcing it would be left to the function
parameter.  E.g.

getHTML :: String - IO HTMLParseTree
getHTML addr = do
   r - mkRequest addr
   tree - withRequest r emptyTree parseHTML
   seq tree $ return tree  -- ! (I'm afraid this is necessary)

tricky :: LazyByteString - String - IO LazyByteString  -- result
will not really be lazy
trickyt str addr = do
   r - mkRequest addr
   withRequest r L.empty dropNTake
   -- we might have to force the result here
 where
   dropNTake s _ = L.take 10 . L.drop 10

If these 'seq's are really necessary, then this would be a pretty hard
to use interface.

So, any ideas / suggestions ?

/ Thomas


[*] .. save in the sense that it does not enforce certain behavior
by means of the type signature or API design.

[1] .. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/20528/focus=20635
[2] .. http://okmij.org/ftp/papers/LL3-collections-enumerators.txt
[3] .. http://nominolo.blogspot.com/2007/05/networkhttp-bytestrings.html

--
Remember! Everytime you say 'Web 2.0' God kills a startup! -
userfriendly.org, Jul 31, 2006
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Network.HTTP+ByteStrings Interface--Or: How to shepherd handles and go with the flow at the same time?

2007-05-23 Thread Thomas Schilling

On 5/24/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:


Why do you need to convert Socket to Handle?


Initially, we chose to use socketToHandle for simplicity reasons--why
duplicate functionality if we can reuse it?  After Simon Marlow's
comment that my reason to assume it inappropriate does no longer hold,
we decided to just keep it that way.  I'm not completely sure, but I
think that handle created from the socket will not use up any of the
file handles, or if it does then it's the socket behind it, but in any
case it doesn't change anything w.r.t. to the total available number
of resource handles.

If it turns out that we should in fact add functions to work directly
on sockets then it would be mostly straightforward translation of
hGet, hGetNonBlocking and hGetContents.  But that's not an issue, ATM.


If this hypothetical 'socketGetContentsAsLazyByteString' also creating a
newEmptyMVar then it could return a (tryPutMVar m ()) action to allow the
consumer of the lazy string to signal to the deferred reading process (which
periodically calls (isEmptyMVar m)) that it should close the socket or at least
stop trying to read from it.  That way there is no _need_ to 'seq' your way to
the end of the lazy bytestring to cause it to close.


Now here comes the actual problem, sorry if that wasn't clear from my
original post.  We actually don't want to rely on the consumer to
signal that it is done reading--this would be manual memory management
and this is unreliable.  Also, we can't be sure the string will ever
be consumed completely.  Another unsatisfactory solution is to attach
a finalizer which is executed when the garbage collector detects that
the object is not live anymore, which is not guaranteed at all.

These are precisely the reasons why Oleg proposed the fold-based
method.  Unfortunately, this does not seem to work nicely in its
current form.

Since, I want to keep some form of laziness though, my trade-off is to
create a lazy zone in which we read data on demand, but if someone
needs to hold on to it longer he has to gather the data explicitly,
which, as showed, might be tricky to use, thus undesirable (especially
for a library).

/ Thomas

--
Remember! Everytime you say 'Web 2.0' God kills a startup! -
userfriendly.org, Jul 31, 2006
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Editor

2007-05-21 Thread Thomas Schilling

Your rant accomplishes nothing.  Just note that programmers can
generally be considered more open towards harder-to-learn but
eventually more efficient to use interfaces.  Yes, to a large part
they lack visibility, consistency, integration, or other such
properties; then again, once you learn to use them you're so much more
efficient than before.  And you loose the incentive to improve things.

So instead of insulting people and complaining that nothing fits your
needs you have at least two options:

1. Implement it.  Of course, this is a _major_ effort and many many
things are completely unsolved research issues.

2. Take what's there, learn to use it.  Yes, it will lack so many
things but one way or another you'll eventually get things done.

On 5/21/07, Michael T. Richter [EMAIL PROTECTED] wrote:


 On Mon, 2007-21-05 at 13:04 +0100, Rodrigo Queiro wrote:

 My friend read your email and remarked:
 How is this guy not embarrassed posting on the internet about not liking vim 
because he doesn't like editing config files?

 Because, unlike your friend, I actually have seen the advances in HID over the past 
30 years.  Editing text files is not the be-all/end-all of user interfaces.  Indeed 
there is astonishingly high volumes of evidence showing that it's a pretty miserable 
user interface -- a misery amplified by the fact that every two-bit program has its 
own entirely unique syntax (usually broken in many exciting ways!) full of cryptic 
commands and settings.  Don't believe it?  Go to your home directory and compare all 
the .files you find.  You really think it's a good thing to maintain each of 
those manually?

 Oh, and of course it wasn't just the config files I showed problems with, now, 
was it?  I seem to remember something about modality and bad syntax 
highlighting.  Maybe I was tripping.  It happens.

 For your friend's reference, here's a good outline of what principles underlie 
HID: http://www.asktog.com/basics/firstPrinciples.html.  For even more modern 
outlooks, I'm sure a quick search at Amazon.com (or his bookseller of choice) 
can give him other ideas.

 So am I embarrassed for asking for something resembling a 21st-century user 
interface instead of a 1970s vintage one?  Not in the slightest.


  --
 Michael T. Richter [EMAIL PROTECTED] (GoogleTalk: [EMAIL PROTECTED])
 It's OK to figure out murder mysteries, but you shouldn't need to figure out 
code. You should be able to read it. (Steve McConnell)
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe







--
Remember! Everytime you say 'Web 2.0' God kills a startup! -
userfriendly.org, Jul 31, 2006
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Listing package dependencies from GHC

2007-05-03 Thread Thomas Schilling



If I'm doing development between ghci and vim, all the different
dependencies I need get linked in when required without me asking.
Similarly if I call ghc --make from the command line. But I have to
write them in manually to my *.cabal file otherwise the compilation
process will fail.

Until now I've just loaded the program in to ghci and noted down all
the dependencies it links in. Am I missing a trick? There must be an
easier way, especially for multiple source files.



I once used this perl script to determine the files I was actually  
used (to have proper LOC stats).  It uses ghc -M which usually  
outputs the dependencies as makefile targets, and then grep over this  
to get all the .hs files.  If you have different file types you might  
want to modify this:


#!/usr/bin/env perl

# Prints the .hs files that are actually used to STDOUT

$tmpfile = '/tmp/deps';
$mainfile = 'Foo.hs';
$ghc_deps = `ghc -M $mainfile -optdep-f -optdep$tmpfile`; die ghc -M  
failed\n if $? != 0;


open(INF,  $tmpfile) || die Could not open $tempfile\n;

@files = ();

while (INF) {
  m/(\w+\.hs)/;
  push(@files, $1);
}

close (INF);

undef %saw;
@nodups = grep(!$saw{$_}++, @files);  # remove duplictes

print join(' ',@nodups), \n;


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


Re: [Haskell-cafe] Listing package dependencies from GHC

2007-05-03 Thread Thomas Schilling

 By dependencies I
meant, library packages that GHC knows about.

For example, if I load something simple like


import System.Posix.Files
main = touchFile example


into GHCi and execute :main it prints


Loading package unix-1.0 ... linking ... done.




Oh, right.  Well, then please file it as a bug report on Cabal.  I'll  
be working on Cabal configs as my Summer of Code project; this is  
clearly related.  With a bit of luck it'll be done before end of August.


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


Re: [Haskell-cafe] Listing package dependencies from GHC

2007-05-03 Thread Thomas Schilling


On 3 maj 2007, at 17.53, Duncan Coutts wrote:

This is not a Cabal bug. By design, Cabal does not just pick up any
packages from the environment like --make does. One of the main points
of Cabal is to be able to explicitly track dependencies of a  
package, so

we do require that they all be listed explicitly. Cabal then tells ghc
to *only* look in those listed packages and ignore all others even if
they happen to be installed.

Now certainly it would be nicer if ghc+cabal could be more helpful and
tell you all the missing packages that you need to list in the
build-depends field in the .cabal file, rather than currently where
you have to do it one by one.


In fact I was thinking of something more than this.  When I said  
file a bug I didn't intend to describe it as a bug but as a  
feature, which are also managed by the bug tracker.  Also, I agree  
that dependencies should be listed explicitly; it might be very  
useful to let Cabal generate you a template with some sane  
suggestions, though.


/ Thomas

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


[Haskell-cafe] Re: Type-level programming problem

2007-05-01 Thread Thomas Schilling


On 1 maj 2007, at 06.12, [EMAIL PROTECTED] wrote:


We see it is a value polymorphic over four type variables: ns, a, b,
and c. The type variable 'a' is also the type of the value, so we have
a way to instantiate it. There is no direct way to instantiate the
remaining three. If there were a functional dependency a - ns, a-b,
a-c, we could have instantiated the remaining variables. But there
are no such dependencies. So, there is really no way we can
ever instantiate the type variables ns, b and c -- and so the  
typechecker

will complain.

So, we need either a functional dependency a - ns in the definition
of Foo, or defaultA should have a signature defaultA :: ns - a
(and ditto for other defaults).


In fact I had this signature for a while, but then I had already  
changed the definition of Foo to a different signature.  Good to know  
that I wasn't too far off..



As I understand, the function
'defaultA' can be present in different components, identified by
ns. When we write 'defaultA' however, how can we say that we mean
defaultA of component X rather than of component Y? There isn't any
way to name the desired component...

Incidentally, if we represent components by records
data XRec = XRec { defaultA :: XA }
then the type of defaultA is Xref - XA. It is the function from the
type of the `namespace'. This seems to suggest the
signature of defaultA should be ns - a ...

BTW, there are other ways to add the name of the namespace to the
signature of defaultA. For example:
newtype TaggedT ns a = TaggedT a
class Foo ns a b c | ...
 defaultA :: TaggedT ns a
or
class Foo ns a b c | ...
 defaultA :: ns a

etc.


Thank you for your quick and helpful response.  I'll look into what  
works best for my purposes.


Thanks,

/ Thomas

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


[Haskell-cafe] Type-level programming problem

2007-04-30 Thread Thomas Schilling

Hi,

I have a type class similar to this one.

data T
class Foo ns a b c | ns - a, ns - b, ns - c where
mkFoo :: ns
defaultA :: a
defaultB :: c - IO b
defaultC :: [T] - c
f :: c - b - a - (b, Int)

The idea is, that I define classes of components where the data types  
of the methods are component-specific.  I therefore use a namespace  
to define the component types (associated types would be nicer, but  
are not widely supported).


Given a few sample instances, I can define a configuration:

data X;  data XA = XA;  data XB = XB;  data XC = XC

instance Foo X XA XB XC where
mkFoo = undefined
defaultA= XA
defaultB XC = return XB
defaultC _  = XC
f _ b _ = (b,0)
mkX = mkFoo :: X

data Y;  data YA = YA;  data YB = YB;  data YC = YC

instance Foo Y YA YB YC where
mkFoo = undefined
defaultA= YA
defaultB YC = return YB
defaultC _  = YC
f _ b _ = (b,1)
mkY = mkFoo :: Y


config = mkX .*. mkY .*. HNil

Using this configuration, I now want to define various functions that  
work on As, Bs or Cs, respectively.  For example, I'd like to have


a :: XA :*: XB :*: HNil
a = hMap DefaultA config

but I fail to figure out how to define DefaultA.  I tried with this one:

data DefaultA
instance Foo ns a b c = Apply DefaultA ns a where
apply _ _ = defaultA

but I get:

Could not deduce (Foo ns1 a b1 c1)
  from the context (Apply MakeAs ns a, Foo ns a b c)
  arising from use of `defaultA'
  at /Users/nominolo/Devel/Haskell/testcase1.hs:126:16-23
Possible fix:
  add (Foo ns1 a b1 c1) to the class or instance method `apply'
In the expression: defaultA
In the definition of `apply': apply _ _ = defaultA
In the definition for method `apply'

I guess I need some type class that also binds b and c.  Or maybe I  
need to do some things completely different at all.  Ideally, I'd  
hope to keep the work for adding new Foo instances as low as  
possible, though.


I attached the relevant parts of the HList implementation and the code.

Any suggestions?

/Thomas



testcase1.hs
Description: Binary data
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] QuickCheck testing of AST transformers

2007-04-23 Thread Thomas Schilling
Additionally, as a safety net, you might want to type-check the code  
that's being produced by your Arbitrary instances and state some  
invariants on your code.  Also, you'll likely want to limit your  
number of evaluation steps if your language allows non-terminating  
programs.


In any case, QuickCheck may not get you far enough to gain enough  
confidence, so proving properties by hand (after you made sure that  
QuickCheck doesn't find any counter-examples, of course) can give you  
interesting insights, since, this way, you have to take a look at all  
the possible cases yourself.


/Thomas


On 24 apr 2007, at 00.05, Lennart Augustsson wrote:

Without looking into your language and transformation in more  
detail it's hard to come up with concrete suggestions.  But here  
are some anyway:


Write an interpreter for each of your languages (original AST,  
transformed AST) etc, and then use a quickcheck property stating  
that well formed programs have the same denotation before and after  
transformation, i.e., the two interpreters give the same value  
(you might need some relaxed notion of same).


You transformations are trying to get rid of some language  
construct, I presume.  So you can have some properties stating that  
they will be gone in the transformed program..


-- Lennart


On Apr 23, 2007, at 22:46 , Joel Reymont wrote:

My previous post did not receive any replies so I thought I might  
try generalizing the problem a bit...


Suppose I'm parsing a language into a syntax tree and then  
transforming that tree into another AST representing a core  
language. The core language is a more general AST that should  
help with compiling to other languages.


My problem is how to best structure my AST transformations to be  
able to test them with QuickCheck. I suspect that I'm not going  
about it in the most optimal way so I thought I should ask for  
suggestions.


The transformation into the core AST applies operations to  
simplify, or desugar, the AST of the original language. Here's  
sample code in the source language which, incidentally, was  
recently highlighted at Lambda the Ultimate [1].


Array: MyArray[10](10 + 2);
Value1 = MyArray[5][10];

This declares an array of 10 elements and initializes each element  
to 12. Value1 (a built-in variable) is then initialized to the  
value of element #5 as of 10 bars ago. A bar is, basically, a  
stock quote. The code is invoked on every bar and so 5 bars ago  
can be treated as 5 invocations ago.


The syntax tree of the above code is a 1-1 mapping. We declare an  
array of integers of 10 elements. Initialize it to the sum of two  
integers and then assign to Value1.


[ ArrayDecs [ VarDecl (VarIdent MyArray) TyInt [Int 10]
  (Op Plus (Int 10) (Int 2)) ]
, Assign (VarIdent Value1) [] (Var (VarIdent MyArray) [Int 5]
 (BarsBack (Int 10))) ]

The desugared version does away with the array declaration  
statement and declares MyArray to be a variable of array type.  
Arrays in the core language do not remember values from one  
invocation to another but there's a data series type, so we  
declare a series variable to hold the value of element #5.


We must manually store the value of the array element in the data  
series and can then refer to the value of the series 10 data  
points ago.


vars = [ (MyArray, VarDecl (TyArray TyInt) [Int 10]
   (Just (Plus (Int 10) (Int 2
   , (series0, VarDecl (TySeries TyInt) [] Nothing)
   ]

code = [ AddToSeries (VarIdent series0) (Var (VarIdent  
MyArray) [Int 5])

   , Assign (Var (VarIdent Value1) [])
(Series (VarIdent series0) (Int 10))
   ]

The next step would be to take the above core syntax tree and  
transform it yet again into a C# (or other target language) AST.  
It's assumed that all target languages have a data series type.


The OCaml version of my code translated directly into the C# AST  
but I figured an intermediate syntax tree will help me translate  
into other languages such as Haskell, Erlang or OCaml.


The part I can't figure out is how to come up with a set of  
invariants for my transformations.


Should I, for example, state that every access to an array value  
in a previous invocation should introduce an extra variable to  
hold the series plus the appropriate assignment code?


Should I write the translator as a series of small transformers in  
the ST monad that can be threaded and tested separately?


Thanks in advance, Joel

[1] http://lambda-the-ultimate.org/node/2201

--
http://wagerlabs.com/





___
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



<    1   2   3