FORTRAN and HASKELL

2001-11-29 Thread clusterpoli

Somebody works with together FORTRAN and Haskell. Exists
some funcao to transform codigo FORTRAN into codigo
HASKELL?

Thanks, Allan Bruno


__
AcessoBOL, só R$ 9,90! O menor preço do mercado!
Assine já! http://www.bol.com.br/acessobol



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



Re: FORTRAN and HASKELL

2001-11-29 Thread Christopher Milton

--- clusterpoli [EMAIL PROTECTED] wrote:
 Somebody works with together FORTRAN and Haskell. Exists
 some funcao to transform codigo FORTRAN into codigo
 HASKELL?

TXL might help, but it's its own functional language.
It can probably convert FORTRAN to Haskell given the
EBNF for each language, but I'm not sure how it works...
http://www.research.avayalabs.com/user/wadler/realworld/ls2000.html
http://gatekeeper.dec.com/pub/misc/txl/

Otherwise, I would look at what algorithm the FORTRAN is
implementing, the either write it in Haskell, or look for it
on the Internet using http://www.google.com/

For example: http://www.cs.chalmers.se/pub/haskell/library/
http://www.cs.chalmers.se/pub/haskell/library/bevan/index

__
Do You Yahoo!?
Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month.
http://geocities.yahoo.com/ps/info1

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



RE: IO errors

2001-11-29 Thread Simon Marlow

 A quick look at the source looks like both GHC and NHC will 
 simply pass
 on errors from the OS, so for example with
 
 module Main where
 
 import IO
 import Directory
 
 main :: IO()
 main = do catch (createDirectory this/does/not/exist/foo)
 (\e - putStrLn $ show $ map (flip ($) e) errors)
 
 errors :: [(IOError - Bool)]
 errors = [isDoesNotExistError,
   isIllegalOperation,
   isPermissionError,
   isAlreadyExistsError]
 
 both GHC and NHC give [True,False,False,False] (I don't seem to have a
 hugs Directory.hs) while the library report only allows
 isIllegalOperation, isPermissionError and isAlreadyExistsError. I
 haven't looked for other cases of this.

Two possibilities: either createDirectory should act like 'mkdir -p' and
make the whole path, or the library report should document
isDoesNotExistError as a possible error thrown by createDirectory.  I'd
vote for the latter.

No doubt there are many other cases of this, we should really do a full
audit of the I/O library specs.

Cheers,
Simon

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



RE: IO errors

2001-11-29 Thread Simon Peyton-Jones

| Two possibilities: either createDirectory should act like 
| 'mkdir -p' and make the whole path, or the library report 
| should document isDoesNotExistError as a possible error 
| thrown by createDirectory.  I'd vote for the latter.

I'm willing to do that for H98 unless anyone can think of a reason I
shouln't.

Simon

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



RE: Possible bug/omission in Numeric library?

2001-11-29 Thread Simon Peyton-Jones

| However, I would guess that changing the type signature of 
| the current showInt function is unacceptable for Haskell'98.  
| Maybe we should consider adding the more general version 
| under a new name like showIntBase, together with 
| show{Dec,Oct,Hex}?  This would break no existing code, and 
| clear up the slight anomaly in the current capability of the 
| Haskell'98 library.

Hmm.  This is another unforced change, but admittedly to the libraries,
which have received much less attention and in some cases (like
this) look more accidental than deliberate.  So I've been using a lower
bar for modifications to the Libraries than to the Report.


As you say, we can't change the type of showInt.  I suppose we could
add:

showIntAtBase :: Integral a 
  = a-- base
  - (a - Char)  -- digit to char
  - a-- number to show.
  - ShowS

showOct, showHex :: Integral a = a - ShowS


Q1:  But would we really want showDec too?  
Identical to existing showInt?

I am disinclined to use K-F's extra generality for H98, nice though it
is.
Too different from readInt.

Also, GHC's NumExts has 

doubleToFloat :: Double - Float
floatToDouble :: Float  - Double

Q2:  If we are going to run round adding functions to 
Numeric, should we add those too?  It's hard to know 
where to stop... but if that conversion is what you want to
do, H98 doesn't give a good way to do it.

Simon

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



Global variables

2001-11-29 Thread Juan Ignacio García García

Hello,

I am interested in using global variables (in GHC). 
I need a variable to store list of Integers to store temporary results.
I have been reading the module MVar, but I wonder if there is an
alternative way of doing it.
I have already implemented my function using an auxiliar argument where
I put my lists of Integers. 
Will the use of a global variable improve my function?

Thanks in advance,

J. Ignacio

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



Re: Possible bug/omission in Numeric library?

2001-11-29 Thread Malcolm Wallace

 As you say, we can't change the type of showInt.  I suppose we could
 add:
 
 showIntAtBase :: Integral a=20
 =3D a-- base
 - (a - Char)  -- digit to char
 - a-- number to show.
 - ShowS
 
 showOct, showHex :: Integral a =3D a - ShowS
 
   Q1:  But would we really want showDec too?
   Identical to existing showInt?

I only suggested it for consistency of naming.  However, since showInt
is not the dual of readInt, we can't have consistency anyway.

Regards,
Malcolm

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



Re: Global variables

2001-11-29 Thread Dmitry Astapov


 JIGG alternative way of doing it.  I have already implemented my function
 JIGG using an auxiliar argument where I put my lists of Integers.  Will
 JIGG the use of a global variable improve my function?

There is no such thing as mutable variable (as in imperative languages) in
Haskell (and my guess is that you are looking exactly for that type), so I
guess that for now you must bear with aux. parameter. 

Use of state monad will help to improve the look of your function, but
learning curve for monads could be steep.


-- 
Dmitry Astapov //ADEpt   E-mail: [EMAIL PROTECTED]
GPG KeyID/fprint: F5D7639D/CA36 E6C4 815D 434D 0498  2B08 7867 4860 F5D7 639D

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



Confused about Random

2001-11-29 Thread Ian Lynagh


With the following module:

module Main where

import Random

data Foo = Foo StdGen

main :: IO()
main = do let rs = randoms (Foo (mkStdGen 39)) :: [Int]
  rRs =  randomRs (0,9) (Foo (mkStdGen 39)) :: [Int]
  putStrLn $ show $ take 100 rs
  putStrLn $ show $ take 100 rRs

instance RandomGen Foo where
 genRange _ = (0, 1)
 next (Foo g) = (val `mod` 2, Foo g')
  where (val, g') = random g
 split _ = error Not implemented

ghc gives me

[-2147476078,7482,-2147476078,-2147476078,-2147476079,-2147476078,7483,7482,7482,-2147476079,-2147476078,-2147476079,-2147476079,7482,-2147476078,-2147476078,-2147476078,-2147476079,7482,7483,7482,7483,7482,-2147476078,-2147476078,-2147476078,7483,-2147476079,7482,-2147476078,-2147476079,-2147476078,7483,-2147476079,7483,7482,-2147476079,7483,7482,7483,-2147476078,-2147476079,-2147476079,7482,-2147476078,7482,-2147476079,-2147476079,7482,-2147476078,7483,7483,-2147476079,-2147476078,7483,7483,-2147476078,-2147476079,-2147476078,-2147476079,-2147476078,7483,7483,7482,7482,7483,-2147476078,-2147476079,-2147476079,7482,7483,-2147476078,-2147476079,-2147476079,-2147476078,7482,7483,-2147476079,7482,7482,7482,7483,-2147476079,-2147476079,-2147476078,7482,7482,7482,7482,-2147476079,7482,7482,-2147476079,7483,-2147476078,7482,7483,-2147476079,-2147476079,7482]
[1,2,2,1,1,2,1,2,1,1,1,2,2,2,2,1,2,1,1,1,1,2,1,1,1,1,2,1,1,2,1,2,1,2,1,1,2,1,2,2,2,1,2,2,2,1,1,2,1,2,1,2,2,2,1,1,2,1,1,2,1,1,1,2,2,2,1,1,2,2,2,1,1,1,2,2,2,1,2,2,1,2,1,1,1,1,2,1,1,2,2,1,1,1,1,1,2,1,1,2]

The first list doesn't seem to cover the whole spectrum and I was
expecting the second list to be composed over 0s through 9s. Is my
understanding wrong?

nhc complains
Context for Random.Random needed in left hand pattern at 17:11.
and hugs doesn't seem to know genRange exists. With it commented out it
returns the same as ghc.


Thanks
Ian


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



Re: Possible bug/omission in Numeric library?

2001-11-29 Thread Alastair David Reid


 Also, GHC's NumExts has

 doubleToFloat :: Double - Float 
 floatToDouble :: Float - Double

   Q2: If we are going to run round adding functions to Numeric,
 should we add those too?  It's hard to know where to stop... but if
 that conversion is what you want to do, H98 doesn't give a good way
 to do it.

Haskell already has fromRealFrac which does the same job (ignoring
NaNs, -0, etc.).  AFAIK, the only reason you'd use these shortcuts is
if you're using a compiler that can't optimize fromRealFrac (i.e.,
you're not using HBC or GHC) or exploring the limits of Haskell's 
support for IEEE arithmetic.

My feeling is that this is something of an unforced change.  Adding
functions can break code (though the fix is easy) so, whilst I agree
that the bar is lower for libraries and for adding functions, I think
we should still exercise some restraint.  This is especially true
since it's not clear that this is the right thing to do (since we have
fromRealFrac already) and it is hard to remove features once you've
added them.

-- 
Alastair Reid[EMAIL PROTECTED]http://www.cs.utah.edu/~reid/

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



Re: Global variables

2001-11-29 Thread Alastair David Reid


 Hello, I am interested in using global variables (in GHC).  I need a
 variable to store list of Integers to store temporary results.  I
 have been reading the module MVar, but I wonder if there is an
 alternative way of doing it.  I have already implemented my function
 using an auxiliar argument where I put my lists of Integers.  Will
 the use of a global variable improve my function?

There's many ways to achieve the same goals as C programmers achieve
using mutable (global) variables including using laziness, use of
accumulator arguments, and, supported by most compilers but not
standard Haskell, mutable variables.  (Unlearning imperative
programming habits is one of the big challenges in learning Haskell.)

Since there are so many ways to avoid mutable variables and (many
less) circumstances where mutable variables are the best solution,
it's hard to give useful advice without more information about the
problem.

-- 
Alastair Reid[EMAIL PROTECTED]http://www.cs.utah.edu/~reid/

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



Re: Where to ask questions regarding categories and datatypes

2001-11-29 Thread C.Reinke

 Peter Douglass writes:
   Hi,
 I have a number of questions regarding categories and datatypes.  I know
   that many of the folk in this mailing list could answer these question, but
   I wonder if there is a more appropriate forum.  (i.e. the question are not
   Haskell specific).
   
 
 Why don't you try the Types Forum [EMAIL PROTECTED]
 See also http://www.cis.upenn.edu/~bcpierce/types/

Or, if your questions are more on the categories side,
there is also:

  Categories List
  The category theory mailing list,
  moderated by Bob Rosebrugh. 
  http://www.mta.ca/~cat-dist/

Claus

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



Re: Global variables

2001-11-29 Thread C.Reinke


 Hello, I am interested in using global variables (in GHC).  I need a
 variable to store list of Integers to store temporary results.  I
 have been reading the module MVar, but I wonder if there is an
 alternative way of doing it.  I have already implemented my function
 using an auxiliar argument where I put my lists of Integers.  Will
 the use of a global variable improve my function?

no!-) ah, well, perhaps..

As you've already got your function, using auxiliary arguments, you
probably don't really need to re-write it in a less functional style.

But you will have noticed that much of your code repeatedly does the
same thing - passing the auxiliary around. It's good functional
programming practice to abstract away repeated code (both for reuse
and to get more concise code). One way to do that will lead you into
monads (your function is a state transformer, transforming the state
of the auxiliary list at each step), still a functional solution.

If you really, and absolutely want and must use global, mutable
variables in a functional language, you might find a recent paper
by John Hughes helpful, on that very topic. See his home page:

  http://www.cs.chalmers.se/~rjmh/

Hth,
Claus

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



Re: Global variables

2001-11-29 Thread Ashley Yakeley

At 2001-11-29 05:31, Juan Ignacio García García wrote:

I am interested in using global variables (in GHC).

In JVM-Bridge (nearly there!) I use lifted monads to store global
constants, though variables are not hard either. This does mean an extra
function needed to call IO functions, but in my case you'd be calling
mostly my glue functions to Java code, which are in the lifted monad
anyway.

Lifted monads look something like this:

 data MyAction a = MkMyAction ((consts,vars) - (vars,a));
 instance Monad MyAction where etc.

I actually have a class for monads that lift the IO monad:

http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/~checkout~/jvm-bridge/sourc
e/Haskell/IOLiftedMonad.hs?rev=HEADcontent-type=text/plain

--
Ashley Yakeley, Seattle WA


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



Re: Global variables

2001-11-29 Thread Ashley Yakeley

At 2001-11-29 11:13, Ashley Yakeley wrote:

Lifted monads look something like this:

 data MyAction a = MkMyAction ((consts,vars) - (vars,a));
 instance Monad MyAction where etc.

Whoops, should be

 data MyAction a = MkMyAction ((consts,vars) - IO (vars,a));


-- 
Ashley Yakeley, Seattle WA


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



Strictness making it worst?

2001-11-29 Thread Jorge Adriano

Hi, I've just started messing around with strictness.  My goal now is 
understanding when and how to use it.
I began with simple examples like making a strict foldl. 
When trying to sum a list of 6 elements with lazy foldl I'd get a stack 
space overflow, with a strict foldl I was able to sum a list of 1E8 elements 
:)

Then I thought I'd mess with the fibonnaci function. 
I began with:

 fibac :: IntPos - (IntPos,IntPos) - (IntPos,IntPos)
 fibac n (a,b) 
   | n == 0= (a,b)
   | otherwise = fibac (n-1) (b,a+b)


Then I tried:

 sfibac :: IntPos - (IntPos,IntPos) - (IntPos,IntPos)
 sfibac n (a,b) 
| n == 0= (a,b)
| otherwise = sfibac (n-1)   (b, (+b) $! a)

I tried both functions with ghc 5.00.1
The strict version was not only slower, but I'd get stack overflows for 
numbers that worked with the 1st version!! (like 10)

I expect sfibac and fibac work this way:
assuming that 
a+b = c
b+c = d
c+d = e

sfibac:
sfibac 4 (a, b) -
sfibac 3 (b, a+b) -
sfibac 2 (a+b, b+(a+b)) -
sfibac 1 (b+(a+b), (a+b)+(b+(a+b))) -
sfibac 0 ((a+b)+(b+(a+b)), (b+(a+b)) + (a+b)+(b+(a+b)))

now if I had to evaluate the first element I'd get
(a+b)+(b+(a+b)) -
c+(b+c) -
c+d -
e

fibac:
sfibac 4 (a, b) -
sfibac 3 (b, a+b) -
sfibac 2 (c, b+c) -
sfibac 1 (d, c+d) -
sfibac 0 (e, d+e) 


I'd expect sfibac to be faster, but what I find even more strange is the 
stack space overflow in sfibac! why?


Greetings,
J.A.

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



Re: Strictness making it worst?

2001-11-29 Thread Jorge Adriano


 Then I tried:
  sfibac :: IntPos - (IntPos,IntPos) -
  (IntPos,IntPos) sfibac n (a,b)
 
 | n == 0= (a,b)
 | otherwise = sfibac (n-1)   (b, (+b) $! a)


I'm sorry I meant:
 sfibac :: IntPos - (IntPos,IntPos) -
 (IntPos,IntPos) sfibac n (a,b)

| n == 0= (a,b)
| otherwise = sfibac (n-1)   (b, (a+) $! b)


otherwise the reductions would be wrong
 fibac:
 sfibac 4 (a, b) -
 sfibac 3 (b, a+b) -
 sfibac 2 (c, b+c) -
 sfibac 1 (d, c+d) -
 sfibac 0 (e, d+e)

In fact I would expect that using ((a+) $! b) would be better than (b, (+b) 
$! a), but the 1st seemed to be the worst in terms of both speed and stack 
space problems.

J.A.

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