Re: getting the path to the executing program

2004-01-08 Thread Ferenc Wagner
Hal Daume III <[EMAIL PROTECTED]> writes:

> True.  Replace "the" with "a" and "?" with ", if it exists?".
>
> On Thu, 8 Jan 2004, Lennart Augustsson wrote:
>
>> Hal Daume III wrote:
>>
>>> is there a function, related to getProgName, which
>>> returns the (absolute) path to the current program?
>>
>> Well, the absolute path name is not necessarily unique,
>> nor is it guaranteed to exist. :)

http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=utf-8&threadm=9201%40june.cs.washington.edu&rnum=1&prev=/groups%3Fhl%3Den%26lr%3D%26ie%3DUTF-8%26oe%3Dutf-8%26selm%3D9201%2540june.cs.washington.edu

This is all you can get, I am afraid.

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


Re: getting the path to the executing program

2004-01-08 Thread Hal Daume III
True.  Replace "the" with "a" and "?" with ", if it exists?".

On Thu, 8 Jan 2004, Lennart Augustsson wrote:

> Hal Daume III wrote:
> > is there a function, related to getProgName, which returns the (absolute) 
> > path to the current program?
> Well, the absolute path name is not necessarily unique, nor is it
> guaranteed to exist. :)
> 
>   -- Lennart
> 
> ___
> Haskell mailing list
> [EMAIL PROTECTED]
> http://www.haskell.org/mailman/listinfo/haskell
> 

-- 
 Hal Daume III   | [EMAIL PROTECTED]
 "Arrest this man, he talks in maths."   | www.isi.edu/~hdaume

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


Re: getting the path to the executing program

2004-01-08 Thread Lennart Augustsson
Hal Daume III wrote:
is there a function, related to getProgName, which returns the (absolute) 
path to the current program?
Well, the absolute path name is not necessarily unique, nor is it
guaranteed to exist. :)
	-- Lennart

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


Re: getting the path to the executing program

2004-01-08 Thread Tomasz Zielonka
On Thu, Jan 08, 2004 at 07:02:04PM +0100, Tomasz Zielonka wrote:
> On Thu, Jan 08, 2004 at 09:06:44AM -0800, Hal Daume III wrote:
> > is there a function, related to getProgName, which returns the (absolute) 
> > path to the current program?
> 
> A non-portable Linux solution:
> 
> System.Posix.readSymbolicLink "/proc/self/exe"

A non-portable FreeBSD solution:

System.Posix.readSymbolicLink "/proc/curproc/file"

Best regards,
Tom

-- 
.signature: Too many levels of symbolic links
___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell


Re: getting the path to the executing program

2004-01-08 Thread Per Larsson
On Thursday 08 January 2004 18.06, Hal Daume III wrote:
> is there a function, related to getProgName, which returns the (absolute)
> path to the current program?
>
> basically, i want to be able to read a file which i know will be in the
> same directory as the current program, but not necessarily in the same
> directory that we're running it from.

I don't know how to do this in a portable way, but on unix/linux you can use 
the standard trick of reading the symbolic link
/proc//exe .

For example:

import System.Posix.Files  (readSymbolicLink)
import System.Posix.Process (getProcessID)

main = do
pid <- getProcessID
path <- readSymbolicLink ("/proc/" ++ (show pid) ++ "/exe")
putStrLn ("Absolute path of this program is " ++ path)

PS. This doesn't work with interpreted code (Hugs, GHCi) in which case
you get the path to the interpreter itself.

Cheers
Per









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


Re: getting the path to the executing program

2004-01-08 Thread Tomasz Zielonka
On Thu, Jan 08, 2004 at 09:06:44AM -0800, Hal Daume III wrote:
> is there a function, related to getProgName, which returns the (absolute) 
> path to the current program?

A non-portable Linux solution:

System.Posix.readSymbolicLink "/proc/self/exe"

Best regards,
Tom

-- 
.signature: Too many levels of symbolic links
___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell


Re: getting the path to the executing program

2004-01-08 Thread Hal Daume III
Sadly, this doesn't seem to work:

9:26am albini:SVMseq/ cat Foo.hs
module Main where
import System.Environment
main = getEnv "_" >>= putStrLn

9:27am albini:SVMseq/ ghc Foo.hs -o foo
9:27am albini:SVMseq/ ./foo

Fail: does not exist
Action: getEnv
Reason: no environment variable
File: _



On Thu, 8 Jan 2004, Christopher Milton wrote:

> The environmental var "_" in $ENV{"_"} (pardon my Perlish) holds
> the full path name of the command currently executing (itself), at
> least on RedHat Linux and HP-UX, so you should be able to use
> getEnv... I think... 
> 
> --- Hal Daume III <[EMAIL PROTECTED]> wrote:
> > is there a function, related to getProgName, which returns the (absolute) 
> > path to the current program?
> > 
> > basically, i want to be able to read a file which i know will be in the 
> > same directory as the current program, but not necessarily in the same 
> > directory that we're running it from.
> 
> 
> =
> Christopher Milton
> [EMAIL PROTECTED]
> 

-- 
 Hal Daume III   | [EMAIL PROTECTED]
 "Arrest this man, he talks in maths."   | www.isi.edu/~hdaume

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


getting the path to the executing program

2004-01-08 Thread Hal Daume III
is there a function, related to getProgName, which returns the (absolute) 
path to the current program?

basically, i want to be able to read a file which i know will be in the 
same directory as the current program, but not necessarily in the same 
directory that we're running it from.

-- 
 Hal Daume III   | [EMAIL PROTECTED]
 "Arrest this man, he talks in maths."   | www.isi.edu/~hdaume

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


Re: class ??? with Haddock

2004-01-08 Thread Wolfgang Jeltsch
Am Donnerstag, 8. Januar 2004 17:44 schrieb Simon Marlow:
> [...]

> One thing I forgot to mention is that you also need to remove the pesky
> lines beginning with '#' that the C preprocessor leaves behind.  Here's what
> we do in GHC:
>
>   $ ghc -D__HADDOCK__ -E -cpp Foo.hs -o Foo.tmp
>   $ sed -e 's/^#.*//' Foo.raw-hs

I use cpp with option -P to solve this problem.

> Cheers,
>   Simon

Wolfgang

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


Re: class ??? with Haddock

2004-01-08 Thread Wolfgang Jeltsch
Am Donnerstag, 8. Januar 2004 17:39 schrieb Simon Marlow:
> [...]

> > >$ ghc -E -cpp -D__HADDOCK__ Foo.hs -o Foo.raw-hs
> >
> > This only replaces all __HADDOCK__ occurences with 1 but doesn't process
> > #ifdefs.
>
> Are you sure?  It works for me, and it's what we use in GHC's libraries.

I found the problem, meanwhile.  You have to put the #ifdefs etc. at the 
beginning of the line.  Uuhâterrible, I'd say.  The same holds for cpp 
-traditional.  cpp without -traditional is more tolerant but treats 
everything beginning with // as a comment and is therefore not usable with 
Hugs when you need Data.Array.

Generally, I'd say that using a C preprocessor for Haskell is a bad idea but, 
of course, I can imagine that it requires less work to make cpp usable for 
Haskell than to develop a new preprocessor from scratch.  But is using cpp 
planned to be a long-term solution?

> Cheers,
>   Simon

Wolfgang

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


RE: class ??? with Haddock

2004-01-08 Thread Simon Marlow
 
> > Am Donnerstag, 8. Januar 2004 11:02 schrieben Sie:
> > > [...]
> > 
> > > Anyway, you can use GHC to preprocess your source files 
> > before feeding
> > > them to Haddock:
> > >
> > >$ ghc -E -cpp -D__HADDOCK__ Foo.hs -o Foo.raw-hs
> > 
> > This only replaces all __HADDOCK__ occurences with 1 but 
> > doesn't process #ifdefs.
> 
> Are you sure?  It works for me, and it's what we use in GHC's 
> libraries.

One thing I forgot to mention is that you also need to remove the pesky
lines beginning with '#' that the C preprocessor leaves behind.  Here's
what we do in GHC:

$ ghc -D__HADDOCK__ -E -cpp Foo.hs -o Foo.tmp
  $ sed -e 's/^#.*//' Foo.raw-hs

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


RE: class ??? with Haddock

2004-01-08 Thread Simon Marlow
 
> Am Donnerstag, 8. Januar 2004 11:02 schrieben Sie:
> > [...]
> 
> > Anyway, you can use GHC to preprocess your source files 
> before feeding
> > them to Haddock:
> >
> >$ ghc -E -cpp -D__HADDOCK__ Foo.hs -o Foo.raw-hs
> 
> This only replaces all __HADDOCK__ occurences with 1 but 
> doesn't process #ifdefs.

Are you sure?  It works for me, and it's what we use in GHC's libraries.

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


Re: class ??? with Haddock

2004-01-08 Thread Wolfgang Jeltsch
Am Donnerstag, 8. Januar 2004 11:02 schrieben Sie:
> [...]

> Anyway, you can use GHC to preprocess your source files before feeding
> them to Haddock:
>
>$ ghc -E -cpp -D__HADDOCK__ Foo.hs -o Foo.raw-hs

This only replaces all __HADDOCK__ occurences with 1 but doesn't process 
#ifdefs.

> [...]

Wolfgang

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


Re: Hugs with C preprocessor

2004-01-08 Thread Wolfgang Jeltsch
Am Mittwoch, 7. Januar 2004 21:46 schrieb Wolfgang Jeltsch:
> [...]

> I tried hugs -F "cpp -P -traditional" but got the same error message as
> without -traditional. This message is, suprisingly,
> sh: line 1: /usr/lib/hugs/libraries/Hugs/Prelude.hs: Permission denied
> ERROR "/usr/lib/hugs/libraries/Hugs/Prelude.hs" - Module "case"
> recursively imports itself
>
> FATAL ERROR: Unable to load Prelude.

I was able to get rid of this error message by removing the space after -F. 
However, now I get the messages cited below.

> I started hugs without the -F option and then tried to set it via :set
> -F"cpp -P -traditional".  After this I loaded my input file via :load and
> got these messages:
> cpp0: output pipe has been closed
> cpp0: output pipe has been closed
> cpp0: output pipe has been closed
> cpp0: output pipe has been closed
> cpp0: output pipe has been closed
> cpp0: output pipe has been closed
> cpp0: output pipe has been closed
> cpp0: output pipe has been closed
> cpp0: output pipe has been closed
> ERROR "./RegAlloc/Data/Graphs.hs":42 - Syntax error in input
> (unexpected selector "#ifdef")
> So cpp gives strange error messages and #ifdefs still don't work.

> [...]

Wolfgang

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


Second Call for Papers : ESSLLI'04 Student Session

2004-01-08 Thread Paul Egré
 !! We apologize for multiple copies of this message !!



SECOND CALL FOR PAPERS

   ESSLLI-2004 STUDENT SESSION

 9-20 August, 2004 in Nancy, France

 Deadline: February 22, 2004

http://esslli2004.loria.fr/



We are pleased to announce the Student Session of the 16th European
Summer School in Logic, Language and Information (ESSLLI-2004),
which will be held in Nancy from August 9-20, 2004. We invite
submission of papers for presentation at the ESSLLI-2004 Student
Session and for appearance in the proceedings.


PURPOSE:

This ninth ESSLLI Student Session will provide, like the previous
editions, an opportunity for ESSLLI participants who are students to
present their own work in progress and get feedback from senior
researchers and fellow-students. The ESSLLI Student Session
encourages submissions from students at any level, undergraduates
(before completion of the Master Thesis) as well as postgraduates
(before completion of the PhD degree). Papers co-authored by
non-students will not be accepted.  Papers may be accepted for full
presentation (30 minutes including 5 to 10 minutes of discussion) or for
a poster presentation.  All the accepted papers will be published in
the ESSLLI-2004 Student Session proceedings, which will be made
available during the summer school.


REQUIREMENTS:

The Student Session papers should describe original, unpublished
work, completed or in progress, that demonstrates insight, creativity,
and promise. No previously published papers should be submitted. We
welcome submissions with topics within the areas of Logic, Language and
Computation.


SUBMISSION DETAILS:

Student authors are invited to submit a full paper, not to exceed 7 pages of
length exclusive of references. Note that the length of the final
version of the accepted papers will not be allowed to exceed 10
pages.

The submissions will be reviewed by the student session programme committee
and additional reviewers. A plain ASCII text version of the identification
page should be sent separately, using the following format:

  Title: title of the submission
  First author: firstname lastname
  Address: address of the first author
  ..
  Last author: firstname lastname
  Address: address of the last author
  Short summary: abstract (5 lines)
  Subject area (one or two of): Logic | Language | Computation


In case the paper is being submitted to another conference or
workshop, this must be clearly indicated on the identification page.

The preferred formats of submissions are PostScript, PDF, or plain text,
although other formats will also be accepted. In case of acceptance, the
final version of the paper will have to be submitted in LaTeX format. The
papers must use single column A4 size pages, 11pt or 12pt fonts, and
standard margins. Submissions not in accordance with the specified
formatting and length requirements may be subject to rejection without
review.



The paper and separate identification page must be sent electronically to:

[EMAIL PROTECTED]

by FEBRUARY 22, 2004.


PROGRAMME COMMITTEE:

Laura Alonso i Alemany (Universitat de Barcelona, Barcelona)
Carlos Areces (LORIA, Nancy)
Jaume Baixeries (Universitat Politècnica de Catalunya, Barcelona)
Willem Comradie (Rand Afrikaans University, South Africa)
Benoit Crabbé (LORIA, Nancy)
Paul Egré (IHPST, Université Paris 1, IJN)
Judit Gervain (SISSA, Trieste)
Bart Geurts (University of Nijmegen, Nijmegen)
Ivana Kruijff-Korbayova (Universität des Saarlandes, Saarbrücken)
Marco Kuhlmann (Universität des Saarlandes, Saarbrücken)
Mª Magdalena Ortiz de la Fuente (Universidad de las Americas, Puebla)
Benjamin Spector (Laboratoire de Linguistique Formelle, Université Paris 7,
ENS)


IMPORTANT DATES:

Deadline for submission of papers : February 22, 2004.
Authors notifications : April 19, 2004.
ESSLLI early registration  : May 1, 2004.
Final papers for proceedings : May 15, 2004.
ESSLLI-2004 Student Session : August 9-20, 2004.


ESSLLI-2004 INFORMATION:

In order to present a paper at ESSLLI-2004 Student Session, at least
one student author of each accepted paper has to register as a
participant at ESSLLI-2004. The authors of accepted papers will be
eligible for reduced registration fees even after the deadline for
early registration. For all information concerning ESSLLI-2004,
please consult the ESSLLI-2004  main website at http://esslli2004.loria.fr/

For more information about the ESSLLI'04 student session, consult the
ESSLLI'04 student session website at:
http://lingua.fil.ub.es/~lalonso/stusESSLLI04/

If you have any further question about the student session, do not hesitate
to contact us:


Laura Alonso i Alemany Paul Egré
[EMAIL PROTECTED][EMAIL PROTECTED]

Departament de Lingüística General   IHPST / Université Paris 1 /
Universitat de

Re: Combining distinct-thread state monads?

2004-01-08 Thread Daan Leijen
Hi Mark,

The state transformer approach seems to have
advantageous in that it provides a framework for
building new monads from old, and accessing the
components.  One disadvantage is that it lacks
symmetry in that one monad is arbitrarily chosen
to sit inside the other.
You may want to read "composing monads" by Mark Jones
and Luc Duponcheel. It specifies precisely what kind
of laws should hold before monads can be composed.
(and indeed, it also shows that not all monads are
symetrical and can be arbitrarily composed!)


All the best,
 Daan Leijen.
___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell


Re: class ??? with Haddock

2004-01-08 Thread Wolfgang Jeltsch
Am Donnerstag, 8. Januar 2004 11:02 schrieb Simon Marlow:
> > How do I instruct Haddock to preprocess the Haskell files. From your mail
> > I thought that Haddock would do so by default but it complains at the
> > first #ifdef it sees.  Unfortunately, I didn't find any Haddock option
> > similar to Hugs' -F.
>
> I should really put this in the manual, since it gets asked so often.
> Anyway, you can use GHC to preprocess your source files before feeding
> them to Haddock:
>
>$ ghc -E -cpp -D__HADDOCK__ Foo.hs -o Foo.raw-hs
>$ haddock -h Foo.raw-hs ...
>
> This also works to turn literate Haskell source into ... er ... illiterate
> source.

So I have to write the preprocessed source to disk instead of piping it to 
Haddock when haddocking multiple files.  Hmm, sounds not so good :-( but is, 
of course, not such a big problem.

> Cheers,
>   Simon

Wolfgang

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


Re: Combining distinct-thread state monads?

2004-01-08 Thread Wolfgang Jeltsch
Am Donnerstag, 8. Januar 2004 03:20 schrieben Sie:
> [...]

> Thanks for your informative reply.

You're welcome.

> [...]

> One disadvantage is that it lacks symmetry in that one monad is arbitrarily
> chosen to sit inside the other.

Yes, I see this as a disadvantage, too.

> I found another approach mentioned called "stratification", developed by
> David Espinosa in his PhD thesis "Semantic Lego".  I am finding it a little
> hard to read because he codes in Scheme, not Haskell, but it sounds
> promising and seems to preserve symmetry better.
>
> Are you (or others) aware of this kind of approach being used in Haskell?

Neither I know this approach nor I'm aware of a Haskell implementation of it.

> Cheers,
>
> Mark.

Wolfgang

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


RE: class ??? with Haddock

2004-01-08 Thread Simon Marlow
 
> How do I instruct Haddock to preprocess the Haskell files.  
> From your mail I 
> thought that Haddock would do so by default but it complains 
> at the first 
> #ifdef it sees.  Unfortunately, I didn't find any Haddock 
> option similar to Hugs' -F.

I should really put this in the manual, since it gets asked so often.
Anyway, you can use GHC to preprocess your source files before feeding
them to Haddock:

   $ ghc -E -cpp -D__HADDOCK__ Foo.hs -o Foo.raw-hs
   $ haddock -h Foo.raw-hs ...

This also works to turn literate Haskell source into ... er ...
illiterate source.

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


Re: Combining distinct-thread state monads?

2004-01-08 Thread Dr Mark H Phillips
Hi Wolfgang,

Thanks for your informative reply.  At first I didn't
understand it, but a search on "StateT" lead me to the
paper "Monad Transformers and Modular Interpreters" by
Liang, Hudak and Jones, which clarified some of the
ideas for me.

The state transformer approach seems to have
advantageous in that it provides a framework for
building new monads from old, and accessing the
components.  One disadvantage is that it lacks 
symmetry in that one monad is arbitrarily chosen
to sit inside the other.  I found another approach
mentioned called "stratification", developed by
David Espinosa in his PhD thesis "Semantic Lego".  I
am finding it a little hard to read because he codes
in Scheme, not Haskell, but it sounds promising and
seems to preserve symmetry better.

Are you (or others) aware of this kind of approach being
used in Haskell?

Cheers,

Mark.


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


Re: Hugs with C preprocessor

2004-01-08 Thread Wolfgang Jeltsch
Am Mittwoch, 7. Januar 2004 20:37 schrieb Alastair Reid:
> > I want to use Haskell files with #ifdef, #else and #endif preprocessor
> > directives.  I tried hugs -F "cpp -P"  but cpp
> > complains about unterminated character constants.  What is wrong?
>
> ANSI C preprocessors tend to get confused by the quotes in lines like the
> following:
>
>f x = x' where x' = ...
>g x = x'
>  where
>   x' = ...
>
> You can often avoid this by putting cpp in 'K&R mode'. For example, GNU cpp
> accepts '-traditional'.

I tried hugs -F "cpp -P -traditional" but got the same error message as 
without -traditional. This message is, suprisingly,
sh: line 1: /usr/lib/hugs/libraries/Hugs/Prelude.hs: Permission denied
ERROR "/usr/lib/hugs/libraries/Hugs/Prelude.hs" - Module "case"
recursively imports itself

FATAL ERROR: Unable to load Prelude.

I started hugs without the -F option and then tried to set it via :set -F"cpp 
-P -traditional".  After this I loaded my input file via :load and got these 
messages:
cpp0: output pipe has been closed
cpp0: output pipe has been closed
cpp0: output pipe has been closed
cpp0: output pipe has been closed
cpp0: output pipe has been closed
cpp0: output pipe has been closed
cpp0: output pipe has been closed
cpp0: output pipe has been closed
cpp0: output pipe has been closed
ERROR "./RegAlloc/Data/Graphs.hs":42 - Syntax error in input (unexpected
selector "#ifdef")
So cpp gives strange error messages and #ifdefs still don't work.

> I'm attaching a shell script you might use (from end of hugs98/Install in
> the Hugs98 distribution).  (Not tested recently but ought to work.)

> [...]

>   if $running_under_some_random_shell;

Is this real code?

> [...]

>  # Reads CPP output and turns #line things into appropriate Haskell
>  # pragmas.  This program is derived from the "hscpp" script
>  # distributed with the Glasgow Haskell Compiler.

I already looked for hscpp but it doesn't seem to be included in 6.2.  Is it 
still in use with GHC?

> [...]

Wolfgang

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