Re: haskell newbie seeking for advice

2003-08-14 Thread Glynn Clements

Jose A.Ortega Ruiz wrote:

 as stated in the subject, i'm a newcomer to haskell programming: i've
 read some tutorials and (portions of) a couple of books and am really
 fascinated with the language. but my haskell coding experience is
 limited to toy programs and short exercises. so i decided to try my
 hand at a small project to really learn haskell and the functional
 programming mindset[1], and i would appreciate to hear your opinions
 and comments on some issues before i start coding:
 
 - build toolchain. i'm used to the autoconfig/automake/make tools for
   C/C++ projects, and to ant for Java stuff. what do haskellers use?
   my initial thought was using a plain Makefile with ghc, but there is
   also hmake and maybe other tools i am missing. what would you use? [2]

There's also ghc --make.

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


Re: Yet Another Monad Tutorial

2003-08-14 Thread Derek Elkins
On Wed, 13 Aug 2003 13:26:34 +0200
blaat blaat [EMAIL PROTECTED] wrote:

I have a long reply, perhaps I'll post it later.  Here's a more
pragmatic short one.

 What did we lose? Well, introspection comes to mind. A monad is
 strange in the sense that, actually, there does not seem to be any
 reason to compute its value since we cannot possibly get anything out
 of it. In case of IO, only the haskell interpreter can. And,
 introspection is a nice thing to have, especially for compiler
 writers. Although I think the benefits in Haskell would be limited, an
 application might be that I could write my own promotion functions on
 my own programs.

Lot's of issues with this paragraph, but here are the questions.  What
do you mean by promotion function?  How would you write it in your
hypothetical Haskell?  How is it related to IO? How do monads and/or the
IO monad in particular cause problems?  Why couldn't the same be done
using monads or why would it be significantly harder if it can be done?

 Think of the following though experiment. What if I would have a
 function unparse:IO a-String which gives the textual representation
 of the specification of the object of type IO a? Clearly, IO is not a
 monad anymore. Moreover, I don't think it would break the purity of
 Haskell. And surely, in case of the IO monad, we can think of better
 manners to break a program down.

Keith has already pointed out the flagrant error here; which I also
point out in my long reply. But again, the questions...

What is unparse supposed to return?  What does it have to do with IO in
particular, i.e. why do I want to unparse IO computations especially? 
Why can't it be done with (or over) the current IO monad?  What other
ways do you want to breakdown a program, still resulting in
understandable behavior, but can't because of the IO monad?

 Hmm, I am rambling. The point is, I think there is no reason to
 discard all alternatives to monads; 

 I believe that central in the
 IO-issue is not the fact that we are using monads for IO - but that we
 can purely create impure programs which do the IO for us ;-), and that
 those do not have to be of the monadic kind.

I have comments for these too, but I'll keep this short.  Basically, I
don't really see how what you want has all that much to do with IO in
general, and I don't see monads get in the way.

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


Re: Editor in Linux for Hint/Helium

2003-08-14 Thread Glynn Clements

Tim Stitt wrote:

 I'm using the Helium interpreter/compiler with the Hint interface within
 Linux. Unfortunately, I want an editor that allows me to jump to the
 row/column of the source when I receive an error.
 
 Does anyone know of a good editor in Linux to do this or the commands for
 Emacs etc. that can be used from within Hint to achieve it?

Emacs and XEmacs allow you to go to a specified line using +number,
e.g.

xemacs +20 foo.txt

loads foo.txt and positions the cursor on line 20. The same syntax
works with emacsclient (Emacs) and gnuclient (XEmacs), which load a
file into an existing XEmacs process, i.e.

gnuclient +20 foo.txt

Emacs requires the server-start command (e.g. in ~/.emacs) before
emacsclient can connect; similarly XEmacs requires gnuserv-start.

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


Re: idiom for producing comma-seperated lists?

2003-08-14 Thread Antony Courtney
Ketil Z. Malde wrote:
Antony Courtney [EMAIL PROTECTED] writes:


-- Example: format a list of strings, using a comma as a seperator:
mkSepStr :: [String] - String
mkSepStr xs = foldrs (\x s - x ++ ,  ++ s)  xs
t0 = mkSepStr []   -- == 
t1 = mkSepStr [hello]-- == hello
t2 = mkSepStr [10,20,30] -- == 10, 20, 30
What do the rest of you do to solve this particular problem?


Uh, concat and intersperse?

Yep, that'll do the trick.

Thanks for all the lightnin-fast responses.  Appologies for overlooking 
this!

	-antony

--
Antony Courtney
Grad. Student, Dept. of Computer Science, Yale University
[EMAIL PROTECTED]  http://www.apocalypse.org/pub/u/antony
___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: Another typing question

2003-08-14 Thread Konrad Hinsen
On Tuesday 05 August 2003 15:23, Wolfgang Jeltsch wrote:

 There probably are ways to achieve this with Haskell's type system. The
 exact solution depends on what exactly you want.

 For just distinguishing between lists of different lengths you could use
 tuples like (a,a) (list of length 2) (a,a,a) (list of length 3) etc.

What would be the advantage to using standard lists? In both cases I'd need 
explicit length checks everywhere.

 A better solution might be:
 data EmptyList element = EmptyList
 data TrueList list element = TrueList element (list element)
 A list of four Ints for example would be represented by a value of type
 TrueList (TrueList (TrueList (TrueList EmptyList))) Int.

Isn't that just the Haskell list type by another name?

 You could define different types for different natural numbers:
 data Zero = Zero
 data Succ number = Succ number
 and do simple arithmetic with them at the type level:
 class Sum a b c | (a, b) - c
 instance Sum 0 a a
 instance Sum a b c = Sum (Succ a) b (Succ c)

That looks interesting, I need to look into multiple parameter classes...

 At the moment, I cannot think of a way of defining a list type which is
 parameterized by such natural types. What I mean is having a type
 List :: * - * - *
 where for our above example of a list of four Ints we would have the type
 List (Succ (Succ (Succ (Succ Zero Int

That's what I would like...

 What I can think of, is an association between our above list types
 (EmptyList and TrueList) and our natural number types by a multi-parameter
 class: class HasLength list length | list - length
 instance HasLength EmptyList Zero
 instance HasLength list length = HasLength (TrueList list) (Succ
 length)

Again those multi-parameter classes... and off I go to the Haskell Web site 
;-)

Thanks for your comments!

Konrad.

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


Re: [newbie] UTF-8

2003-08-14 Thread Marcin 'Qrczak' Kowalczyk
Dnia pon 11. sierpnia 2003 00:49, Wolfgang Jeltsch napisa:

 The main problem is that you need binary I/O. Haskell 98 only provides text
 I/O.

You don't need binary I/O for UTF-8 now; because implementations use 
ISO-8859-1, UTF-8 octets can be faked as characters by (chr . fromIntegral).

 The other point with text I/O is that under Windows the EOF character ^Z is
 treated specially and a conversion between Windows EOLs (^M^J) and Haskell
 EOLs (^J) takes place.

UTF-8 preserves ASCII and doesn't use ASCII bytes for non-ASCII characters,
so the situation is the same as in other encodings and text mode is usually 
fine. It would not be OK for UTF-16.

-- 
   __( Marcin Kowalczyk
   \__/   [EMAIL PROTECTED]
^^ http://qrnik.knm.org.pl/~qrczak/

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


Re: IO Bool - Bool

2003-08-14 Thread Brandon Michael Moore


On Thu, 14 Aug 2003, Wolfgang Jeltsch wrote:

 On Thursday, 2003-08-14, 17:05, CEST, Kevin S. Millikin wrote:
  On Wednesday, August 13, 2003 11:20 PM, Tn X-10n
  [SMTP:[EMAIL PROTECTED] wrote:
is it possible to convert IO Bool to Bool?
 
  Sure.  Which Bool do you want?  True?
 
   toTrue :: IO Bool - Bool
   toTrue x = True
 
  Or False?
 
   toFalse :: IO Bool - Bool
   toFalse x = False

There's also

boolFromIO :: IO Bool - Bool
boolFromIO = boolFromIO

if you want to be even less useful :)

 I wouldn't call these *conversion* functions because they don't look at their
 argument.

  Maybe that's not what you had in mind.

 Surely not.

 Wolfgang

I'm surprise nobody has mentioned unsafePerformIO (:: IO a - a).
As the name suggests, it isn't referentially transparent.

Are you sure you need a function of type IO Bool - Bool? What are you
trying to do?

Brandon


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


Re: idiom for producing comma-seperated lists?

2003-08-14 Thread Ketil Z. Malde
Antony Courtney [EMAIL PROTECTED] writes:

 -- Example: format a list of strings, using a comma as a seperator:
 mkSepStr :: [String] - String
 mkSepStr xs = foldrs (\x s - x ++ ,  ++ s)  xs
 
 t0 = mkSepStr []   -- == 
 t1 = mkSepStr [hello]-- == hello
 t2 = mkSepStr [10,20,30] -- == 10, 20, 30
 
 What do the rest of you do to solve this particular problem?

Uh, concat and intersperse?

Prelude concat $ List.intersperse ,  $ []

Prelude concat $ List.intersperse ,  $ [hello]
hello
Prelude concat $ List.intersperse ,  $ [10,20,30]
10, 20, 30

-kzm
-- 
If I haven't seen further, it is by standing in the footprints of giants
___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe


RE: .. Drowning in stateful, side-effect riddled, spaghetti code? We have the answer. fdps[]c.

2003-08-14 Thread Bayley, Alistair
Hey there!

Stateful side-effect-laden spaghetti programming sucks, and so does the
cost.. feel like your [sic] getting ripped off? ...
We tear up your code and give you and your colleagues a fresh start ..

 - Save you a lot of money by eliminating side-effects
 - Develop new code in substantially reduced time
 - Stop customers/managers calling you on the phone about late delivery
 - Avoid code maintenance debt

... and more!

Why keep dealing with the stress, and headaches, of mainstream programming
styles?

Combine pure and lazy functional programming and get on with your life
today!!

Come here and take a look at how we can help.

http:///www.haskell.org


 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
 Sent: 12 August 2003 08:47
 To: [EMAIL PROTECTED]
 Subject: .. Drowning in debt? We have the answer. fdps[]c.
 
 
 Hey There!
 
 Debt sucks, and so do the repayments.. feel like your getting 
 ripped off? ..
 We tear up your debt and give you and your family a fresh start ..
 
 - Save you a lot of money by eliminating late fees
 - Settle your accounts for a substantially reduced amount
 - Stop creditors calling you on the phone
 - Avoid bankruptcy
 
 ... and more!
 
 Why keep dealing with the stress, and headaches?
 
 Combine your debt into a low interest repayment and
 get on with your life today!!
 
 Come here and take a look at how we can help.
 
 http://[EMAIL PROTECTED]/index.php?N=g


*
The information in this email and in any attachments is 
confidential and intended solely for the attention and use 
of the named addressee(s). This information may be 
subject to legal professional or other privilege or may 
otherwise be protected by work product immunity or other 
legal rules.  It must not be disclosed to any person without 
our authority.

If you are not the intended recipient, or a person 
responsible for delivering it to the intended recipient, you 
are not authorised to and must not disclose, copy, 
distribute, or retain this message or any part of it.
*

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


RE: Database interface

2003-08-14 Thread Tim Docker

[EMAIL PROTECTED] wrote:

 If I may interject, that's precisely how a Scheme DB interface is
 designed. The main function is a left-fold. Not quite though: it
 provides for a premature termination:
 
 A major procedure: DB1:fold-left PROC INITIAL-SEED QUERY-OBJECT

Premature termination sounds like a useful property. I can
see two ways this could be done: keep the previous signature,
and use an exception to exit early, or add a boolean return 
value like the scheme version:

   doquery :: Process - String - (a - b  - IO (b,Bool)) - b - IO b

Any opinions on which alternative wouuld be preferable?

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


[String]-[[Bool]] 2

2003-08-14 Thread Tn X-10n

[String] contains = ["1 0 0","1 0 0","0 1 0"] this [String] is read from a file.
the file shows only: i convert it by using Lines. but i stuck wif the output.
1 0 0
1 0 0
1 0 1
if 1 then False 0 then True
the expected result show be [[False,True,True],[False,True,True],[True,False,True]]

My code is as followed...
 readF :: String - IO () readF fname = do x - (readFile fname) putStr (show(conv(words x))) i can't use lines here because change only accepts "0" or "1". but my file contains spaces.
 change :: String - Bool change "1" = True change "0" = False
 conv :: [String] - [Bool]==unable to declare [[Bool]] conv fname = [(change x)| x - (fname)]
Get free gift vouchers every week with MSN Premium Vouchers
___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: Another typing question

2003-08-14 Thread Wolfgang Jeltsch
On Tuesday, 2003-08-05, 15:22, CEST, Nick Name wrote:
 [...]

  Is there any way to parametrize a type by a value, rather than another
  type? What I would like to do is to define list of length 3 and list of
  length 4 as separate parametrization of the same type, such that I could
  write functions that accept lists (under my new typename) of any length as
  long as parameters have the same length. The goal is to remove the need
  for runtime checks all over the code.

 This is called dependent types and is not a feature of haskell (nor of any
 language that I know); there was cayenne (try a google search) but I don't
 believe it is still mantained.

Well, there are, e.g., Ada and C++ which allow types to be parametrized by 
values. The point is that they obviously still use runtime checks, it's just 
that you don't have to code these checks explicitely.

 BTW, why is there no general interest for such a thing as dependent types?

What negative consequences does their implementation have? I think, sometimes 
they could be quite handy.

 V.

W. ;-)

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


RE: Yet Another Monad Tutorial

2003-08-14 Thread Jeff Newbern
Alistair,

Hhhmmm.  That is an interesting issue, and I am unsure how to treat it
in the tutorial.  I did attempt to explain the ability of the monad to
isolate impure computations, but I think I need to make a better
explanation of what an action is and how it is used.

As for the question of whether using a monad in this way casts Haskell
out of the ranks of the functionally pure, I don't know.  This feels to
me like a debate over personal interpretation, with decent arguments on
both sides.  I think the most accurate thing to say is that it enables
Haskell to incorporate non-pure features without destroying the purity
of the core of the language.

Any suggestions for how best to present this issue to a reader who may
be new to the world of FP?  Should we mention it at all?

Thanks,
Jeff

Alistair Bayley wrote: 
 Thanks. Quite comprehensive.
 
 Peter Van Roy (the Mozart/Oz guy) said this on the PragProg list, and 
 I didn't have the knowledge to respond. It's a point you might want to
 address, perhaps in this section?:
 http://www.nomaware.com/monads/html/laws.html#nowayout

 [Discussion of whether I/O monad makes Haskell impure]

-- 
Jeff Newbern [EMAIL PROTECTED]
Nomaware, Inc.

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


Re: Yet Another Monad Tutorial

2003-08-14 Thread blaat blaat
To many questions, not enough mail. First, thanks for all your replies. 
Second, I stand totally corrected on the fact that we cannot break down 
monads. Functions of type m a-b are called impure, see also 
unsafePerformIO. I am questioning (a) the exact relation between monads, 
monadic IO, IO in general and (b) whether the impure restriction is actually 
a warranted restriction, which relates to, what I find, strange evaluation 
behavior of the IO monad.

What is the difference between putStr a, (putStr a, putStr a), putStr 
(putStr a), putStr (show (putStr a))?

At the moment objects of type IO a _only_ get evaluted when they are the 
_sole_ result of a Haskell program. What kind of strange dichotomy is that? 
Is not the _only_ interpretation of this dichotomy that objects of type IO 
describe impure programs (composed of actions which are only evaluated 
when...)? And, if so, why can't we decompose these programs (before they get 
evaluated)? And, if so, is not the only relation between a monad and doing 
functional IO that there is a monadic manner to construct descriptions of 
impure programs? If so, are there also non-monadic ways which might be 
equally interesting?

As stated by Keith, deriving show for IO is possible.  In such a setting 
putStr (putStr a) I imagine returns putStr \a\, which I find far more 
orthogonal than what we have now. (Have to find the reference still). Does 
this boil down to an impure or a pure decomposition?

From: Derek Elkins [EMAIL PROTECTED]
To: blaat blaat [EMAIL PROTECTED], [EMAIL PROTECTED]
pragmatic short one.
 What did we lose? Well, introspection comes to mind. A monad is
 strange in the sense that, actually, there does not seem to be any
 reason to compute its value since we cannot possibly get anything out
 of it. In case of IO, only the haskell interpreter can. And,
 introspection is a nice thing to have, especially for compiler
 writers. Although I think the benefits in Haskell would be limited, an
 application might be that I could write my own promotion functions on
 my own programs.
Lot's of issues with this paragraph, but here are the questions.  What
do you mean by promotion function?
Example of promotion: map f . map g = map (f . g)

A promotion function would transform objects of type IO a into objects of 
type IO a while performing promotions.

 How would you write it in your
hypothetical Haskell?  How is it related to IO? How do monads and/or the
IO monad in particular cause problems?  Why couldn't the same be done
using monads or why would it be significantly harder if it can be done?
In a monadic approach, I imagine functions like unbind which now would 
break purity.

[..]

 I believe that central in the
 IO-issue is not the fact that we are using monads for IO - but that we
 can purely create impure programs which do the IO for us ;-), and that
 those do not have to be of the monadic kind.
I still stand here (but am totally willing to be corrected on this account 
too). Hmpf, maybe someone more enlightened should write a paper on it.

Cheers, l4t3r

_
MSN 8 with e-mail virus protection service: 2 months FREE*  
http://join.msn.com/?page=features/virus

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


Re: Yet Another Monad Tutorial

2003-08-14 Thread Antony Courtney
Peter G. Hancock wrote:
Jeff Newbern wrote (on Tue, 12 Aug 2003 at 17:20):
?
 The functions exported from the IO module do not
 perform I/O themselves. They return I/O actions, which describe an I/O
 operation to be performed. The I/O actions are combined within the IO
 monad (in a purely functional manner) to create more complex I/O
 actions, resulting in the final I/O action that is the main value of the
 program. The result of the Haskell compiler is an executable function
 incorporating the main I/O action. Executing the program applies this
 ultimate I/O action to the outside world to produce a new state of the
 world. 

That seems to me the wrong thing to say.  There is no application.  Whether
or not the word is put in quotes, it is something involving a function
and an argument.  An IO action is not a function.
So then, in your view, what *is* an IO action?

One conceptual model is that an IO action with type (IO a) denotes a 
function of type World - (World,a).  Given that model, applying an IO 
action to the external world seems like a perfectly reasonable account 
of executing such an action.

	-antony

--
Antony Courtney
Grad. Student, Dept. of Computer Science, Yale University
[EMAIL PROTECTED]  http://www.apocalypse.org/pub/u/antony
___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe


AW: Yet Another Monad Tutorial

2003-08-14 Thread Markus . Schnell
 The overall message I have taken from your post is that I need to
 be more precise to convey the correct information and avoid confusion
 (or worse, misinformation).

As I understood it, the tutorial should be instructive. So I would not
try to be more precise at the beginning, because too much detail would 
lead to confusion for a beginner.
Start with something like I'm now telling you some lies, which make
it easier to grasp the idea of the monad, but further down the road, 
I'll reexplain some concepts and be more precise there.
This was done by Don Knuth for the Typesetting-Books and it worked
very well (for me).

I hope this is a sensible idea.

Markus

--
Markus Schnell
Infineon Technologies AG, CPR ET
Tel +49 (89) 234-20875
___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe


RE: Database interface

2003-08-14 Thread oleg

 I'll probably generalise the query function to do a fold, rathen than
 always accumulate a list:
 doquery :: Process - String - (a - b  - IO b) - b - IO b

If I may interject, that's precisely how a Scheme DB interface is
designed. The main function is a left-fold. Not quite though: it
provides for a premature termination:

A major procedure: DB1:fold-left PROC INITIAL-SEED QUERY-OBJECT

A QUERY-OBJECT (which in this implementation is a list of fragments
that make a SQL statement, in the reverse order -- without the
terminating semi-colon) is submitted to the database, using the
default database connection.

PROC is a procedure: SEED COL COL ...
The procedure PROC takes 1+n arguments where n is the number of
columns in the the table returned by the query.  The procedure PROC
must return two values: CONTINUE? NEW-SEED

The query is executed, and the PROC is applied to each returned row in
order. The first invocation of PROC receives INITIAL-SEED as its first
argument. Each following invocation of PROC receives as the first
argument the NEW-SEED result of the previous invocation of PROC.  The
CONTINUE? result of PROC is an early termination flag. If that flag is
returned as #f, any further applications of PROC are skipped and
DB1:fold-left finishes.  The function DB1:fold-left returns NEW-SEED
produced by the last invocation of PROC. If the query yielded no rows,
DB1:fold-left returns the INITIAL-SEED.

Thus DB1:fold-left is identical to the left fold over a sequence,
modulo the early termination.

There are a few minor variants of the above procedure, optimized for
common particular cases: a query that is expected to return at most
one row, and a query that expects to return at most one row with
exactly one column. The latter query has the same interface as a
lookup in a finite map.

The QUERY-OBJECT is of coursed not built by hand. There is a
domain-specific language (which greatly resembles the source language
and makes some use of quasi-quotation) whose result is a query
object. Therefore, I can write both the query and the handlers of the
query result using the same syntax.

The premature termination is important. Database connections and
cursors are too precious resources to leave them for the garbage
collector to finalize. More discussion and pointers can be found at

http://srfi.schemers.org/srfi-44/mail-archive/msg00023.html

The interface has been used in an industrial application.
___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: Yet Another Monad Tutorial

2003-08-14 Thread Dominic Fox
 I suspect that tutorials should at some point mention some
 definitions of monads, monoids et al --- since this is where the power
 (sorry, QA) comes from.

I was reading an overview-for-non-specialists of category theory earlier
today, and was surprised by the familiarity of much of it - based on the
little Haskell I'd learned. What it didn't have, and what I'd still like to
read, is an overview-for-non-specialists of monads and monoids, as this was
one bit of the mathematical terminology used by Haskell that was rather
opaque to me - I think of a monad as a) a sort of a self-contained
something-or-other in Liebniz's philosophy, and b) a scary baddy in the ABC
Warriors comic strip published by 2000AD (I'm not making this up...).

Dominic

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


Re: [String] - [[Bool]]

2003-08-14 Thread tahara
 i am new wif haskell, i would like to know how can i get a list of string and
 convert it to a list of a list of bool
 
 [String]- [[Bool]]
 
 for example a [String] [0 1 0 1 0 1,0 0 0 0 0 0 ,1 0 0 0 1 0]
 
 it return true if 0 and false if 1. the [String] is read from a
 file.

map (\x - map (==0) x) $ map words [0 1 0 1 0 1,0 0 0 0 0 0 ,1 0 0 0 1 0]
--
Yoshinori Tahara [EMAIL PROTECTED]
___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe


haskell newbie seeking for advice

2003-08-14 Thread Jose A . Ortega Ruiz

hi all,

as stated in the subject, i'm a newcomer to haskell programming: i've
read some tutorials and (portions of) a couple of books and am really
fascinated with the language. but my haskell coding experience is
limited to toy programs and short exercises. so i decided to try my
hand at a small project to really learn haskell and the functional
programming mindset[1], and i would appreciate to hear your opinions
and comments on some issues before i start coding:

- build toolchain. i'm used to the autoconfig/automake/make tools for
  C/C++ projects, and to ant for Java stuff. what do haskellers use?
  my initial thought was using a plain Makefile with ghc, but there is
  also hmake and maybe other tools i am missing. what would you use? [2]

- graphics toolkit. one of my programs will be a GUI. there seems to
  be a lot of choice here: gtk2hs looks nice (as used in hircules) and
  fudgets seems to have a pretty interesting and well-documented
  architecture (which covers also client/server programming: i'll be
  using a client/server architecture too) but its widgets are uglier
  and look alien in current linux desktops. i'd like to have a
  fudgets-gtk framework of sorts :) and then, there is htoolkit,
  Object I/O and whatnot... any recommendations?

- TCP/IP stuff. i will have a client/server architecture with TCP/IP
  as the transport protocol. other than fudgets, i'm not aware of any
  haskell framework for IPC: am i missing something?

- XML. i'll be handling XML documents, and HaXml seems to me an
  excellent candidate to cover this area, but, of course, i'm very
  interested in hearing of alternatives...
  
thanks a lot for your help!

cheers,
jao

Footnotes: 
[1]  if that matters, the project will consist on a set of utilities
for handling a document metadata database, based upon the OMF standard.

[2] my project will consist of several executables, sharing a set of
common libraries and, therefore, i plan to use (if possible) a
non-flat directory layout.

-- 
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare. - Blair Houghton.
___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: Yet Another Monad Tutorial

2003-08-14 Thread Jeff Newbern
Peter,

Thank you for criticism.  This is exactly the kind of feedback I need.

The overall message I have taken from your post is that I need to
be more precise to convey the correct information and avoid confusion
(or worse, misinformation).

I should have said that a function which performs a computation
in the I/O monad must have IO as the outermost constructor
in its return type.  I think that is more precise (and correct :-).

As for the later text concerning application of the top-level I/O
action, I will need to think for a while to see how I can word this
more clearly.  If you (or anyone else) have ideas, I'd like to hear
them.

Thanks again,
Jeff

On Tue, 2003-08-12 at 18:24, Peter G. Hancock wrote:
  Jeff Newbern wrote (on Tue, 12 Aug 2003 at 17:20):
 (proposed revisions)
 
  In the section No Way Out:
  --
  The IO monad is a familiar example of a one-way monad in Haskell.
  Because you can't escape from the IO monad, it is impossible to write a
  function that does a computation in the IO monad but returns a
  non-monadic value. 
 
 I wouldn't say that, as it is inaccurate.  Of course you can return a
 value of _some_ monadic type eg. (Maybe ...).
 
  Not only are functions of the type IO a - a
  impossible to create, 
 
 You can quite easily write a function of type IO (IO a) - IO a, which
 is a special case of that type. 
 
  but any function whose result type does not
  contain the IO type constructor is guaranteed not to use the IO monad.
 
 That's rather vague: what does it mean for a function to use a monad?
 
  Other monads, such as List and Maybe, do allow values out of the monad.
  So it is possible to write non-monadic functions that internally do
  computations in those monads. The one-way nature of the IO monad also
  has consequences when combining monads, a topic that is discussed in
  part III.
  --
 
 In summary, I've only a vague idea of what you are trying to say.  If you
 can't reformulate it more precisely, don't add the above stuff.
 
  and a little farther down:
 
  --
  Some people argue that using monads to introduce non-pure features into
  Haskell disqualifies it from claiming to be a pure functional language.
  This subtle question   not particularly relevant to the practical
  programmer   is revisited in the context of the I/O monad later in the
  tutorial.
  --
 
 That's fair enough.  I don't think the question is so much subtle as
 religious, as we might expect from the terminology of purity. 
 
  Later, in the section on the I/O monad:
  --
  In Haskell, the top-level main function must have type IO (), so that
  programs are typically structured at the top level as an
  imperative-style sequence of I/O actions and calls to functional-style
  code. Revisiting the debate about the purity of Haskell (in a functional
  sense), it is important to note that the IO monad only simulates
  imperative-style I/O. 
 
 That (about simulation) seems weak.  A simulation isn't a vague syntactic 
 resemblance.
 
  The functions exported from the IO module do not
  perform I/O themselves. They return I/O actions, which describe an I/O
  operation to be performed. The I/O actions are combined within the IO
  monad (in a purely functional manner) to create more complex I/O
  actions, resulting in the final I/O action that is the main value of the
  program. The result of the Haskell compiler is an executable function
  incorporating the main I/O action. Executing the program applies this
  ultimate I/O action to the outside world to produce a new state of the
  world. 
 
 That seems to me the wrong thing to say.  There is no application.  Whether
 or not the word is put in quotes, it is something involving a function
 and an argument.  An IO action is not a function.
 
  This occurs only once per execution of the program, and since the
  state of the world changes for each execution, the issue of purity is
  neatly side-stepped.
  --
 
 By the program, I think you mean the IO action.  I think it is right to
 speak of the action as something that is executed.  Execution may involve
 (side-effect free) calculation; but execution is something essentially 
 different from calculation, not an impure form of it.
 
 
 I'm sorry to sound negative -- it's just that you invited criticism.
 Your pages seem generally of a very high quality to me.  Sorry not
 to be more constructive too. 
 
 Peter Hancock
-- 
Jeff Newbern [EMAIL PROTECTED]
Nomaware, Inc.

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


Re: Another typing question

2003-08-14 Thread Jon Cast
 On Tuesday, 2003-08-05, 15:22, CEST, Nick Name wrote:

snip

  This is called dependent types and is not a feature of haskell
  (nor of any language that I know); there was cayenne (try a google
  search) but I don't believe it is still mantained.

snip

  BTW, why is there no general interest for such a thing as dependent
  types?

 What negative consequences does their implementation have?

It depends on whether you just want to write functions to take in values
of such types, or whether you want to write functions to return values
of such types.  Doing the former uses dependant products, which would
require a significant extension to GHC's guts, but not (AIUI) inherently
unpleasant.  Doing the latter (AIUI) essentially requires dependant
sums.  Basically, a family of types A_i parameterized by a value i :: I
is written, for long-honored traditional reasons too complex to get into
here, Sigma i::I.A_i.  Now, if you have such dependant sums, there's a
bad interaction with polymorphism: either you must have a type alpha
which cannot appear in a family of types A_i in a dependant sum, or, for
any function f :: alpha - alpha, there exists a type beta such that f
cannot be aplied at either beta or Sigma i::Int.beta.  Clear?

The alternative, btw., is to have both dependant sums and an undecidable
type-checking problem.

 I think, sometimes they could be quite handy.

Sure.  Sarcastic comment censored.

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


Re: IO Bool - Bool

2003-08-14 Thread Adrian Hey
On Thursday 14 August 2003 06:20, Tn X-10n wrote:
 htmldiv style='background-color:'DIV
 PBRhai guys/Pis it possible to convert IO Bool to
 Bool?/DIV/divbr clear=allhrGet 10mb of e-mail space with a
 href=http://g.msn.com/8HMTENSG/2737??PS=;MSN Hotmail Extra Storage/a at
 only S$36 per year including GST/html

It makes no sense to convert an IO Bool to a Bool. If something
has type IO Bool that means it is an action which will get a
Bool from the outside world. It cannot be converted into a Bool.

If you want to use the action to get a Bool from the outside world
you should invoke the action in somewhere in the IO part of your code,
like this..

do ...
   boolVal - ioBoolAction
   ...

Regards
--
Adrian Hey


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


Fwd: Re: Yet Another Monad Tutorial

2003-08-14 Thread blaat blaat

From: Derek Elkins [EMAIL PROTECTED]
blaat blaat [EMAIL PROTECTED] wrote:
[...]

 However, given that observation, the fact that IO is a monad I find to
 be a _rather arbitrary design decision_; why not define a small term
 language which may be passed to the OS?
That would be confusing to use or restrictive (unless done exceedingly
well perhaps), it would be awkward to define, and it would pretty much
require arbitrary design decisions (what should be included in this
language? what are it's semantics? etc).

 Why not have (some limited)
 introspection on programs which we build?
It would be round-about in both implementation and use to do this.
Nevertheless, you can easily view the IO monad as an imperative language
-embedded- in Haskell.  Even when writing mostly imperative code
Haskell gives you much more flexibility and protection than many
imperative languages, especially the more popular ones.
[...]

 Are we missing out on usefull stuff?

No, but if we were, it'd be trivial to test/get it with an appropriate
top-level runTheProgram IO computation definable in Haskell today.
Trivial to test I fully agree with; however, to the missing out on usefull 
stuff I am not convinced. Please allow me to continue my trolling.

To use the IO monad for impure calculations is, of course, a design 
decision. It is arbitrary to the point that I have the freedom not to agree 
with it; but hey, even I know the thing works ;-).

The key point to my email was that doing impure IO possibly has little to do 
with a monadic style of programming but with the fact that we can 
functionally construct a description of an impure program which is evaluated 
_only_ when delivered as a sole result of a Haskell computation. I find that 
somewhat odd; but not to the point I cannot live with it ;-)

About the indirectness issue. The benefit of choosing a monad is clear - the 
evaluation/rewrite of an action corresponds directly with an impure 
subroutine call. Moreover, the action can be discarded and, as you pointed 
out, the description of these impure subroutine calls are trivially embedded 
directly into Haskell - giving typesafety as a reward. It is both effective 
and efficient.

Great Hail to the monad!

Hmmm, uhm, but let's think further...

What did we lose? Well, introspection comes to mind. A monad is strange in 
the sense that, actually, there does not seem to be any reason to compute 
its value since we cannot possibly get anything out of it. In case of IO, 
only the haskell interpreter can. And, introspection is a nice thing to 
have, especially for compiler writers. Although I think the benefits in 
Haskell would be limited, an application might be that I could write my own 
promotion functions on my own programs.

Think of the following though experiment. What if I would have a function 
unparse:IO a-String which gives the textual representation of the 
specification of the object of type IO a? Clearly, IO is not a monad 
anymore. Moreover, I don't think it would break the purity of Haskell. And 
surely, in case of the IO monad, we can think of better manners to break a 
program down.

Hmm, I am rambling. The point is, I think there is no reason to discard all 
alternatives to monads; I believe that central in the IO-issue is not the 
fact that we are using monads for IO - but that we can purely create impure 
programs which do the IO for us ;-), and that those do not have to be of the 
monadic kind (with all respect to the baffling ingenuity of the invention).

Cheers,
 l4t3r
_
Protect your PC - get McAfee.com VirusScan Online  
http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963

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


Outlook

2003-08-14 Thread birene
hey there, i thought you'd like to check this out

You really owe it to yourself and your family to take a look,

With the money you save, put it towards a new car!

---

http://btrack.iwon.com/r.pl?redir=http://[EMAIL PROTECTED]/index.asp?RefID=198478

---





for no more http://[EMAIL PROTECTED]/auto/index.htm
___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: Yet Another Monad Tutorial

2003-08-14 Thread Jeff Newbern
Hello,

I have put up all-in-one archives of the tutorial for people who
prefer to read it offline.

http://www.nomaware.com/monads/monad_tutorial.tgz

and

http://www.nomaware.com/monads/monad_tutorial.zip

Thanks,
Jeff Newbern
[EMAIL PROTECTED]


__
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com
___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: Database interface

2003-08-14 Thread Thomas L. Bevan
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

 I still want to use HaskellDB (or at least the relational calculus part of
 it), so I was thinking of splitting it into two pieces: a library that
 submits SQL queries and returns the results (database interface), and a
 library that constructs queries with the relational calculus and generates
 SQL from them. Obviously the database interface must be written for each
 DBMS product, while the relational calculus library ought to be independent
 of DBMS (although it might be wise to have SQL compatibility flags for the
 SQL it generates. For example: Oracle 8 (what I'm using now) only supports
 SQL-92).

Ideally, we would have the following.

1/ A high level combinator library for relational calculus built on,

2/ A standard low-level Haskell API 
 i.e. functions like Connection - String - ( a - b - IO b) - IO b

3/ Database specific bindings.

The problem is that projections and cartesian products generate new types, at 
least in the way it was done in HaskellDB. The form the calculus takes would 
need to be substantially reworked.

Tom
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.2.2 (GNU/Linux)

iD8DBQE/O6DBYha8TWXIQwoRAmkCAKCwZkNpU3TjX5bj7rOZHx5DXRjPhwCgihnY
sAWwEKX+5hZ1Tiu4wfSGo7Y=
=ALnJ
-END PGP SIGNATURE-

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


Re: IO Bool - Bool

2003-08-14 Thread Wolfgang Jeltsch
On Thursday, 2003-08-14, 17:05, CEST, Kevin S. Millikin wrote:
 On Wednesday, August 13, 2003 11:20 PM, Tn X-10n
 [SMTP:[EMAIL PROTECTED] wrote:
   is it possible to convert IO Bool to Bool?

 Sure.  Which Bool do you want?  True?

  toTrue :: IO Bool - Bool
  toTrue x = True

 Or False?

  toFalse :: IO Bool - Bool
  toFalse x = False

I wouldn't call these *conversion* functions because they don't look at their 
argument.

 Maybe that's not what you had in mind.

Surely not. 

Wolfgang

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


Re: Yet Another Monad Tutorial

2003-08-14 Thread Ross Paterson
On Tue, Aug 12, 2003 at 03:04:39PM -0400, Antony Courtney wrote:
 So then, in your view, what *is* an IO action?
 
 One conceptual model is that an IO action with type (IO a) denotes a 
 function of type World - (World,a).

But the IO monad is not a state monad, because other agents may change
the state of the world while a Haskell program is running.

It's more accurate to say that the program returns an action to be
executed by the environment:

data IO a = Return a | Invoke (SysCall (IO a))
data SysCall r
= GetChar (Char - r)
| PutChar Char r
| ...

In addition to the usual arguments, the system call is given a return
continuation to enter on completion.  (This was the model of interactive
I/O used by Moggi in An Abstract View of Programming Languages, and
is also used by Fudgets.)  Of course the interpretation the environment
places on GetChar, etc is outside of the functional world.

That simple model omits exceptions.  One way of adding them is

data IO a
= Return a
| Error IOError
| Invoke (SysCall (IO a)) (IOError - IO a)
___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe


RE: IO Bool - Bool

2003-08-14 Thread Kevin S. Millikin
On Wednesday, August 13, 2003 11:20 PM, Tn X-10n 
[SMTP:[EMAIL PROTECTED] wrote:
  is it possible to convert IO Bool to Bool?

Sure.  Which Bool do you want?  True?

 toTrue :: IO Bool - Bool
 toTrue x = True

Or False?

 toFalse :: IO Bool - Bool
 toFalse x = False

Maybe that's not what you had in mind.


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


RE: Yet Another Monad Tutorial

2003-08-14 Thread Bayley, Alistair
 From: Wolfgang Jeltsch [mailto:[EMAIL PROTECTED]
 
 For example, the function readFile is pure. For a specific 
 string s the 
 expression readFile s always yields the same result: an I/O 
 action which 
 searches for a file named s, reads its content and takes this 
 content as the 
 result of the *action* (not the expression).

What about getChar? This is a function which takes no arguments, yet returns
a (potentially) different value each time. I know, I know: it returns an IO
action which reads a single char from the terminal and returns it.

Is the IO monad the only one (currently) in which you would say that it
returns an action, which is then executed by the runtime system? I would
have thought that monads that are not involved in IO (e.g. State) would be
pure in the sense that Van Roy was thinking. You wouldn't need to describe
functions in them as returning an action.


*
The information in this email and in any attachments is 
confidential and intended solely for the attention and use 
of the named addressee(s). This information may be 
subject to legal professional or other privilege or may 
otherwise be protected by work product immunity or other 
legal rules.  It must not be disclosed to any person without 
our authority.

If you are not the intended recipient, or a person 
responsible for delivering it to the intended recipient, you 
are not authorised to and must not disclose, copy, 
distribute, or retain this message or any part of it.
*

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


Re: IO Bool - Bool

2003-08-14 Thread Keith Wansbrough
 PBRhai guys/Pis it possible to convert IO Bool to Bool?

No, it's not... and for good reason!  See the discussion at

http://www.haskell.org/hawiki/ThatAnnoyingIoType

and

http://www.haskell.org/hawiki/UsingIo

In general, the HaWiki has answers to lots of newbie questions like 
this - you might find it useful to peruse (although you should 
certainly continue to ask questions here too - we're a pretty friendly 
bunch!).

Best wishes,

--KW 8-)
-- 
Keith Wansbrough [EMAIL PROTECTED]
http://www.cl.cam.ac.uk/users/kw217/
University of Cambridge Computer Laboratory.

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


Re: IO Bool - Bool

2003-08-14 Thread Wolfgang Jeltsch
On Thursday, 2003-08-14, 07:20, CEST, Tn X-10n wrote:
 hai guys

 is it possible to convert IO Bool to Bool?

No. The reason for introducing the IO type is to preserve the purity of 
Haskell, i.e., to ensure that expression evaluation doesn't depend on the 
state of the outside world and doesn't alter this state.*) Allowing a 
conversion from IO t to t would nullify this.

As you might have noticed, there was (or still is) a discussion about yet 
another monad tutorial on The Haskell Cafe. Some of the messenges and, above 
all, the monad tutorial itself may help you understand how I/O in Haskell 
works. There is not a quick answer to your question like: This way you 
convert an IO Bool to a Bool. You will have to do some reading to understand 
the basic ideas of I/O in Haskell. They are quiet different from what you 
might know from other programming languages.

Wolfgang

*) This is at least how I would formulate it, others would probably phrase it 
a bit different. ;-)

P.S.: Would you mind to configure your mail client such that your mails also 
contain a plain text variant of your message?

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


Re: Yet Another Monad Tutorial

2003-08-14 Thread Derek Elkins
On Wed, 13 Aug 2003 09:44:36 +0200 
blaat blaat [EMAIL PROTECTED] wrote:

 Hmmm, I personally always thought of the IO monad as being a synonym
 for Program 

So.  What is a Program?

[...]

 For what is the interpretation of an object of type IO a? Well, it is
 a bit of a hack atop of Haskell, isn't it? 

Not for the reasons you describe below.

 If we return a complex type
 with an IO a object in it, the object cannot be evaluated, but if we
 return a IO object solely (program), the program get evaluated (passed
 to the (Haskell)-OS).

 However, given that observation, the fact that IO is a monad I find to
 be a _rather arbitrary design decision_; why not define a small term
 language which may be passed to the OS? 

That would be confusing to use or restrictive (unless done exceedingly
well perhaps), it would be awkward to define, and it would pretty much
require arbitrary design decisions (what should be included in this
language? what are it's semantics? etc).

 Why not have (some limited)
 introspection on programs which we build?

It would be round-about in both implementation and use to do this. 
Nevertheless, you can easily view the IO monad as an imperative language
-embedded- in Haskell.  Even when writing mostly imperative code
Haskell gives you much more flexibility and protection than many
imperative languages, especially the more popular ones.

[...]

 Are we missing out on usefull stuff?

No, but if we were, it'd be trivial to test/get it with an appropriate
top-level runTheProgram IO computation definable in Haskell today.

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


[String]-[[Bool]]

2003-08-14 Thread Tn X-10n

a string is a list of Char which can be '1', '0', '/n'and spaces ' '. ["1 0 1 0 0 1 /n"]Get free gift vouchers every week with MSN Premium Vouchers
___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe


Yet Another Monad Tutorial

2003-08-14 Thread blaat blaat
Hmmm, I personally always thought of the IO monad as being a synonym for 
Program (or, for functions wich return an IO a, a subroutine with 
side-effects which returns a value of type a).

We can build mini programs (like putStr), and compose them in a sequential 
manner (including something alike assignment).

I personally use the following analogy. Someone, somewhere, sometime must 
have thought, Great, if I cannot do imperative programming directly, I can 
damned well create imperative programs and have _them_ evaluated, grumbl! 
And with that thought, he solved numerous problems ;-)

Can we really make cheese out of it? (Dutch saying)

For what is the interpretation of an object of type IO a? Well, it is a bit 
of a hack atop of Haskell, isn't it? If we return a complex type with an IO 
a object in it, the object cannot be evaluated, but if we return a IO object 
solely (program), the program get evaluated (passed to the (Haskell)-OS).

However, given that observation, the fact that IO is a monad I find to be a 
_rather arbitrary design decision_; why not define a small term language 
which may be passed to the OS? Why not have (some limited) introspection on 
programs which we build? Purity will never be broken since the only way to 
get a program evaluated is to pass it to the Haskell-OS. Are we missing 
out on usefull stuff?

Hehe... God, we might as well just generate impure graph rewrite rules, 
or plain C for that matter ;-).

Cheers, l4t3r

ps: Mind you, nothing wrong with that IO monad. It works, why break it. ;-)

_
STOP MORE SPAM with the new MSN 8 and get 2 months FREE* 
http://join.msn.com/?page=features/junkmail

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


RE: Database interface

2003-08-14 Thread Tom Pledger
Tim Docker writes:
 | Tom Pledger writes:
 | 
 |   This is a pretty good way to stop those nasty vague SQL row types at
 |   the Haskell border and turn them into something respectable.  Perhaps
 |   it would even be worth constraining the extracted type to be in
 |   DeepSeq
 |  
 |  doquery :: (DeepSeq v) =
 | Process - String - IO v - IO [v]
 | 
 | Can you explain what the constraint does here?

Yes.  It soothes my superstitious fears about unsafeInterleaveIO.

I imagined that:

  - doquery (like getContents) uses unsafeInterleaveIO to make the
resulting list lazy, i.e. avoid grabbing all the rows at the
outset,

  - the unsafe interleaving would *somehow* get into the extraction
action, and

  - the current row could be overwritten while some stringv (etc.)
actions on it were yet to happen, so

  - a good safety measure would be to force evaluation (hence DeepSeq)
of each list element before overwriting the current row.

But now that you ask, I think it's possible for doquery to stop the
unsafeInterleaveIO from leaking into the extraction action, so the
DeepSeq would only protect users from shooting themselves in the foot
with weird queries like this

doquery p select s from t (unsafeInterleaveIO (stringv p 1))
-- DeepSeq would allow doquery to undo the effect of unsafeInterleaveIO

or this

[a1, a2] - doquery p select s from t (return (stringv p 1))
s2 - a2
s1 - a1
-- DeepSeq would disallow this at compile time

- Tom

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


Re: haskell newbie seeking for advice

2003-08-14 Thread Iavor Diatchki
hi,

Jose A.Ortega Ruiz wrote:
hi all,

as stated in the subject, i'm a newcomer to haskell programming: i've
read some tutorials and (portions of) a couple of books and am really
fascinated with the language. but my haskell coding experience is
limited to toy programs and short exercises. so i decided to try my
hand at a small project to really learn haskell and the functional
programming mindset[1], and i would appreciate to hear your opinions
and comments on some issues before i start coding:
- build toolchain. i'm used to the autoconfig/automake/make tools for
  C/C++ projects, and to ant for Java stuff. what do haskellers use?
  my initial thought was using a plain Makefile with ghc, but there is
  also hmake and maybe other tools i am missing. what would you use? [2]
ghc --make is also quite useful (the ghc documentation is at: 
haskell.org/ghc).

- graphics toolkit. one of my programs will be a GUI. there seems to
  be a lot of choice here: gtk2hs looks nice (as used in hircules) and
  fudgets seems to have a pretty interesting and well-documented
  architecture (which covers also client/server programming: i'll be
  using a client/server architecture too) but its widgets are uglier
  and look alien in current linux desktops. i'd like to have a
  fudgets-gtk framework of sorts :) and then, there is htoolkit,
  Object I/O and whatnot... any recommendations?
this is a tough one...  i think most of the libraries have some quircks. 
 there are a few recent attempts to get a good library going, but i 
haven't had a chance to try them (the latest as far as i know are 
wxHaskell and hToolkit).  i have a bit of experience with fudgets and it 
works.  it is however getting a bit old (hence the funny look, and 
programming it is sometimes a bit weird).  it would be nice to have a 
new fudgets, but it seems like a rather large task.

- TCP/IP stuff. i will have a client/server architecture with TCP/IP
  as the transport protocol. other than fudgets, i'm not aware of any
  haskell framework for IPC: am i missing something?
ghc has a bunch of libraries for networking.  they are a bit low level, 
but if you are used to writing networking applications in C, they are 
fine (and perhaps better).  see the library documentation of ghc.

- XML. i'll be handling XML documents, and HaXml seems to me an
  excellent candidate to cover this area, but, of course, i'm very
  interested in hearing of alternatives...
never used any of those.

--
==
| Iavor S. Diatchki, Ph.D. student   |
| Department of Computer Science and Engineering |
| School of OGI at OHSU  |
| http://www.cse.ogi.edu/~diatchki   |
==
___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe


Database interface

2003-08-14 Thread Tom Pledger
Thomas L. Bevan writes:
 | Does anyone know if there is work being done on a standard Haskell
 | database interface.

I suspect that there isn't.  The pattern seems to be that someone gets
an interface working well enough for some purposes, and perhaps shares
it, but is too modest and/or busy to put it forward as a standard.

For a row extraction mechanism, I'd vote for passing an extraction
function (or IO action) to the main query function, like Tim Docker
described last month.

http://haskell.cs.yale.edu/pipermail/haskell-cafe/2003-July/004684.html

This is a pretty good way to stop those nasty vague SQL row types at
the Haskell border and turn them into something respectable.  Perhaps
it would even be worth constraining the extracted type to be in
DeepSeq

doquery :: (DeepSeq v) =
   Process - String - IO v - IO [v]

so that the interface clearly may confine its attention to one row at
a time per cursor.

- Tom

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


RE: Database interface

2003-08-14 Thread Tim Docker
Tom Pledger writes:

  This is a pretty good way to stop those nasty vague SQL row types at
  the Haskell border and turn them into something respectable.  Perhaps
  it would even be worth constraining the extracted type to be in
  DeepSeq
 
 doquery :: (DeepSeq v) =
Process - String - IO v - IO [v]

Can you explain what the constraint does here?

Although I haven't touched the db interface in the meantime, when/if I
do,
I'll probably generalise the query function to do a fold, rathen than
always
accumulate a list:

doquery :: Process - String - (a - b  - IO b) - b - IO b

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


Re: [String]-[[Bool]] 2

2003-08-14 Thread Ketil Z. Malde
Tn X-10n [EMAIL PROTECTED] writes:

 change :: String - Bool
 change 1  = True
 change 0  = False

  conv :: [String] - [Bool]==unable to declare [[Bool]]

Again: a String is a list of ?

-kzm
-- 
If I haven't seen further, it is by standing in the footprints of giants
___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [String] - [[Bool]]

2003-08-14 Thread Ketil Z. Malde
Tn X-10n [EMAIL PROTECTED] writes:

 i am new wif haskell, i would like to know how can i get a list of
 string and convert it to a list of a list of bool

 [String]- [[Bool]]

What is the definition of a String?  (I.e. what is a String a list of?)
Write a function to convert one of these to the corresponding Bool.

Then write a function that uses that function to convert a String to a
list of Bool.

And then, in a similar manner, apply it to a list of Strings to
generate a list of lists of Bool.

-kzm
-- 
If I haven't seen further, it is by standing in the footprints of giants
___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe


RE: Yet Another Monad Tutorial

2003-08-14 Thread Bayley, Alistair
 -Original Message-
 From: Jeff Newbern [mailto:[EMAIL PROTECTED]
 
 Alistair,
 
 Hhhmmm.  That is an interesting issue, and I am unsure how to treat it
 in the tutorial.  I did attempt to explain the ability of the monad to
 isolate impure computations, but I think I need to make a better
 explanation of what an action is and how it is used.
 
 As for the question of whether using a monad in this way casts Haskell
 out of the ranks of the functionally pure, I don't know.  
 This feels to
 me like a debate over personal interpretation, with decent 
 arguments on
 both sides.  I think the most accurate thing to say is that it enables
 Haskell to incorporate non-pure features without destroying the purity
 of the core of the language.


The interesting point for me is: you can't escape from the IO monad, but you
can from others. You can use non-IO functions from IO functions, but you
can't use IO functions from non-IO functions. AFAICT, this is not true of
all monads; as Wolfgang said, you can write a function that uses monadic
values but returns a non-monadic (pure) value.

You (sort of) explain this in the first two paragraphs of No way out, but
things that might help are:
 - two example lists: of one-way monads (IO), and others (List, Maybe)
 - non-monadic function using monadic values (
http://www.nomaware.com/monads/html/listmonad.html#example )


 Any suggestions for how best to present this issue to a reader who may
 be new to the world of FP?  Should we mention it at all?

I think you should mention it in a monad tutorial, hence the request. It
will help (has helped) me understand a little more about monads.


*
The information in this email and in any attachments is 
confidential and intended solely for the attention and use 
of the named addressee(s). This information may be 
subject to legal professional or other privilege or may 
otherwise be protected by work product immunity or other 
legal rules.  It must not be disclosed to any person without 
our authority.

If you are not the intended recipient, or a person 
responsible for delivering it to the intended recipient, you 
are not authorised to and must not disclose, copy, 
distribute, or retain this message or any part of it.
*

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


RE: Database interface

2003-08-14 Thread Bayley, Alistair
 -Original Message-
 From: Thomas L. Bevan [mailto:[EMAIL PROTECTED]
 
 This type of interface is fine as far as it goes, but there is only 
 ever a loose coupling between the database and application.
 
 The HaskellDB work implemented a relational calculus that ensured
 that all queries were checked at compile time for validity against
 a particular database.

HaskellDB doesn't actually type check against the database; it checks
against types defined in a module, which is generated from the database. If
you change the database, then you need to regenerate the module.

I prefer the approach of passing an extraction function/IO action to the
interface. This is the approach taken by HaSql, HaskellDB (I think, although
it's so indirect I find it hard to follow), and Tim Docker's Sybase library,
and it's the design I intend to use for my Oracle library (when I get around
to it).

I still want to use HaskellDB (or at least the relational calculus part of
it), so I was thinking of splitting it into two pieces: a library that
submits SQL queries and returns the results (database interface), and a
library that constructs queries with the relational calculus and generates
SQL from them. Obviously the database interface must be written for each
DBMS product, while the relational calculus library ought to be independent
of DBMS (although it might be wise to have SQL compatibility flags for the
SQL it generates. For example: Oracle 8 (what I'm using now) only supports
SQL-92).


*
The information in this email and in any attachments is 
confidential and intended solely for the attention and use 
of the named addressee(s). This information may be 
subject to legal professional or other privilege or may 
otherwise be protected by work product immunity or other 
legal rules.  It must not be disclosed to any person without 
our authority.

If you are not the intended recipient, or a person 
responsible for delivering it to the intended recipient, you 
are not authorised to and must not disclose, copy, 
distribute, or retain this message or any part of it.
*

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


Re: Yet Another Monad Tutorial

2003-08-14 Thread Jeff Newbern
Alistair,

Thanks for your message regarding the debate about monads and purity.

What do you think about these additions as a discussion of the issue?
Does this address everything you think is needed?  Is there a clearer
way to explain it?

Thanks,
Jeff

In the section No Way Out:
--
The IO monad is a familiar example of a one-way monad in Haskell.
Because you can't escape from the IO monad, it is impossible to write a
function that does a computation in the IO monad but returns a
non-monadic value. Not only are functions of the type IO a - a
impossible to create, but any function whose result type does not
contain the IO type constructor is guaranteed not to use the IO monad.
Other monads, such as List and Maybe, do allow values out of the monad.
So it is possible to write non-monadic functions that internally do
computations in those monads. The one-way nature of the IO monad also
has consequences when combining monads, a topic that is discussed in
part III.
--

and a little farther down:

--
Some people argue that using monads to introduce non-pure features into
Haskell disqualifies it from claiming to be a pure functional language.
This subtle question  not particularly relevant to the practical
programmer  is revisited in the context of the I/O monad later in the
tutorial.
--

Later, in the section on the I/O monad:
--
In Haskell, the top-level main function must have type IO (), so that
programs are typically structured at the top level as an
imperative-style sequence of I/O actions and calls to functional-style
code. Revisiting the debate about the purity of Haskell (in a functional
sense), it is important to note that the IO monad only simulates
imperative-style I/O. The functions exported from the IO module do not
perform I/O themselves. They return I/O actions, which describe an I/O
operation to be performed. The I/O actions are combined within the IO
monad (in a purely functional manner) to create more complex I/O
actions, resulting in the final I/O action that is the main value of the
program. The result of the Haskell compiler is an executable function
incorporating the main I/O action. Executing the program applies this
ultimate I/O action to the outside world to produce a new state of the
world. This occurs only once per execution of the program, and since the
state of the world changes for each execution, the issue of purity is
neatly side-stepped.
--

-- 
Jeff Newbern [EMAIL PROTECTED]
Nomaware, Inc.

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


RE: Yet Another Monad Tutorial

2003-08-14 Thread Phil Molyneux
I think the crucial distinction is to think about is the difference
between calculating a value (such as a character) compared to calculating
an action (such as a computation that reads a character) --- one is wholly
in your programming language while the other interacts with something
outside your language (the I/O system). Many years ago we were all told it
was a *good thing* to separate calculating values from *doing* I/O. Of
course, you weren't actually *doing* any I/O when you *wrote* your program
--- you were *calculating* (working out, writing...) your program.

For most actions/computations, the properties you usually want is that A
followed by (B followed by C) is the same as (A followed by B) followed by
C and a unit (as in multiplication) or zero (as in addition) action. I
guess the usefulness of this is quite subtle --- the Romans had no
notation for zero and look what happened to them (although we still use
Roman numerals for decoration). How do you know you have structured your
program so that the preceding properties hold ? You show that you're
working in the appropriate Monad --- remember, maths is the QA of
programming. I suspect that tutorials should at some point mention some
definitions of monads, monoids et al --- since this is where the power
(sorry, QA) comes from. 

Phil




On Tue, 12 Aug 2003, Bayley, Alistair wrote:

 Date: Tue, 12 Aug 2003 12:10:24 +0100
 From: Bayley, Alistair [EMAIL PROTECTED]
 Subject: RE: Yet Another Monad Tutorial
 
  From: Wolfgang Jeltsch [mailto:[EMAIL PROTECTED]
  
  For example, the function readFile is pure. For a specific 
  string s the 
  expression readFile s always yields the same result: an I/O 
  action which 
  searches for a file named s, reads its content and takes this 
  content as the 
  result of the *action* (not the expression).
 
 What about getChar? This is a function which takes no arguments, yet returns
 a (potentially) different value each time. I know, I know: it returns an IO
 action which reads a single char from the terminal and returns it.
 
 Is the IO monad the only one (currently) in which you would say that it
 returns an action, which is then executed by the runtime system? I would
 have thought that monads that are not involved in IO (e.g. State) would be
 pure in the sense that Van Roy was thinking. You wouldn't need to describe
 functions in them as returning an action.
 
 
 *
 The information in this email and in any attachments is 
 confidential and intended solely for the attention and use 
 of the named addressee(s). This information may be 
 subject to legal professional or other privilege or may 
 otherwise be protected by work product immunity or other 
 legal rules.  It must not be disclosed to any person without 
 our authority.
 
 If you are not the intended recipient, or a person 
 responsible for delivering it to the intended recipient, you 
 are not authorised to and must not disclose, copy, 
 distribute, or retain this message or any part of it.
 *
 
 ___
 Haskell-Cafe mailing list
 [EMAIL PROTECTED]
 http://www.haskell.org/mailman/listinfo/haskell-cafe
 
 



Phil Molyneux email  [EMAIL PROTECTED]
tel  work 020 8547 2000 x 5233  direct 020 8547 8233  home 020 8549 0045
Kingston Business School room 339 WWW http://www.kingston.ac.uk/~ku00597
Kingston University,  Kingston Hill,  Kingston upon Thames  KT2 7LB,  UK


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


.. Drowning in debt? We have the answer. fdps[]c.

2003-08-14 Thread koxwhdsinsad
Hey There!

Debt sucks, and so do the repayments.. feel like your getting ripped off? ..
We tear up your debt and give you and your family a fresh start ..

- Save you a lot of money by eliminating late fees
- Settle your accounts for a substantially reduced amount
- Stop creditors calling you on the phone
- Avoid bankruptcy

... and more!

Why keep dealing with the stress, and headaches?

Combine your debt into a low interest repayment and
get on with your life today!!

Come here and take a look at how we can help.

http://[EMAIL PROTECTED]/index.php?N=g










dont want any more?
http://[EMAIL PROTECTED]/r.php
___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe


[newbie] UTF-8

2003-08-14 Thread Danon'.
Hi, 

  We try to make a program which write on stdout the UTF-8 character
corresponding to an input unicode value. And this under MacOS X,
Debian linux, and Windows.
  It seems to be easy, but we can't have found anything valuable, on
the net.
Would you mind to help us?

Niko.
Ps: excuse my poor english.

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


Help with Exceptions on I/O

2003-08-14 Thread Alexandre Weffort Thenorio


I have a program which creates textfiles out of other 
files. Since theprogram is runned from windows I output some text strings 
(Like "Filecreated succefully") and I need to stop the program before it 
quits so thatthe user can read the line outputted to know what went on and 
then he canpress ENTER to quit the program.I managed to do this fine 
if no error occurs but when a error occurs I amhaving problems.The 
code goes like thatmain :: IO()main =catch 
(do 
Do all the needed stuff 
here 
putStr "File created Successfully. Press RETURN 
toquit" 
dummy - getLine --Halts the program so the user canread the above 
line) 
putStr "Exiting now..." --needed since I can't finish ado function with the 
"dummy- getLine" line) (\_ - do putStr "\nFile notfound. Press 
RETURN (ENTER) to quit." dumb - 
getLine putStr "\nExiting...")So when the 
program runs, if the input file is found the program writessuccessfull 
creation of file but if the file doesn't exist, after the usergives the 
input filename and press enter, the program creates a new line andHalts 
(Probably because of the getLine function) without writing outanything, then 
when the user press ENTER again it writes the line at thefirst putStr (File 
not...), then writes the next putStr line under it(Exiting...) and exits. I 
don't know why it doesn't wirte the first line,halts and then when user 
press enter it writes the second and quits.Can anybody help me as I am 
not very familiar with exception and catches.Another question I have 
is: Is there any other function rather than getLinethat halts a program and 
continues when a user press any key (Instead ofENTER) and besides this is an 
ugly code since getLine wasn't made for thatbut I couldn't find anything 
else myself.Thank you in advance.Best RegardsAlex