Re: [Haskell-cafe] Multiple stages in Template Haskell

2006-10-11 Thread Ch. A. Herrmann

Hi,

because Template Haskell is a compile-time metaprogramming language, 
there is no metaprogram
left after the first stage. Thus, it does not make sense, conceptually, 
to have more than one stage.
In contrast, in MetaOCaml, you can generate code at run time that 
generates code at run time that ...


In Template Haskell, you have the possibility of a sequence of files 
where file n+1 makes use
of the templates defined in file n; and maybe sometime this will be 
simplified such that you can

have all definitions in one file. Anyway, you do not need multiple stages.

Concerning the stage count, perhaps you just forgot to insert a 
quasi-quote at some place, e.g., at:


$ [| zipN ...

--
Christoph

Lyle Kopnicky wrote:


Hi folks,

I noticed that in Template Haskell, you can only have one level of 
splicing or quasi-quoting. E.g., you can't write:


   $(zipN ($(sel 2 3) (zip level,3,( ['a'..'Z'] [1..] (words 
now is the time)


Because you can't have a splice inside a splice. But wouldn't it be 
handy to use all these macros when defining other macros?


This would be like stages in MetaML, which have no such limitation. 
But all the stages but the last one would be evaluated at compile 
time. The compiler would look for the deepest level of nested splices 
and evaluate it first.


On the other hand, I can understand why you wouldn't include splices 
and quasi-quotes in the Language.Haskell.TH.Syntax - programmers could 
write functions that dynamically created arbitrarily (even infinitely) 
nested splices - so it would be undecidable where to start.


I'm wondering if there's some reason this restriction is imposed. Is 
it particularly difficult to implement, or are there more theoretical 
problems? Does that mean I'm volunteering? ;)


- Lyle

___
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: Is Haskell a 5GL?

2006-10-05 Thread Ch. A. Herrmann

Hi,

Henning Thielemann wrote:


...

The notation
  [f x | x - xs]
describes operations on list elements, and looks like the imperative
 forall x in xs do f x,
whereas
 map f xs
is a list transformation. The second one is more abstract, isn't it?
 


for that simple example yes, but what's about list comprehensions like:

sequence of parsers:
(p + q) r = [ (f (x,y), r2) | (x, r1) - p r, (y, r2) - q r1 ]

or triples:
[ (x,y,z) | x-[1..n], let x2=x*x, y-[1..x], let y2=y*y, let z=isq 
(x2,y2), x2+y2==z*z ]


or database queries:
[ (name,salary) | ((_,name),dateofbirth,((Just salary))) - table, 
dateofbirth1980  salary10 ]


I just typed these examples but did not check them.

There are many other examples like n queens, functions on shaped 
matrices etc.


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


Re: [Haskell-cafe] Re: Is Haskell a 5GL?

2006-09-27 Thread Ch. A. Herrmann

Hi,

an experienced person at our lab told me that the classification
into generations has become unfashioned in the last decade;
thus I think I will stay away from using it but argue with
concrete abstraction features.

Concerning the point someone made about the features of Haskell:
* pattern matching: just case distinction
* list comprehensions: syntactic sugar
These are indeed local syntactic issues but the amount of such small things
is essential to make things easy, in addition to semantic issues like 
laziness.

Assume that you do not have them: then your programs would look
as verbose as Java or LISP programs.

If someone asks me for the generation level of Haskell, I will say 5,
because there are only a few small functions you have to add
to implement a small theorem prover; provocatively speaking:
if these were in the prelude than Haskell was an artificial intelligence
language. But perhaps such marketing statements are not convincing any more.
--
Christoph
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Is Haskell a 5GL?

2006-09-25 Thread Ch. A. Herrmann

Hi,


   and/or visual programming (Visual Basic,...)


I can only assume you are a) joking


a bit, yes


, or b) not a visual basic user.


also true


While Visual Basic is a much insulted language, I have a soft spot for
it. However, its not a Visual programming language - its a language
which happens to have a GUI API and a bit of IDE support. Its
resolutely a 3GL, roughly akin to Java, in my opinion.


I'd agree but I found the info in the web


The question is: how strong is the influence of laziness in everyday
Haskell programming?


I'd say very strong, lots of times a where is used thats making use
of laziness.


I don't agree: where is often only used to program in a top-down style

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


Re: [Haskell-cafe] Is Haskell a 5GL?

2006-09-25 Thread Ch. A. Herrmann

Hi,

Henning Thielemann wrote:


assembly language (Assembler ist deutsch :-)


for mysterious reasons it entered the English world.


3GLs: programming based on algorithms (C, Java, ...)
4GSs: domain-specific languages (SQL,...)
5GLs: automatic problem solving (Mathematica, Prolog,...)
 and/or visual programming (Visual Basic,...)
   



Visual Basic and Computer Algebra Systems in the same generation?
 


Ok, let Visual Basic be a 3GL.


Haskell's laziness would in principle permit programming in a style
akin to Prolog, e.g., for parser combinators.
The question is: how strong is the influence of laziness in everyday
Haskell programming?
   



Actually, laziness allows me to formulate algorithms that look more like
the specification of the problem than the solution.


That would be a 4GL.


E.g., I can formulate
the solution of a differential equation in terms of a power series or time
series in that way. However I have to put some effort into formulating it
in a way that works.


That's kind of developing an algorithm.
--
Christoph


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


[Haskell-cafe] CFP: PAPP 2006

2005-10-05 Thread Ch. A. Herrmann

-
Please accept our apologies if you have received multiple copies.
Please feel free to distribute it to those who might be interested.
-


--
  CALL FOR PAPERS

PAPP 2006
 Third International Workshop on
 Practical Aspects of High-level Parallel Programming
 http://graal.ens-lyon.fr/~abenoit/conf/papp2006.html

  part of

 ICCS 2006
  The International Conference on Computational Science
   May 28-31, 2006, University of Reading, UK  
--




AIMS AND SCOPE

Computational Science applications are more and more complex to
develop and require more and more computing power. Parallel and grid
computing are solutions to the increasing need for computing
power. High level languages offer a high degree of abstraction which
ease the development of complex systems. Moreover, being based on
formal semantics, it is possible to certify the correctness of
critical parts of the applications.

Algorithmic skeletons, parallel extensions of functional languages
such as Haskell and ML, parallel logic and constraint programming,
parallel execution of declarative programs such as SQL queries, etc.
have produced methods and tools that improve the price/performance
ratio of parallel software, and broaden the range of target
applications.

The PAPP workshop focuses on practical aspects of high-level parallel
programming: design, implementation and optimization of high-level
programming languages and tools (performance predictors working on
high-level parallel/grid source code, visualisations of abstract
behaviour, automatic hotspot detectors, high-level GRID resource
managers, compilers, automatic generators, etc.), applications in all
fields of computational science, benchmarks and experiments. Research
on high-level grid programming is particularly relevant.

The PAPP workshop is aimed both at researchers involved in the
development of high level approaches for parallel and grid computing
and computational science researchers who are potential users of these
languages and tools.


TOPICS

We welcome submission of original, unpublished papers in English on
topics including:

* high-level models (CGM, BSP, MPM, LogP, etc.) and tools for parallel
 and grid computing

* high-level parallel language design, implementation and
 optimisation

* functional, logic, constraint programming for parallel, distributed
 and grid computing systems

* algorithmic skeletons, patterns and high-level parallel libraries

* generative (e.g. template-based) programming with algorithmic
 skeletons, patterns and high-level parallel libraries

* applications in all fields of high-performance computing (using
 high-level tools)

* benchmarks and experiments using such languages and tools


PAPER SUBMISSION AND PUBLICATION

Prospective authors are invited to submit full papers in English
presenting original research. Submitted papers must be unpublished and
not submitted for publication elsewhere. Papers will go through a
rigorous reviewing process. Each paper will be reviewed by at least
three referees. The accepted papers will be published in the
Springer-Verlag Lecture Notes in Computer Science (LNCS) series, as
part of the ICCS proceedings.

Submission must be done through the ICCS website:
http://www.iccs-meeting.org/iccs2006/papers/upload.php
We invite you to submit a full paper of 8 pages formatted according to
the rules of LNCS, describing new and original results, no later than
December 2, 2005. Submission implies the willingness of at least one
of the authors to register and present the paper. An early email to
Anne.Benoit at ens-lyon.fr with your intention to submit a paper would
be greatly appreciated (especially if you have doubts about the
relevance of your paper).  


Accepted papers should be presented at the workshop and extended and
revised versions will be published in a special issue of Parallel and
Distributed Computing Practices, provided revisions suggested by the
referees are made.


IMPORTANT DATES

December 2, 2005 Full paper due
January 31, 2006 Referee reports and notification
February 10, 2006 Camera-ready paper due
May 2006 Journal version due
June 2006 Referee reports
July-October 2006 Revision of papers, final notification
November 2006 Final paper due


PROGRAM COMMITTEE

Marco Aldinucci (CNR/Univ. of Pisa, Italy)
Olav Beckmann (Imperial College London, UK)
Anne Benoit (ENS Lyon, France)
Alexandros Gerbessiotis (NJIT, USA)
Stephen Gilmore (Univ. of Edinburgh, UK)
Clemens Grelck (Univ. of Luebeck, Germany)
Christoph Herrmann (Univ. of Passau, Germany)
Zhenjiang Hu (Univ. of Tokyo, Japan)
Frédéric Loulergue (Univ. Orléans, France)
Casiano Rodriguez Leon (Univ. La Laguna, Spain)
Alexander Tiskin 

Template Haskell, [p|...|]

2003-07-03 Thread Ch. A. Herrmann
Hi,

trying to adapt the zipN-example in the paper
Template Meta-programming for Haskell by
Sheard and Peyton Jones to Language.Haskell.THSyntax
I found that quasi-quotation for patterns does not seem 
to work with ghci-6.0, e.g., the following results in 
Parse error in pattern:

   pcons x xs = [p| $x : $xs |]
  
Using a user defined data-type

   data List a = Nil | Cons a (List a)

the following works

   pcons x xs = Pcon Cons [x,xs]

but I don't want to use a new data type.
Trying to use the standard list representation by

   pcons x xs = Pcon (:) [x,xs]

I got the error message

   Data constructor not in scope: `(:)'
   tcLookupDataCon: `(:)' is not in scope

Does anyone know a workaround?
--
 Christoph
___
Glasgow-haskell-bugs mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


ghc-6.0 compiler bug

2003-06-06 Thread Ch. A. Herrmann
Hi,

playing around with partial evaluation, 
I encountered the following bug:

65 ghc --make -fglasgow-exts -package haskell-src Main.hs -o Main -ddump-splices
Chasing modules from: Main.hs
Compiling Power( Power.hs, ./Power.o )
Compiling Main ( Main.hs, ./Main.o )
ghc-6.0: panic! (the `impossible' happened, GHC version 6.0):
nameModule x {- v a1BE -}

Please report it as a compiler bug to [EMAIL PROTECTED],
or http://sourceforge.net/projects/ghc/.
--
module Power where

 import Language.Haskell.THSyntax

 pow :: ExpQ - Int - ExpQ
 pow x 0   = [| const 1 |]
 pow x n | n0 = [| $x * $(pow x (n-1)) |]
--
module Main where

 import Power (pow)

 main = let x = 2 :: Double
in putStrLn (show ($(pow [|x|] 5)))
--
Good luck
-- 
 Dr. Christoph Herrmann
 Teaching and Research Assistant 
 University of Passau, Germany 
 http://www.fmi.uni-passau.de/~herrmann
___
Glasgow-haskell-bugs mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


RE: ghc-6.0 compiler bug

2003-06-06 Thread Ch. A. Herrmann
Hi Simon

Simon Yes, this is a known bug,

Sorry that I'm not perfectly aware of everything going
on with Template Haskell.

Simon but thank you for reporting it
Simon anyway.  I'm going to fix it as part of my next sweep though.

Thank you very much. I'm happy to know that it is really possible
to apply the generated code to run-time values; taking the 
idea of the workaround:

 main = $([| do
  s - getLine
  let x = read s :: Double   
  putStrLn (show ($(pow [|x|] 5))) |])
-- 
 Dr. Christoph Herrmann
 Teaching and Research Assistant 
 University of Passau, Germany 
 http://www.fmi.uni-passau.de/~herrmann
___
Glasgow-haskell-bugs mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Deadline extended: EuroPar 2003, Topic 10

2003-02-11 Thread Ch. A. Herrmann
Apologies if you receive multiple copies of this message.
---

 **
 ******
 ***  LAST CALL FOR PAPERS  ***
 ***   Submission Deadline: February 16, 2003   ***
 ******
 ***   EURO-PAR 2003 Topic 10   ***
 *** Parallel Programming: Models, Methods and  *** 
 ***   Programming Languages***
 ******
 ***Klagenfurt, Austria ***
 *** August 26-29, 2003 ***
 ******
 *** http://europar-itec.uni-klu.ac.at/ ***
 ******
 **

Description
This topic provides a forum for the presentation of the latest research
results and practical experience in the development of parallel 
programs. Advances in algorithmic and programming models, design 
methods, languages, and interfaces are needed to produce correct, 
portable parallel software with predictable performance on different
parallel and distributed architectures.

The topic emphasises results that improve the process of developing 
high-performance programs, including high-integrity programs that are 
scalable with both problem size and complexity. Of particular interest
are novel techniques by which parallel software can be assembled from 
reusable parallel components without compromising efficiency. Related 
to this is the need for parallel software to adapt, both to available 
resources and to the problem being solved. 

Where appropriate, contributions should demonstrate quantitative 
performance results in support of their claims, and address 
applications not adequately handled by well-established approaches.

Focus
* Languages, libraries and interfaces for different parallel 
  programming models (e.g. data-parallelism, task-parallelism, 
  functional, object-oriented, logic, component-based etc.).
* Implementation and optimisation techniques for innovative 
  parallel languages and programming models (e.g. threads, 
  dataflow, tiling, skeletons, declarative languages, and 
  generalised data-parallel approaches, etc.).
* Performance models and their integration into the design of 
  efficient parallel algorithms and programs (e.g. BSP, LogP, CGM,
  N-half and their alternatives, cost calculi and static 
  performance prediction, profile-driven approaches).
* Parallel programming paradigms and tools, their comparison and 
  integration (e.g. data-parallel vs. task-parallel, coordination 
  programming, performance analysis and debugging).
* Methodological aspects of developing, optimizing and validating 
  parallel programs (formalisms, semantics, specification, design,
  transformations, verification, etc.).
* Software engineering for parallel and distributed systems 
  (design patterns, portability, robustness, standardization, 
  etc.).
* Systematic approaches and programming models to support 
  effective program development in grid environments.   
* Domain-specific parallel libraries and languages (e.g. for 
  simulation, irregular and unstructured meshes, computational 
  geometry, etc.).

---
 KEY DATES

  November 8, 2002  First call for papers
  February 9, 2003  Final date for submissions
  May 1, 2003   Notification of acceptance
  July 15, 2003 Early registration deadline

---
PC COMMITTEE

Global Chair

Prof. José  C. Cunha
New University of Lisbon, Portugal
Email: [EMAIL PROTECTED]   
 
Vice Chairs

Dr. Marco Danelutto
University of Pisa, Italy 
Email: [EMAIL PROTECTED]  

Prof. Peter H. Welch
University of Kent, United Kingdom 
Email: [EMAIL PROTECTED]  

Local Chair

Dr. Christoph Herrmann
Universität Passau, Germany
Email: [EMAIL PROTECTED]

---
 SUBMISSION DETAILS

Authors are requested to submit their papers by using our submission 
site http://europar-itec.uni-klu.ac.at/submission.html (please 
indicate TOPIC 10). The site will open not later than at the beginning
of January 2003. 
All accepted papers will be available at the conference in the 
proceedings published by Springer-Verlag in the LNCS series.

EuroPar 2003, Topic 10 (CfP)

2003-01-16 Thread Ch. A. Herrmann

Apologies if you receive multiple copies of this message.
---

 **
 ******
 ***SECOND CALL FOR PAPERS  ***
 ***   Submission Deadline: February 9, 2003***
 ******
 ***   EURO-PAR 2003 Topic 10   ***
 *** Parallel Programming: Models, Methods and  *** 
 ***   Programming Languages***
 ******
 ***Klagenfurt, Austria ***
 *** August 26-29, 2003 ***
 ******
 *** http://europar-itec.uni-klu.ac.at/ ***
 ******
 **

Description
This topic provides a forum for the presentation of the latest research
results and practical experience in the development of parallel 
programs. Advances in algorithmic and programming models, design 
methods, languages, and interfaces are needed to produce correct, 
portable parallel software with predictable performance on different
parallel and distributed architectures.

The topic emphasises results that improve the process of developing 
high-performance programs, including high-integrity programs that are 
scalable with both problem size and complexity. Of particular interest
are novel techniques by which parallel software can be assembled from 
reusable parallel components without compromising efficiency. Related 
to this is the need for parallel software to adapt, both to available 
resources and to the problem being solved. 

Where appropriate, contributions should demonstrate quantitative 
performance results in support of their claims, and address 
applications not adequately handled by well-established approaches.

Focus
* Languages, libraries and interfaces for different parallel 
  programming models (e.g. data-parallelism, task-parallelism, 
  functional, object-oriented, logic, component-based etc.).
* Implementation and optimisation techniques for innovative 
  parallel languages and programming models (e.g. threads, 
  dataflow, tiling, skeletons, declarative languages, and 
  generalised data-parallel approaches, etc.).
* Performance models and their integration into the design of 
  efficient parallel algorithms and programs (e.g. BSP, LogP, CGM,
  N-half and their alternatives, cost calculi and static 
  performance prediction, profile-driven approaches).
* Parallel programming paradigms and tools, their comparison and 
  integration (e.g. data-parallel vs. task-parallel, coordination 
  programming, performance analysis and debugging).
* Methodological aspects of developing, optimizing and validating 
  parallel programs (formalisms, semantics, specification, design,
  transformations, verification, etc.).
* Software engineering for parallel and distributed systems 
  (design patterns, portability, robustness, standardization, 
  etc.).
* Systematic approaches and programming models to support 
  effective program development in grid environments.   
* Domain-specific parallel libraries and languages (e.g. for 
  simulation, irregular and unstructured meshes, computational 
  geometry, etc.).

---
 KEY DATES

  November 8, 2002  First call for papers
  February 9, 2003  Final date for submissions
  May 1, 2003   Notification of acceptance
  July 15, 2003 Early registration deadline

---
PC COMMITTEE

Global Chair

Prof. José  C. Cunha
New University of Lisbon, Portugal
Email: [EMAIL PROTECTED]   
 
Vice Chairs

Dr. Marco Danelutto
University of Pisa, Italy 
Email: [EMAIL PROTECTED]  

Prof. Peter H. Welch
University of Kent, United Kingdom 
Email: [EMAIL PROTECTED]  

Local Chair

Dr. Christoph Herrmann
Universität Passau, Germany
Email: [EMAIL PROTECTED]

---
 SUBMISSION DETAILS

Authors are requested to submit their papers by using our submission 
site http://europar-itec.uni-klu.ac.at/submission.html (please 
indicate TOPIC 10). The site will open not later than at the beginning
of January 2003. 
All accepted papers will be available at the conference in the 
proceedings published by Springer-Verlag in the LNCS series.

Euro-Par 2003, Topic 10 (CfP)

2002-11-15 Thread Ch. A. Herrmann
Dear Haskellers,

many of you are using Haskell as a tool for developing parallel
programs, are working on parallelizing Haskell compilers,
language extensions, or interfaces. If you are involved in 
parallel programming, I'd strongly encourage you to submit a 
paper to Topic 10 of Euro-Par 2003. It'll be a good forum to 
present your work.

Apologies if you receive multiple copies of this message.
---

 **
 ******
 ***  CALL FOR PAPERS   ***
 ***   Submission Deadline: February 9, 2003***
 ******
 ***   EURO-PAR 2003 Topic 10   ***
 *** Parallel Programming: Models, Methods and  *** 
 ***   Programming Languages***
 ******
 ***Klagenfurt, Austria ***
 *** August 26-29, 2003 ***
 ******
 *** http://europar-itec.uni-klu.ac.at/ ***
 ******
 **

Description
This topic provides a forum for the presentation of the latest research
results and practical experience in the development of parallel 
programs. Advances in algorithmic and programming models, design 
methods, languages, and interfaces are needed to produce correct, 
portable parallel software with predictable performance on different
parallel and distributed architectures.

The topic emphasises results that improve the process of developing 
high-performance programs, including high-integrity programs that are 
scalable with both problem size and complexity. Of particular interest
are novel techniques by which parallel software can be assembled from 
reusable parallel components without compromising efficiency. Related 
to this is the need for parallel software to adapt, both to available 
resources and to the problem being solved. 

Where appropriate, contributions should demonstrate quantitative 
performance results in support of their claims, and address 
applications not adequately handled by well-established approaches.

Focus
* Languages, libraries and interfaces for different parallel 
  programming models (e.g. data-parallelism, task-parallelism, 
  functional, object-oriented, logic, component-based etc.).
* Implementation and optimisation techniques for innovative 
  parallel languages and programming models (e.g. threads, 
  dataflow, tiling, skeletons, declarative languages, and 
  generalised data-parallel approaches, etc.).
* Performance models and their integration into the design of 
  efficient parallel algorithms and programs (e.g. BSP, LogP, CGM,
  N-half and their alternatives, cost calculi and static 
  performance prediction, profile-driven approaches).
* Parallel programming paradigms and tools, their comparison and 
  integration (e.g. data-parallel vs. task-parallel, coordination 
  programming, performance analysis and debugging).
* Methodological aspects of developing, optimizing and validating 
  parallel programs (formalisms, semantics, specification, design,
  transformations, verification, etc.).
* Software engineering for parallel and distributed systems 
  (design patterns, portability, robustness, standardization, 
  etc.).
* Systematic approaches and programming models to support 
  effective program development in grid environments.   
* Domain-specific parallel libraries and languages (e.g. for 
  simulation, irregular and unstructured meshes, computational 
  geometry, etc.).

---
 KEY DATES

  November 8, 2002  First call for papers
  February 9, 2003  Final date for submissions
  May 1, 2003   Notification of acceptance
  July 15, 2003 Early registration deadline

---
PC COMMITTEE

Global Chair

Prof. José  C. Cunha
New University of Lisbon, Portugal
Email: [EMAIL PROTECTED]   
 
Vice Chairs

Dr. Marco Danelutto
University of Pisa, Italy 
Email: [EMAIL PROTECTED]  

Prof. Peter H. Welch
University of Kent, United Kingdom 
Email: [EMAIL PROTECTED]  

Local Chair

Dr. Christoph Herrmann
Universität Passau, Germany
Email: [EMAIL PROTECTED]

---
 SUBMISSION DETAILS

Authors are requested to 

RE: Rational sequence

2002-10-24 Thread Ch. A. Herrmann
Hi Haskellers,

   Simon Any objections?

frankly speaking, yes.

The intellectual meaning of a successor in a non-integral type
is not clear for me. Can anyone explain it?

I observed this report discussion for quite a long time and
maybe have found the deep reason behind the problems. It appears
to me that people like to add flexibility to the language
that should better not be added since it destroys structure.
The software engineering power of Haskell mainly comes from 
its structure. One is surely more flexible with an untyped, 
not referentially transparent language, but many efforts 
have been made to add flexibility without loss of structure,
e.g., Generic Haskell.

Surely, one can enumerate the rationals like one can enumerate
pairs of integers, but that is not the kind of enumeration discussed
here, which is suppose to have a constant increment/decrement.

Unfortunately, several decisions concerning the predefined type class
system have already been kept according to other programming
languages instead of algebra. The latter
would have provided both mathematical rigor and more possibilities
for useful overloading of predefined operators. 

Making non-integrals an instance of Enum appears to me like
a dirty hack, to reuse nice syntax. Maybe, it would be
more genuine to say that [a..b] is a counterpart of a loop
and use a new class called Iterator for a and b.
In any case, numbers which do not permit an exact increment,
as is the case for Float and Double should not be permitted
as types of iteration variables, since it would legitimate
bad programming style.

Since I suppose you also want to receive constructive suggestions,
I'd suggest to remove some instance definitions from the
report. Would any dubious instance definition have a consequence
on the performance of compiled code if it is, for compatibility, 
only provided by a kind of deprecated prelude or library?

Cheers
--
 Christoph




___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell



IO security

2002-10-04 Thread Ch. A. Herrmann

Hi GHC users,

I'm looking for secure compile and run-time methods to ensure 
automatically that Haskell modules cannot perform particular 
IO operations. Therefore, I've got some questions that might 
be interesting for other people using GHC as well.

   o There are functions like unsafePerformIO. How many of these
 unsafe functions exist and what are their names? Is there
 a possibility to tell GHC to reject programs in which
 such functions occur? Concerning, e.g.,  the rewrite-rule system,
 how can we prevent that these functions are applied by
 some trick, invisible by an automatic inspection of the
 source code?
 
   o Is the function print secure in the sense that all stuff
 it produces is restricted to go to stdout, even if strange
 sequences of control characters appear?

   o Is there a way to tell the GHC run-time system to block
 file operations or system calls coming from the
 application program, while permitting input/output
 via stdin/stdout?

Thanks in advance
--
 Christoph Herrmann 
___
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users



Re: Problems with IO

2002-09-24 Thread Ch. A. Herrmann

Hi Pavel,

 pavel == pavel  [EMAIL PROTECTED] writes:

pavel I'm having a problem with writing a function dealing with
pavel I/O. Maybe it's just a lack of experience or simple Haskell
pavel knowledge because I'm just a beginer. The problem: I want to
pavel write a function that converts an IO String into String lala
pavel :: IO String - String

pavel Is it possible? If yes, how?

you cannot use (except from a dirty trick) an IO operation that
returns a string (IO String) as a string. What you can do 
--and, I assume, that's what you want to do-- is
to apply a function inside a composition of IO operations that uses the
result of a previous IO operation, e.g., function f in the
following program text:

main = do
string1 - readFile input  or something else of type IO String
let result = f string1
print result or something else
return ()

Note that this kind of let does not have a corresponding in. 

The reason that a function like unIO :: IO a - a
does not legally exist is that it would break a nice
theoretical property of Haskell called referential transparency
which makes reasoning about programs extremely productive.

Hope that helps.
--
 Christoph Herrmann

___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell



Re: Problems with IO

2002-09-24 Thread Ch. A. Herrmann

Hi Pavel,

 pavel == pavel  [EMAIL PROTECTED] writes:

pavel My task is to write a parser for some language (TSG).
pavel ...
pavel Why should I use that do thing? What is so magical in it?

pavel PS: Please, don't say that I'm stupid, I just have problem
pavel with understanding IO/Monad part, besides that is just me
pavel second week of Haskell... :)

I think that your task is not appropriate for a Haskell beginner.
You should go to the person who gave you the task and tell
him/her that you need much more time to learn Haskell, understand
how monads are to be used and, maybe, what type classes are. 
Otherwise, you cannot guarantee that your program will
work the way it is supposed to.

Good luck
--
 Christoph
___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe



Re: readFloat

2002-05-31 Thread Ch. A. Herrmann

Hi Haskellers,

 Max == Max Kirillov [EMAIL PROTECTED] writes:

Max So why one might need it? I've never used Rational, but, if
Max asked, I would say that they are for exact representation of
Max numbers (some symbolic calcs).

that's true. I'm using rationals intensively since a couple of years for this
purpose and I'd like that they remain as exact as they are. 

Max On the other side, 'real' dotted
Max numbers always represent some real values with finite
Max accuracy. 

I'm not sure if that always is the case, but there is the danger of
confusion and this should be enough reason to be careful.

Max That's look like a bad idea to me to call Rational
Max numbers 'real' and type (print) them as a decimal fraction (*).

Especially converting rationals to a string and back should always
be the identity. It would be better to print rationals in the
form   
   numerator % denominator

and read them in the same form.

Surely, it's good to have flexibility in a programming language;
but at critical points --and conversions between floating points
(even if represented as strings) and rationals are such a point-- 
a programming language should demand explicit conversion. 

Cheers
-- 
 Christoph 
___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell



Re: Simple Question

2002-05-16 Thread Ch. A. Herrmann

Hi,

JiJie 20) append' x:xs y = [(init x:xs)] ++ [(tail xs)++[y]]

function application (blank) binds stronger than :,
thus you should write 

   append' (x:xs) y = ...

Cheers
-- 
 Christoph
___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe



Re: Simple Question Follow Up

2002-05-16 Thread Ch. A. Herrmann

To make it short:

Main let append' xs y = init xs ++ [last xs ++ [y]]

This works for the three given examples but maybe incorrect
for the task you have in mind, e.g., if xs is empty.

Main append' [ [1, 2], [3, 4], [5] ] 6
[[1,2],[3,4],[5,6]]
Main append' [ ['1', '2'], ['3'] ] '4'
[12,34]
Main append' [ [True], [True] ] False
[[True],[True,False]]

Cheers
--
 Christoph
 
___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe



Re: some algorithms are hard to code in O(n) in Haskell

2002-04-25 Thread Ch. A. Herrmann

Hi,

first of, you should consider whether you really need O(n).
Since you want to use Haskell, your aim is probably more
on elegance than on performance. Maybe, an Theta(n * log n) program
in Haskell would be easier to verify.

Surely, you can program in imperative style in Haskell achieving
optimal complexity, using arrays with destructive updates 
(check the Glasgow extensions).

For some O(n) graph algorithms (like connected components),
there is an elegant optimal solution by John Launchbury:
Graph algorithms with a functional flavour,
Springer Lecture Notes in Computer Science 925, pp. 308--331, 1995.

Good luck
-- 
 Christoph Herrmann
___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell



Bug ghc-5.02.3 / Gtk+HS

2002-04-24 Thread Ch. A. Herrmann

Hi,

compiling the example ModuleTest.hs from the
Gtk+HS distribution produces the following
error message:

84  ghc `gtkhs-config --cflags --libs` ModuleTest.hs 
ghc-5.02.3: panic! (the `impossible' happened, GHC version 5.02.3):
AbsCStixGen.gencode typedef void ( *_ccall_fun_tys1ku) (I_);

Please report it as a compiler bug to [EMAIL PROTECTED],
or http://sourceforge.net/projects/ghc/.

Good luck
--
 Christoph

___
Glasgow-haskell-bugs mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs



multiple methods pattern bug(?)

2002-04-11 Thread Ch. A. Herrmann

Hi,

the following instance declaration doesn't work any
more with ghc-5.02.3, it worked before.

 newtype ST state a = ST { unST :: state - (a,state) }
 
 instance Monad (ST c) where
  return x  = ST (\state - (x,state))  
 (m = f) = ST (\state - let (x,state1) = unST m state
   (y,state2) = unST (f x) state1
   in (y,state2)) 

Error message:
Can't handle multiple methods defined by one pattern binding
(m = f)
= ST (\ state
  - let
   (y, state2) = ...
   (x, state1) = ...
 in (y, state2))

What can I do instead?

--
 Christoph
___
Glasgow-haskell-bugs mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs



Re: a universal printer for Haskell?

2002-02-19 Thread Ch. A. Herrmann

Hi Haskellers,

 Bernard == Bernard James POPE [EMAIL PROTECTED] writes:

Bernard Handling functions is always going to be hard. Actually, a
Bernard related issue in Haskell is what do you do with partially
Bernard evaluated structures? Certainly in some circumstances you
Bernard don't want to force the value just so that you can write it
Bernard out.

sorry if I wasn't precise enough. I don't want to force ANY evaluation
on the value to be marshalled; in some cases the computation may even
not terminate! Instead, the string is an encoding of the smallest
part of the heap that is necessary to restore the information.
My aim is to save a state which contains unevaluated closures to
disk and resume the computation at a later time or to send a state
to a remote location. The nice property of a functional language,
in contrast to imperative languages, is that you can make a snapshot 
of your computation without any support by the runtime environment if, 
of course, those (un)marshalling functions are available.
 
Bernard If you compiled to byte code, life would be a lot
Bernard easier, however everything will get a lot messier if you
Bernard want to mix machine code and byte code. urgh...

The problem is to encode program functions, not just functions that arise during
the computation. Compiling to byte code is a different issue.

Bernard It would be nice if you could write out some data to file from
Bernard GHC and then read it in using NHC :)

That'll be very complicated and require a deep discussion about an
interface language.

Bernard I think Clean has a prototype persistence mechanism, I saw
Bernard a short demo late last year. I'm not sure how they
Bernard represent functional values. I think you can only read the
Bernard data from within the same program that wrote the data.

That would be OK for me. It would even be OK if it is the same binary,
i.e., not to be used in heterogeneous networks. Anyway, I don't
like to change my favourite programming language unless it's better
than Haskell and that'll be very likely Haskell-II :-) 

Cheers
--
 Christoph
___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe



Re: a universal printer for Haskell?

2002-02-18 Thread Ch. A. Herrmann

Hi Bernard,

Bernard I, and I assume many other Haskell programmers would from
Bernard time to time like a universal print mechanism, something
Bernard that can turn an arbitrary value into a String.

yes, I'm such a Haskell programmer that would like such a mechanism but
it only makes sense for me if you also have the inverse function.

In this case, you could save the state of your computation on disk and
recover it later, send run-time functions to a remote machine 
and execute them on that machine with full control by the programmer.

This marshalling/unmarshalling mechanism is provided partially by
some Haskell tools. As far as I heard, OCaml permits a more general
mechanism, but I didn't manage to get it running with OCaml.
Anyway, I don't want to program in OCaml.

Probably the reason that this mechanism doen't exist in Haskell yet is that
it is difficult to implement. Also, efficient marshalling will likely
produce unreadable strings for elements of the Show class and thus,
would be an additional feature, no extension. 

Cheers
-- 
 Christoph



   
___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell



RE: The size of things

2002-02-15 Thread Ch. A. Herrmann

 Simon == Simon Marlow [EMAIL PROTECTED] writes:

 Yes, I see.  Would it be possible to have a standard strict list,
 i.e. something equivalent of
 
 data SList a = SNil | SCons !a SList
 
 (which could be a member of the same class as the normal lists,
 and have the usual functions (length, ++, isPrefixOf...) 
 overloaded)?

Simon Yes, it would be possible, but we can't do it without making
Simon sweeping changes to standard libraries and deviating from
Simon Haskell 98 quite a bit.  It's something to bear in mind
Simon should the topic of Haskell 2 come up, though.

If there are significant changes to be made anyway, wouldn't it be 
the best thing to generalize lists to a type class of which lists 
are an instance of? The nice list comprehension syntax could then 
be used also for other data structures, and combinators like map, filter,
scanl applied to arrays, trees etc. 

Analogously to the Num class, one could have a function like *toList*, 
and one would expect from a program to establish:  

   toList . combinator_in_X_a = combinator_in_[a] . toList

Cheers
--
 Christoph



 

___
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users



Re: RFC: Syntax for implicit parameter bindings

2002-02-04 Thread Ch. A. Herrmann

Hi Haskellers,

personally, I'd prefer to use a kind of labeled fields notation at the
point where the function is called, like:

   addBase{?base=7} 5

In recursive calls, this notation would then be optional, of course.

If a function should be called multiple times with the same
value of the implicit parameter, one could use a local definition:

   let addBase7 = addBase{?base=7}
   in addBase7 5 + addBase7 9

Cheers
-- 
 Christoph Herrmann
___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell



Re: compilation using MPI

2002-02-01 Thread Ch. A. Herrmann

 Hal == Hal Daume, Hal writes:

Hal are there any MPI bindings for any version of Haskell (or
Hal related language or any FPL for that matter)?

there's a tool called hMPI:

   http://www-i2.informatik.rwth-aachen.de/~michaelw/hmpi.html

Cheers
--
 Christoph

___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell



RE: gcd 0 0 = 0

2001-12-18 Thread Ch. A. Herrmann

 Simon == Simon Peyton-Jones [EMAIL PROTECTED] writes:

Simon Christoph does not like this

It's OK if the definition is clear; it wasn't using
the words positive or greatest integer.

Stating gcd 0 0 = 0 explicitly is a good thing,
even if it could be expressed verbatim;
people may think about the mathematical background,
but they should not need to think about the
meaning of the definition.

Anyway, I'm still against promoting 1 to a prime number :-)

Cheers
--
 Christoph 


___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell



Re: gcd 0 0 = 0

2001-12-17 Thread Ch. A. Herrmann

 George == George Russell [EMAIL PROTECTED] writes:

George I've reconsidered my earlier position and think now that the
George Prelude is wrong to make gcd 0 0 an error, and should return
George 0.  It probably doesn't make much difference to anyone, but
George it's like 1 not being a prime; it may be slightly harder to
George explain, but it makes the maths come out nicer and is in the
George end a simplification.

I'm strongly against making 1 a prime number.

In contrast, 0*x=0, thus 0 divides 0 (somehow).
But I have problems with gcd being the greatest positive integer ...

- 0 is not positive, it is non-negative or natural
- 2 also divides 0 and 2 is a greater integer than 0
  (0 is the top element of the lattice formed by the division relation
   but that is not clear by the expression greatest)

Anyway, gcd 0 0 = error  would be the simplest way to avoid confusion
and catch accidental programming errors; e.g., using the gcd to divide
something else.

--
 Christoph

___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell



Re: GCD

2001-12-11 Thread Ch. A. Herrmann

 Simon == Simon Peyton-Jones [EMAIL PROTECTED] writes:


Simon  gcd x y is the greatest POSITIVE integer that divides
Simon both x and y.

Simon I don't think that changes the specification in fact, but
Simon experience has led me to always check these things!

I find it confusing to read a definition which contains redundant
information. Instead, I'd suggest to add something like:

  Note: this number is always positive

Cheers
-- 
 Christoph Herrmann

___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell



Re: Pointers in Haskell??

2001-12-07 Thread Ch. A. Herrmann

Hello,

 Bryan == Bryan Hayes (Hayes Technologies) 
[EMAIL PROTECTED] writes:

Bryan My question is:
Bryan Does Haskell principally not need pointers (i.e. in case of 2
Bryan data structures needing to reference an other very large data
Bryan structure) or is this a design flaw or have a overlooked
Bryan something?

if you hold two variables to a data structure, the structure is
represented only once. This is established by a graph structure of data,
instead of just a tree structure. If you modify one copy, only the
reachable parts between the handle (variable) and the position where the
change has been made, are copied. All common substructures that are not
affected by the change remain shared. Memory is allocated and released
automatically.

However, if you prefer a more state-based way of programming, you can
deal with pointers in a so-called monad, but if you need pointers for
no other reason than efficiency, you should first try to use efficient
programming techniques and data structures in Haskell. Programming in
Haskell is completely different from imperative programming but it'll
be worth it from the perspective of programming productivity.
Just finding a way to fit imperative style in the syntax of Haskell
will not give you the benefit you may expect from Haskell. 
Have a look at the book by Simon Thompson: Haskell: The Craft of
Functional Programming. It explains the methodology of programming
in Haskell very well.

Cheers
-- 
 Christoph Herrmann

___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe



Strict foldl

2001-12-06 Thread Ch. A. Herrmann

Hi Haskellers,

which compiler settings do I have to pass to ghc-5.02
in order to achieve that the strictness analyzer
recognizes strictness of (+) in foldl and computes
sum in constant space?

Prelude sum [1..1000]

had the following effect:

  PID USER PRI  NI  SIZE  RSS SHARE STAT %CPU %MEM   TIME COMMAND
23542 herrmann  20   0  250M 130M 97500 R66.3 52.4   0:21 ghc-5.02

Of course, one could define a strict foldl oneself:

 sfoldl f e [] = e
 sfoldl f e (x:xs) = (sfoldl f $! (f e x)) xs

(   sfoldl (+) 0 [1..1000] 
   returns 500500 in about a minute interpreted 
   using 18MB of total space.)

But with the own definition one has to redefine many of the prelude functions.

Thanks in advance
--
 Christoph Herrmann

___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell



Enum class

2001-10-23 Thread Ch. A. Herrmann

Hi Haskellers,

assuming that the type class Enum represents enumeration
types, there are two questions for me:

(1) What is the justification for the types Float and Double
to be members of the type class Enum? This might induce students
to use floating point values as counters in arithmetic 
sequences. 

(2) Why not make tuples of bounded enumeration types 
themselves bounded enumeration types? E.g.,

   [(False,False)..(True,True)] 

could evaluate to

   [(False,False),(False,True),(True,False),(True,True)]

and it is comprehensible since the ordering in the sequence
equals the lexicographic ordering imposed on tuple comparison.

Cheers
Christoph  

___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell



Re: Enum class

2001-10-23 Thread Ch. A. Herrmann

 Lennart == Lennart Augustsson [EMAIL PROTECTED] writes:

Lennart Ch. A. Herrmann wrote:
 (1) What is the justification for the types Float and Double
 to be members of the type class Enum? This might induce
 students to use floating point values as counters in arithmetic
 sequences.

Lennart And what's wrong with that? If the students are using are
Lennart using values like 0.1 and expecting it to be represented
Lennart exactly then they should have some lectures about floating
Lennart point arithmetic.

The point is that students might use the fact that Float and Double are
in type class Enum as a justification to use it in practice, e.g.,
to avoid an Int-Float conversion. Maybe one can even prove that
approximation errors will not harm in a particular situation.
The question is whether a language should impose a style that protects
programmers from taking such risks, and Haskell is a language that
uses to follow this direction. 

Lennart I've heard your complaint before, but I
Lennart can't really understand why removing Float and Double 

Removing them would possibly cause problems with existing programs 
and this is definitely not my aim. However, it'll make sense to 
think about long-term improvements. I wouldn't call Float and Double 
enumeration types. Maybe, a just misunderstood what Enum means.

Cheers
Christoph 


___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell



Re: list comprehension

2001-10-19 Thread Ch. A. Herrmann

 Stephanie == Stephanie Randles [EMAIL PROTECTED] writes:

Stephanie Hi, I have a script here

Stephanie interleave :: [Integer] - [Strings] - [String]
Stephanie interleave (x:xs) (y:ys) = words [a | a - (unwords
Stephanie [(show x), (filter (/= 1) y), +])]

Stephanie and the error message i receive is

Stephanie (Instance of Num Char required for definition of
Stephanie interleave)

the difficult error message is due to the flexibility of the
type class system in Haskell.

The variable y is of type String, i.e., a list of Char. You try
to compare a number (/= 1) with a character (an element of y taken
by filter).
The number constant 1 imposes the type class Num (for numbers) via the
comparison to this character, but you have not made Char an
instance of class Num (define  +, -, * on Char). Probably that's
not what you want; the error message does not address the logical
source of error but the point where the constraints mismatched.

Good luck
-- 
Christoph Herrmann

___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell



ghci: unknown symbol `__ashldi3

2001-10-05 Thread Ch. A. Herrmann

We have installed ghc-5.02 from source on a Solaris-2.6
machine after a difficult bootstrapping process. 
Now, ghc-5.02 works fine but with ghci we get the following
error message:

 Loading package std ... linking ... 
/public/packages/programming/ghc-5.02/lib/ghc-5.02/HSstd_cbits.o: unknown symbol 
`__ashldi3'
 ghc-5.02: panic! (the `impossible' happened, GHC version 5.02):
 can't load package `std'


Does anyone know how to fix this problem?

Due to the presence of several Sparc classic machines we cannot
switch to Solaris-2.7 at the moment.
-- 
 Christoph Herrmann

___
Glasgow-haskell-bugs mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs



ghc-5.02/libreadline.so.3

2001-09-24 Thread Ch. A. Herrmann

Dear Haskellers,

in ghc-5.02/distrib/INSTALL, there is the following hint:

 Linux users: GHCi-5.00 needs libreadline.so.3.  Newer Linuxes (SuSE
 7.1, possibly RH 7.X, possibly Mandrake 8.X) only come with
 libreadline.so.4.  If you need libreadline.so.3 and only have the .4
 version, you might be able to get things working by making a symbolic
 link from libreadline.so.4 to libreadline.so.3.  We tried this on a
 SuSE 7.1 box and it seemed to work.

It worked well on my PC at home. However, I also have to install it
at our office and students pool but unfortunately, our system
administrator told me that he will not allow hacks of this kind. 
He asked me to adapt the installation appropriately instead of 
manipulating the system. 

Please tell me how to adapt the makefile or something else to get
it running. I'm sorry not to be an installation expert; maybe it's
a simple thing to do.

Many thanks in advance
-- 
 Christoph Herrmann
 Postdoctoral Research Associate 
 University of Passau, Germany 
 E-mail:  [EMAIL PROTECTED]
 WWW: http://brahms.fmi.uni-passau.de/cl/staff/herrmann.html

 

___
Glasgow-haskell-bugs mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs



RE: ghc-5.02/libreadline.so.3

2001-09-24 Thread Ch. A. Herrmann

 Julian == Julian Seward (Intl Vendor) [EMAIL PROTECTED] writes:

Julian On possible thing you can do is

Julian * Find a copy of libreadline.so.4 from somewhere (your home
Julian PC ?)  * Place it in some dir under your control, eg
Julian /home/herrman/lib * export
Julian LD_LIBRARY_PATH=/home/herrman/lib:$LD_LIBRARY_PATH

Julian Now ldd /path/to/ghc-5.02-executable should show
Julian libreadline.so.4 being picked up from /home/herrman/lib and
Julian you should be able to run ghc.

Done.

Calling ghci delivers the following error message:
   ghc-5.02: not built for interactive use

ghc works (seems OK) and using ldd shows the correct link.

How can I enforce the interactive build of ghci, 
maybe without recompiling the whole stuff?

Christoph



___
Glasgow-haskell-bugs mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs



Re: RFC: GUI Library Task Force

2001-09-24 Thread Ch. A. Herrmann

Basically, I like the suggestions, but want to clarify:

 * The library focuses on graphical *user interfaces* (ie,
   buttons, menus, scrollbars, selection lists, etc) as
   opposed to drawing and animation routines.

Many applications where GUIs are used require a canvas/scribble field
with the following basic functionality:

  - set a point in a particular color; if speed is an issue,
mapping a 2D-array content to the canvas would be useful
  - read the relative mouse coordinates when a mouse
button was pressed or released or the mouse was moved 
with a pressed button  

Cheers
Christoph

___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell



The Haskell Report

2001-07-23 Thread Ch. A. Herrmann

Hi Haskellers,

because I recognized that some people are discussing
the Haskell report, I'd like to point out a problem
concerning the operator precedences.

At precedence level 9, there are the left associative
operator (!!) and the right associative operator (.),
but combining both directions doesn't make sense neither for me ..

.. nor for ghci: 
gs !! i . f
cannot mix `(!!)' [infixl 9] and `(.)' [infixr 9] in the same infix expression
 
It appears sensible for me that (!!) associates to the
left and I suppose that there is a strong requirement
for (.), which is associative anyway (f.g).h = f.(g.h), 
to associate to the right, due to efficiency reasons.
However, what's the problem with introducing a precedence level 10
and move (!!) upto it?

Cheers
Christoph

___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell



RE: The Haskell Report

2001-07-23 Thread Ch. A. Herrmann

 Simon == Simon Peyton-Jones [EMAIL PROTECTED] writes:

Simon You may be right, but the Report is neither confusing nor
Simon inconsistent on this point, I think.  So I don't think it
Simon falls into the class of things that we can change for H98.

Simon You'll just have to add parens!

That's true. It's not a vital point; just a question of beauty ...

Cheers
Christoph

 



___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell



Re: CA proposal by D.Thurston

2001-05-14 Thread Ch. A. Herrmann

Hi Haskellers,

 S == S D Mechveliani S.D.Mechveliani writes:

S I was said that there exists an algebraic library proposal for
S Haskell (version 0.02) dated by February (2001?), by Dylan
S Thurston.

that sounds interesting for me. Sorry, that I don't have an answer to your 
question, but I like to state some points about an algebraic library.

A standard algebraic library has several advantages to many different
tools developed by individual programmers:

(1) One can benefit from the knowledge and experience of others
(and of their work also, of course)
(2) An open discussion process will help to avoid
errors or difficulties in use
(3) Programs written by others that use the library functions
are more comprehensible

I've got no impression of how such a library may look like
and if the library is meant to be updated from time to time.
Anyway, an algebraic library is important:
it is nice that Haskell has the rational numbers but recently, it
appeared useful for me also to have the algebraic numbers, e.g.,
to evaluate expressions containing roots exactly. The problem is
that I'm not an expert in this stuff and thus, be very glad if
such things are added by an expert.

On the other hand, I'd like to add things like a linear equation solver
for a non-invertible system which may help to convince people that
Haskell provides more features than other programming languages do.

Cheers
Christoph

___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell



Re: please help me

2001-02-08 Thread Ch. A. Herrmann

Hi Faizan,

 "FAIZAN" == FAIZAN RAZA [EMAIL PROTECTED] writes:

FAIZAN Hello Please help me to solve this questions


FAIZAN Question

FAIZAN Cartesian Product of three sets, written as X x Y x Z is
FAIZAN defined as the set of all ordered triples such that the
FAIZAN first element is a member of X, the second is member of Y,
FAIZAN and the thrid member of set Z. write a Haskell function
FAIZAN cartesianProduct which when given three lists (to represent
FAIZAN three sets) of integers returns a list of lists of ordered
FAIZAN triples.

FAIZAN For examples, cartesianProduct [1,3][2,4][5,6] returns
FAIZAN [[1,2,5],[1,2,6],[1,4,5],[1,4,6],[3,2,5],[3,2,6],[3,4,5],[3,4,6]]

I'll leave that as an exercise for you :-)

If you want to become a Haskell programmer, try it yourself.

Two hints: - have a look at list comprehensions in the report
   - first try to solve it with two sets and pairs

Cheers
Christoph

___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell



Re: Revamping the numeric classes

2001-02-07 Thread Ch. A. Herrmann

moved to haskell-cafe

Ketil E.g. way back, I wrote a simple differential equation solver.
Ketil Now, the same function *could* have been applied to vector
Ketil functions, except that I'd have to decide on how to implement
Ketil all the "Num" stuff that really didn't fit well.  Ideally, a
Ketil nice class design would infer, or at least allow me to
Ketil specify, the mathematical constraints inherent in an
Ketil algorithm, and let my implementation work with any data
Ketil satisfying those constraints.

the problem is that the --majority, I suppose?-- of mathematicians
tend to overload operators. They use "*" for matrix-matrix
multiplication as well as for matrix-vector multiplication etc.

Therefore, a quick solution that implements groups, monoids, Abelian
groups, rings, Euclidean rings, fields, etc. will not be sufficient.

I don't think that it is acceptable for a language like Haskell
to permit the user to overload predefined operators, like "*".

A cheap solution could be to define a type MathObject and operators like 
   :*: MathObject - MathObject - MathObject
Then, the user can implement:

a :*: b = case (a,b) of
 (Matrix x, Matrix y) - foo
 (Matrix x, Vector y) - bar
-- 
 Christoph Herrmann
 E-mail:  [EMAIL PROTECTED]
 WWW: http://brahms.fmi.uni-passau.de/cl/staff/herrmann.html

___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell



Re: Revamping the numeric classes

2001-02-07 Thread Ch. A. Herrmann

moved to haskell-cafe

Ketil E.g. way back, I wrote a simple differential equation solver.
Ketil Now, the same function *could* have been applied to vector
Ketil functions, except that I'd have to decide on how to implement
Ketil all the "Num" stuff that really didn't fit well.  Ideally, a
Ketil nice class design would infer, or at least allow me to
Ketil specify, the mathematical constraints inherent in an
Ketil algorithm, and let my implementation work with any data
Ketil satisfying those constraints.

the problem is that the --majority, I suppose?-- of mathematicians
tend to overload operators. They use "*" for matrix-matrix
multiplication as well as for matrix-vector multiplication etc.

Therefore, a quick solution that implements groups, monoids, Abelian
groups, rings, Euclidean rings, fields, etc. will not be sufficient.

I don't think that it is acceptable for a language like Haskell
to permit the user to overload predefined operators, like "*".

A cheap solution could be to define a type MathObject and operators like 
   :*: MathObject - MathObject - MathObject
Then, the user can implement:

a :*: b = case (a,b) of
 (Matrix x, Matrix y) - foo
 (Matrix x, Vector y) - bar
-- 
 Christoph Herrmann
 E-mail:  [EMAIL PROTECTED]
 WWW: http://brahms.fmi.uni-passau.de/cl/staff/herrmann.html

___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe



Re: Extensible data types?

2000-09-25 Thread Ch. A. Herrmann

Hi,

Jose I am working on an Computer Algebra system to transform
Jose mathematic expressions, possibly simplifing them. There is a
Jose data type to represent the expressions:

Jose data Expr = Int Integer | Cte String | Var String | App Fn [Expr]

Jose An expression may be an integer, a named constante (to
Jose represent "known" contantes like pi and e), a variable or an
Jose application. An application has a functor (function name) and
Jose a list of arguments. The functor is introduced with

Jose   data Fn = Sum | Pro | Pow

Jose meaning the application may be a sum, a product or a power.

...

Jose The functions manipulating the expressions also should be
Jose extensible to accomodate new algorithms. The extensions is in
Jose a form of hooks (based on the Fn component of an application
Jose function) in the main algorithms.

I've encountered the same problem and I'm interested to get to know a
highly productive way which at the same time can be considered
a good way of software engineering.
Not enough ... it should pass the Haskell typechecker and be compatible
with the class concept.

At the moment, I know only one "right way": to define several different 
types and define functions on each of these types individually.
That's too much work for me ...

However, the only fast but awful style I know is something like:

data FunctorType = Sum | Pro | Pow | Sin | Trace | UnsafeInput 
 | ... whatever you like

data AllMyExpressions = SingleConstructor { functor:   FunctorType,
arguments: [AllMyExpressions] }
-- 
 Christoph Herrmann
 E-mail:  [EMAIL PROTECTED]
 WWW: http://brahms.fmi.uni-passau.de/cl/staff/herrmann.html





Re: openFile, process file table full

2000-09-12 Thread Ch. A. Herrmann

 "Jan" == Jan Kort [EMAIL PROTECTED] writes:

  
Jan I can't seem to work around this behaviour, is it possible to
Jan force readFile to just open a file, read it entirely and close
Jan it before doing the next open ? I tried a few things with seq,
Jan but this doesn't work:

I tried to copy the file into a temporary, remove it and wait until it
does not exists any longer. However, that doesn't work either.
The message on Solaris was:

 ld.so.1: sh: fatal: libc.so.1: open failed: Too many open files

 Fail: interrupted
 Action: system
 Reason: system command interrupted rm newtmp

Although our file system may have synchronizations problems I was sure
the following would work:
--
module Main where

import Directory
import System


waitWhileExistsFile :: String - IO ()
waitWhileExistsFile name 
 = do
exists - doesFileExist name
if exists 
  then waitWhileExistsFile name
  else return ()

safeReadEntireFile :: String - IO String
safeReadEntireFile name 
 = do
system("cp "++name++" newtmp");
content - readFile "newtmp"
system("rm newtmp");
waitWhileExistsFile "newtmp"
return content


main :: IO ()
main = do
xs - mapM safeReadEntireFile (take 1000 (repeat "tmp"));
print (length xs)
return ()
--




(no bug :-)) GHC Core Language

2000-09-11 Thread Ch. A. Herrmann

Hello,

I'm considering for the near future to "hack" with the core language 
module of GHC, but I'm not sure whether it's good to use the
current definitions or data structures because things may change
with the new GHC.

Is there an agreement that the data structures used for the
core language will remain or will there be an agreement for
the structures used in the new GHC?

Are there attempts to approach something that is described in
the paper by Peyton Jones, Launchbury, Shields and Tolmach:

"Bridging the gulf: a common intermediate language for
 ML and Haskell"
?
-- 
 Christoph Herrmann
 E-mail:  [EMAIL PROTECTED]
 WWW: http://brahms.fmi.uni-passau.de/cl/staff/herrmann.html




Re: Some questions about Monads

2000-09-05 Thread Ch. A. Herrmann

Hi Diego,

 "Diego" == Diego Dainese [EMAIL PROTECTED] writes:

Diego - In Haskell is there some way to combine IO and ST? 

there is a so-called IOS-Monad combining IO and State, appended below.
Thanks to John O'Donnell who told me about it and gave it to me a few weeks ago.

Cheers
Christoph
--
 IOS: Input/Output with state

 module IOS where

 newtype IOS s a = IOS (s - IO (a, s))

 unIOS :: IOS s a - (s - IO (a, s))
 unIOS (IOS m) = m

 liftIOS :: IO a - IOS s a
 liftIOS m = IOS (\s - m = \a - return (a,s))

 runIOS :: IOS s a - s - IO (a, s)
 getIOS :: IOS s s
 setIOS :: s - IOS s ()
 modIOS :: (s - s) - IOS s s

 runIOS= unIOS 
 modIOS f  = IOS (\s - return (s, f s))
 setIOS s' = IOS (\s - return ((),s'))
 getIOS= IOS (\s - return (s,s))

 thenIOS m k= IOS (\s - unIOS m s = \(a,s') - unIOS (k a) s')
 then_IOS m k= IOS (\s - unIOS m s = \(_,s') - unIOS k s')
 retIOS a = IOS (\s - return (a,s))

 instance Monad (IOS s) where
   (=)  = thenIOS
   ()   = then_IOS
   return = retIOS

---
-- Basic operations for data parallel monad

 rundp :: IOS s a - s - IO ()
 rundp prog initst =
   do runIOS prog initst
  return ()

 dp_putStr :: String - IOS s ()
 dp_putStr xs = liftIOS (putStr xs)

 dp_getChar :: IOS s Char
 dp_getChar = liftIOS getChar

 dp_showState :: Show s = String - IOS s ()
 dp_showState cs =
   do dp_putStr cs
  x - getIOS
  dp_putStr (show x)
  dp_putStr "\n"
  return ()

 dp_showStatenew :: (s - IO ()) - IOS s ()
 dp_showStatenew f =
   do x - getIOS
  liftIOS (f x)
  dp_putStr "\n"
  return ()

 repeatLoop f =
   do q - f
  if q then repeatLoop f
   else return ()

---
-- Data parallel monadic operations with list state

 dpl_map :: (a-a) - IOS [a] [a]
 dpl_map f = modIOS (map f)

 dpl_foldl :: (a-b) - (b-b-b) - b - IOS [a] b
 dpl_foldl f g a =
   do xs - getIOS
  return (foldl g a (map f xs))

---
-- Examples of monadic data parallel programs

-- Basic I/O with dp operations in the IOS monad

 dp_echoChar :: IOS [Int] ()
 dp_echoChar =
   do dp_putStr "This is dp_echoChar, type in a character for me!\n"
  c - dp_getChar
  dp_putStr ("\nyou typed in the character ---" ++ [c] ++ "---\n")
  dp_showState "this is the initial state:\n  "
  dp_putStr "bye\n"
  return ()

 run_echoChar = rundp dp_echoChar [1..10]

Monadic data parallel maps, folds and scans with list state

 dp_alg :: IOS [Int] ()
 dp_alg =
   do dp_putStr "\nThis is dp_alg\n"
  dp_showState "initial state:\n  "
  dpl_map (*10)
  dp_showState "after mapping (*10):\n  "
  x - dpl_foldl id (+) 0
  dp_putStr ("dplfold id (+) == " ++ show x ++ "\n")
  dpl_map (+x)
  dp_showState "after mapping (+x):\n  "
  dp_putStr "bye\n\n"
  return ()

 run_dp_alg = rundp dp_alg [1..10]

---
-- The pure Data Parallel monad (without I/O)

 data DP s a = DP (s - (a,s))

 instance Monad (DP s) where
   (f = g) =
 DP (\s - case unwrapDP f s of
 (a,s') - unwrapDP (g a) s')
   return a = DP (\s - (a,s))

 unwrapDP :: DP s a - (s -(a,s))
 unwrapDP (DP f) = f
===
END of mail




Re: frantk / overlapping instances

2000-09-01 Thread Ch. A. Herrmann

Hello,

does type-checking remain decidable (in general) for overlapping instances
(:+o in hugs)? 

-- 
Christoph




Haskell-GUIs (was Re: using Hudak's SOE book)

2000-08-30 Thread Ch. A. Herrmann

Hello,

 "Johannes" == Johannes Waldmann [EMAIL PROTECTED] writes:
Johannes 1) FranTk runs with hugs *and* with ghc (does this hold
Johannes for FAL as well? last I checked it seemed hugs only)

Johannes 2) FranTk has all those fancy input widgets

Johannes Again i want to avoid the impression that Haskell is a toy
Johannes language because all examples are run on a seemingly small
Johannes interpreter, and the graphics libraries are too simple. As
Johannes I said, the students have done some programming, including
Johannes Java.

I have got a little programming experience with both FranTk and Java
applets and got the impression that FranTk is appropriate for
a simple graphical interface to a program which you want to
be written in Haskell.

In my impression, the Haskell GUI most supported is the binding to GTK
by Manuel Chakravarty. Despite the fact, whether GTK or FranTk is
more comfortable, I'd decide for a GUI which is going to be supported
in the future by several people and maybe even part of the main ghc
distribution.

Sometime in the future, when a combination of ghc and hugs
is available, the GUI should run with hugs if it runs 
compiled with ghc. 

Cheers
-- 
 Christoph Herrmann
 E-mail:  [EMAIL PROTECTED]
 WWW: http://brahms.fmi.uni-passau.de/cl/staff/herrmann.html





Re: Higher-order function application

2000-08-23 Thread Ch. A. Herrmann

Hi Tim,

Tim 6. Applying a function f:t-u to a list x::[t] translates to
Tim "map f x".

the problem is that we loose much of the strength the Haskell type
system provides and a lot of programming errors will remain
undetected.

What you can do is write a preprocessor that provides a
nicer syntax for you.

Cheers
-- 
 Christoph Herrmann
 E-mail:  [EMAIL PROTECTED]
 WWW: http://brahms.fmi.uni-passau.de/cl/staff/herrmann.html




Re: Fw: speed of compiled Haskell code.

2000-03-22 Thread Ch. A. Herrmann

Hi,

 very slow. After we made the insert operation in the AVL tree
 hyperstrict and a few similar changes, our program behaved very
 well and is surely faster than if written in C using naive data
 structures and algorithms.  We used combinators like strict2 f x
 y = strict (strict f x) y to achieve a simple code.

Jan I find this interesting. It would be nice if you would like to
Jan explain me what you mean by " hyperstrict"

I agree with the definition of hyperstrictness, that a function is
hyperstrict if it evaluates its arguments completely.

What I meant concerning the AVL tree was not complete hyperstrictness
but, that all parts which influence the structure of the tree
are evaluated when a new element is inserted. The crucial point
is that the application of the tree constructors must be strict to
guarantee that the restructuring balancing operation is performed
immediately. The comparison operators and the condition in
if-then-else are strict anyway and, thus, will force sufficient
evaluation. However, data stored in the tree that is not used for
the operations on the tree need not be evaluated.

Cheers
Christoph
 

  




Re: speed of compiled Haskell code.

2000-03-20 Thread Ch. A. Herrmann

Dear Haskellites,

 My experience with the program of generating permutations on
 [1..10] showed that the code produced by ghc-4.04 is 22 times
 slower than certain specially written C program.  Only the C
 program algorithm was taken very different from Haskell's
 one. For each system has its own best algorithm and appropriate
 data structure.  But this example task was chosen as unlucky for
 Haskell.  In other, average case, I expect the ratio of 6-10.

Jan This seems that Haskell cannot be considered as a language for
Jan real world applications but merely as a toy for researchers .

some people from the FORTRAN community could say:
"C is far too slow, use FORTRAN! Many computationally expensive
 problems do not need dynamic data structures!"


In my opinion, the speed argument has to be relativated:

- Not all applications require full speed.

- Haskell programming saves you a lot of development time
  compared with C. You can use Haskell as an executable 
  specification language and, if really necessary, charge
  some programmers with the task to convert it to C. 

- You need not use exclusively either Haskell or C. Time critical, 
  interactive, or hardware accessing parts can be implemented in C, 
  but your sophisticated algorithms are programmed in Haskell.

- The ratio 6-10 is the state of the art today.
  I believe that if as much research were spent on Haskell compilation as
  on C compilation, Haskell would outperform C.
  Haskell has the advantage to C that due to referential transparency
  more powerful optimization rules can be applied.
  Thus, giving up referential transparency would mean to get a small 
  improvement now but sacrifice the chances of the future.

Cheers
-- 
 Christoph Herrmann
 E-mail:  [EMAIL PROTECTED]
 WWW: http://brahms.fmi.uni-passau.de/cl/staff/herrmann.html








RE: speed of compiled Haskell code.

2000-03-20 Thread Ch. A. Herrmann

Hi,

Jan Haskell code optimised by strictnes annotions in functions or
Jan in datastructures are ? times slower than C.

Jan Please correct me where I am wrong and fill in the required
Jan number for the ?  sign above

I cannot give you a number, but I like to report about some
experience we made in our programming project. We used lists to
store a symbol table for a compiler. Later, we felt the need to
switch to AVL trees and so we did. As the programs got bigger
we discovered that our program used more than 200MB heap and
became very slow. After we made the insert operation in the
AVL tree hyperstrict and a few similar changes, our
program behaved very well and is surely faster than
if written in C using naive data structures and algorithms.
We used combinators like  
   strict2 f x y = strict (strict f x) y
to achieve a simple code.


Cheers
-- 
 Christoph Herrmann
 E-mail:  [EMAIL PROTECTED]
 WWW: http://brahms.fmi.uni-passau.de/cl/staff/herrmann.html



RE: Haskell 98: partition; and take,drop,splitAt

2000-01-26 Thread Ch. A. Herrmann

Hello,

I'm worrying that there are too many constraints put on the definition
of a function's domain. Thus, if you agreed on the domains of take, drop,
etc. and their semantics, please give a definition, say D, of these functions
in terms of the ordinary list constructors. I would consider any
implementation of take, e.g., to terminate for at least the input values
for which it terminates, if defined by D.

I agree, that the following equation is very useful:

take n xs ++ drop n xs == xs

I would also prefer monotonicity, i.e., 

take (n-1) xs   always be a prefix oftake n xs
and
drop (n+1) xs   always be a suffix ofdrop n xs

A definition respecting this would be:

take n xs | n=0 = []
take n [] | n0  = []
take n (x:xs) | n0  = x : take (n-1) xs
and
drop n xs | n=0 = xs
drop n [] | n0  = []
drop n (x:xs) | n0  = drop (n-1) xs

Termination of take works also if xs is an infinite list.

-- 
 Christoph Herrmann
 E-mail:  [EMAIL PROTECTED]
 WWW: http://brahms.fmi.uni-passau.de/cl/staff/herrmann.html





Re: drop take [was: fixing typos in Haskell-98]

2000-01-26 Thread Ch. A. Herrmann

 "Hamilton" == Hamilton Richards [EMAIL PROTECTED] writes:

Hamilton How about these definitions? They're like the Haskell98
Hamilton prelude definitions except that n0 is always an error,
Hamilton even if the list is [].

the problem with an unnecessary restriction is that it complicates
reasoning about the program. 
Instead of

   xs
 = { take/drop-law }
   take (n-m) xs ++ drop (n-m) xs

you have to write, e.g.:

   xs
 = { restricted take/drop-law }
   if nm then undefined else take (n-m) xs ++ drop (n-m) xs
 
The problem is that the "-" operator naturally can appear
if you perform cut and paste operations on lists, but
the natural numbers are not closed under negation.

If using a natural type, people will insist on having a partial
minus operation. How should the compiler check that this operation
is well-defined? If the compiler can't, why have this type at all
if the integers are available?

The advantage of solution (A) is that it makes a single principle
exception for values out of range: an unnatural definition,
but solution (B) makes two: undefinedness for negative values and 
an unnatural definition for values that exceed the size of the list,
i.e., (B) puts more work on the programmer.

In general, the larger a domain of an operation is, the simpler
is the handling. If, i.e., a division by zero produces a value
"div by zero" instead of an error message, 
subsequent operations may deal with it and the entire computation can succeed.

-- 
 Christoph Herrmann
 E-mail:  [EMAIL PROTECTED]
 WWW: http://brahms.fmi.uni-passau.de/cl/staff/herrmann.html







Re: Dynamic scopes in Haskell

1999-12-01 Thread Ch. A. Herrmann

Hello,

 operators with suitable associations defined). So
 my symbolic expression type should be an instance
 of the Num class so that the (+) operator can
 be overloaded for it. But, as the function has
 now three arguments, it cannot be a binary operator
 anymore.

maybe, an ad-hoc solution is to use an interpreter
which takes your infix expressions as strings and evaluates them in
the environment you like.

For the future, I would appreciate a redesign of the overloading
of operators in Haskell, such that any (also predefined) operator
can be overloaded according to the users taste,
e.g., to form an expression like

expr1 +e expr2

where e is some environment and the above expression is shorthand for 

(+) e expr1 expr2.

-- 
 Christoph Herrmann
 E-mail:  [EMAIL PROTECTED]
 WWW: http://brahms.fmi.uni-passau.de/cl/staff/herrmann.html







Re: Dynamic scopes in Haskell

1999-12-01 Thread Ch. A. Herrmann

I had just a fast look at the following I found at the 
page "http://www.cse.ogi.edu/PacSoft/projects/Hugs/hugsman/exts.html"
for dynamic scoping:

   min :: [a] - a
   min  = least with ?cmp = (=)

Actually, I'm not sure how referential transparency can be established
with these implicit parameters. Assume min to be called at two places
with a different value for cmp, but with the same input list. Or is it
the case that the type a is bound to a particular cmp all over the program?

Please note, that referential transparency is one main advantage Haskell
has in contrast to other languages .

-- 
 Christoph Herrmann
 E-mail:  [EMAIL PROTECTED]
 WWW: http://brahms.fmi.uni-passau.de/cl/staff/herrmann.html






Equational reasoning, was Re: What is a functional language?

1999-09-27 Thread Ch. A. Herrmann

Hi,

 "F" == Fergus Henderson [EMAIL PROTECTED] writes:

F Well, it depends a bit on how you look at it.  But I would say
F that with normal equational reasoning, you _are_ constrained to
F preserve strictness.  To say that a function is strict in an
F argument just means that when you apply that function to _|_, the
F result is _|_.  Using equational reasoning, transformations need
F to preserve properties such as `f _|_ = _|_' just as much as they
F need to preserve properties such as `f 0 = 42'.

I see a huge problem for equational reasoning due to preserving
strictness and that has nothing to do whether you are in a strict
language like ML or in a non-strict language like Haskell:

!!! You loose ability to expand functions. 

Have a look at the following example: Assume 
  f :: Integer - Integer
  f x = x - x

and the expression (e + f n). Normally, you would like to simplify that
expression to e what you cannot do if you don't know that n/=_|_.
The use of Haskell can't help here, because '-' is strict anyway and,
in fact, termination behavior might change.

The problem is to introduce _|_ into your calculus, i.e., into the
integers, where it doesn't belong to. Mathematics says that for every
integer x, it holds that x-x=0. If you add _|_ to the integers,
this and many other theorems simply don't hold any longer,
because _|_ - _|_ must be _|_.

Therefore, I suggest to keep _|_ out of equational reasoning proofs and
consider termination behavior as a separate issue. Precisely, the
proof tells you, that if both programs terminate, they deliver the
same result, and that's better than having no proof at all (e.g., in
the case that a program you derived terminates more often, which
is obviously a good thing).

Cheers
-- 
 Christoph Herrmann
 E-mail:  [EMAIL PROTECTED]
 WWW: http://brahms.fmi.uni-passau.de/cl/staff/herrmann.html


 


 






Re: 4.04 binary installation, $LibGmp

1999-07-30 Thread Ch. A. Herrmann

Happens also with the solaris binary:

ld: fatal: library -lgmp: not found
ld: fatal: File processing errors. No output written to ...


 "S" == S D Mechveliani [EMAIL PROTECTED] writes:

S I have a question for the GHC developers: where it is explained
S the path setting for the gmp library?

-- 
 Christoph Herrmann
 E-mail:  [EMAIL PROTECTED]
 WWW: http://brahms.fmi.uni-passau.de/cl/staff/herrmann.html



RE: Eval class / Sorry

1998-12-15 Thread Ch. A. Herrmann

Hello,

I'm sorry cause I didn't recognized that the "strict" function is
still available:

 "Ch" == Ch A Herrmann [EMAIL PROTECTED] writes:

Ch What I like to have is a mechanims to force the evaluation of an
Ch expression before passing it as an argument to a function. 

It seems to be that now "strict" is defined for all applications.
---
 Christoph Herrmann
 E-mail:  [EMAIL PROTECTED]
 WWW: http://brahms.fmi.uni-passau.de/cl/staff/herrmann.html




Q: Eval class

1998-12-14 Thread Ch. A. Herrmann

Hi,

I have a problem with the Eval class. Maybe its just that a compiler
flag or import declaration is missing. I compiled with
   ghc-4.01/bin/ghc -c -fvia-C -syslib exts

and got the error message:
   No instance for `Eval Int'

OK, let's try 
   instance Eval Int where
  seq x y = y   -- because ints are already evaluated

Then I got the error message:
   Class `Eval' does not have a method `seq'

However, in the hugs standard prelude one can find the following
definition:

class Eval a where
strict :: (a - b) - a - b
seq:: a - b - b

It's *not* a special problem of ghc-4.01.

Has somebody an idea what to do or can give me a hint on a report 
for the Eval class?

Thanks in advance
---
 Christoph Herrmann
 E-mail:  [EMAIL PROTECTED]
 WWW: http://brahms.fmi.uni-passau.de/cl/staff/herrmann.html



RE: topdelcs / decls

1998-10-23 Thread Ch. A. Herrmann

Hello,

Jan Your thought would destroy equational reasoning! For example
Jan you would be able to define different equalties on the same
Jan data structure. So Red==Black could be False in one place
Jan and True in another place. Does that make any sense?

Ralf Of course, it does. You neglect the fact that definitions have
Ralf scope.  You can already define two functions both called say
Ralf `eq' such that `eq Red Black' yields False in one place and
Ralf True in another place.

in fact, one has to be very careful in using equational reasoning.
Consider the do-notation:

   do x - ...
  let y = x
  x - ..
  return (y==x)

It is false to assume that the value True is returned. Each line of
the do opens a new scope. In my opinion, avoid the use of x
twice in such cases.

Let me give you my opinion about the idea of Johannes.

Johannes just a thought .. why is it that some declarations (data,
Johannes type, newtype, class, instance) are only allowed at the
Johannes (module) top level? in some cases i'd like to have more
Johannes locality, and less namespace pollution.

I think the module is the right instance to make type definitions
like the function is the right instance to define values, in 
general. You could also have a lot of nested let-expressions, e.g.,
but they complicate the comprehension of the functions, see the
scope discussion above.

What you suggest may be good for a very special purpose,
--- I'm interesting in what you have in mind ---
but not for most applications. What you can do is to
define your types in an indirect way using algebraic data
types.

If your problem arised just as a consequence that your modules
are very large, I suggest to use smaller modules.
As it is beneficial to have small function definitions, it also
is to have small modules. In that case, what one would like to
have is NESTED MODULES and that seems to be implementable more
easily.

Sincerely
---
 Christoph Herrmann
 E-mail:  [EMAIL PROTECTED]
 WWW: http://brahms.fmi.uni-passau.de/cl/staff/herrmann.html






Re: numerics in Haskell

1998-08-04 Thread Ch. A. Herrmann

Hello,

 "Hans" == Hans Aberg [EMAIL PROTECTED] writes:

Hans   The idea with calling the floating numbers floating numbers
Hans is that it is possible to implement real numbers too, as in
Hans computer algebra programs.

we have to distinguish between 3 sets:

(1) The set of algebraic numbers (rationals + roots etc.).
An arbitrary finite subset of this set can be represented in the machine.
Each element can be represented as a root of a polynomial
with rational coefficients.
An exact representation will be appropriate for things like testing, 
whether the square of the square root of 2 is 2.
I guess (I don't know) that it is possible to test whether
two representations represent the same number or not. 

(2) The set of all real numbers.
An arbitrary finite subset cannot be represented in the machine.
Specific subsets can be represented, if we agree upon codes
for "e", "pi", "sum from i=a to b of ...", "integral"  etc.
The question is: how does evaluation of expressions with these
numbers look like? Simplification based on heuristics?

(3) The set of finite prefixes of a radix representation
of real numbers. 
This set will be appropriate for
approximating real numbers. To make this set really useful
there must be a function (less :: "Real" - "Real" - Bool), 
which always terminates and checks absolutely sure, if the 
first argument is less than the second.
Then, numerical mathematicians will damn Haskell, I suppose.

The last set (3) might be a good argument for people to use
Haskell because of its laziness. It also seems to be of most
practical interest. 
---
 Christoph Herrmann
 E-mail:  [EMAIL PROTECTED]
 WWW: http://brahms.fmi.uni-passau.de/cl/staff/herrmann.html








Typechecking Monads

1997-10-14 Thread Ch. A. Herrmann

Hello,

in the following example, where I define a
state transformer monad "St" parametrized with 
the state "c", the ghc-2.08 typechecker reports
the following error message in the type definition of
function "foo" which uses the instantiated "St":  

  `St' should have no arguments, but has been given 1 .

It works if I comment out the type definition. It also
works in hugs-1.3 with the type definition. Is there a
way to get it being typechecked by given a special compiler option?

Thanks in advance
--
 Christoph Herrmann
 E-mail:  [EMAIL PROTECTED]
 WWW: http://brahms.fmi.uni-passau.de/cl/staff/herrmann.html
--
data State c a = State (c - (a,c))

unState :: State c a - (c - (a,c))
unState (State x) = x

unitState :: a - State c a
unitState a = State (\s0 - (a,s0))

bindState :: State c a - (a - State c b) - State c b
bindState m k = State (\s0 - let (a,s1) = (unState m) s0
  (b,s2) = (unState (k a)) s1 
  in (b,s2))

instance Eq c = Monad (State c) where
return = unitState 
(=)  = bindState 

data TS = TS { vs::Int } deriving (Show,Eq)

type St = State TS

foo :: Int - St Int  -- it works if this line is not given
foo x = return x
--
END OF MESSAGE



Re: bug

1997-09-26 Thread Ch. A. Herrmann

Hello,

concerning my previous mail:

during compilation with the binary installed version of
ghc-2.07 for Solaris, I got the following message:
---
*** Pattern-matching error within GHC!

This is a compiler bug; please report it to [EMAIL PROTECTED]

Fail: "nativeGen/MachCode.lhs", line 1024: pattern-matching failed in case
---
I found the part of the source that caused the error,
it is inside a case expression:

   EInt i  - i `seq` (TInt SUndef, EInt i)

If one removes "i `seq`" it compiles without errors.
However, the "seq" has been useful for me in debugging,
because I get error messages that contain expressions
that are further evaluated. I'm using this regularly
when developing with hugs. Please tell me if that's
a bad style, and the compiler should give an error
message there.
---
 Christoph Herrmann
 E-mail:  [EMAIL PROTECTED]
 WWW: http://brahms.fmi.uni-passau.de/cl/staff/herrmann.html