Re: [Haskell-cafe] Literate Haskell

2005-02-22 Thread Jesper Louis Andersen
Quoting Jérémy Bobbio ([EMAIL PROTECTED]):
> I really see Literate Haskell and Haddock as two orthogonal tools, and 
> that help me to focus when writing docs.

It impresses me SO much that the COMPUTER SCIENTIST have found a WAY to
ELEVATE mere tools likke Haddock and Literate Haskell as elements in a 
VECTOR SPACE. Furthermore it seems that the SAME vector space has LANGUAGES
as well, and moreso; It is an INNER PRODUCT SPACE, since one can talk about
ORTHOGONALITY. One could have used the term ''Lineraly independent set'',
but NO! One should use the magical, term Orthogonal! Heed my words! 
Orthogonal!

Fun aside, I think you are right, but I disagree literate haskell is the
way to write the ``how does this fit together'' question. Having just 
completed a quite big program written all in literate style, I can actually
put up some comments about it:

* It is hard. There is a thin line between having meaningful information
  in the comments and nothing but redundancy, compared to the source code.

* There is many changes. All the time you change code semantics and then
  you have to read the comments around and check them for correctness.

* There is an abstraction gap. Your thoughts can separately be given at
  a very high level. If interspersed with code, you are explaining at a
  much lower (and precise) level what your program is actually doing.

I have a program of 2500 Lines. It is, typeset in LaTeX, 155 pages of report
and literate documentation. That is awfully much for 2500 Lines of source code.
Currently my feeling is that the added effort of writing it literate style 
does not add to the general understanding of the source code. This is partly
because the source code is imperative at many points (it is ML - who said you
can't just push in a couple of ref cells?). And also because the code in
question is quite complex (due to the destructive updates, actually). I think
you want 3 things:

* API documentation (Haddock fills this gap). It is the for the programmer who
  wants to see how a given function should be called and be given the abstract
  view of it's semantics as a black box.

  Furthermore, Haddock provides a very succintly different but important view
  of my Modules: The ``SML signature'' view to type annotations, where type
  annotations are all presented in the same location for overview and is
  disconnected from the actual implementation. Together with proper
  documentation, this gives a very good overview over programs.

* Documentation of the ``hard semantical parts''. The meaning of some functions
  needs elaboration since they are either hard to understand or they have some
  subtle point you commonly overlook. 

* Documentation of the high-level structure. 

My view is that Haddock, code comments and LaTeX fits these 3 quite well. On
the other hand, if writing code by example to teach others about it, sending
email with code etc, I like to have literate haskell style. But I do not tend
to use it for large projects.  

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


Re: [Haskell-cafe] Re: New to haskell: unresolved overloading question

2005-02-22 Thread Christian Maeder
Keean Schupke wrote:
There are problems with this approach... 

instance (Ord a, Num a) => ApproxEq a where x ~= y = (abs (x-y) < 1)

However it should do what you want with just -foverlapping-instances 
-fundecidable-instances.
Only -fallow-incoherent-instances allowes to resolve
 3.5 ~= 2.6
without type-annotations! But when adding:
 instance ApproxEq Double where x~=y = False
the above result remained True (via Defaulting) whereas
3.5 ~= (2.6 :: Double)
became False. (An the other hand there was no need to add such an 
instance for Double.)

It is also not possible to add a further instance like:
 instance (Ord a, Fractional a) => ApproxEq a where
   x ~= y = (abs (x-y) < 0.1)
(hoping that fractionals are treated more accurate that nums) Only one 
instance for "ApproxEq a" is allowed.

Since the subject is "New to haskell" I recommend to stay Haskell98 
compliant, i.e. avoid overlapping instances and add type signatures as 
necessary.

If you add the option -Wall (or -fwarn-type-defaults) to ghci you'll get 
a warning whenever "defaulting" occurs (like in 1.5 == 1.5 to Double)

(Putting "default ()" in your source file prevents defaulting, but I 
don't recommend to do so only to force types on decls like "f = 1.5")

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


[Haskell-cafe] Re: New to haskell: unresolved overloading question

2005-02-22 Thread Christian Maeder
Tomasz Zielonka wrote:
Why not forget about ApproxEq for () and Bool and simply define a
function?
  (~=) :: (Ord a, Num a) => a -> a -> Bool
  x ~= y = abs (x-y) < 1
Indeed, this works best. The instance for lists is also not too important.
Christian
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: New to haskell: unresolved overloading question

2005-02-22 Thread Daniel Fischer
Am Dienstag, 22. Februar 2005 00:34 schrieb Daniel Fischer:

> That's a very common problem for newbies, so don't panic.
> In older versions of hugs (November 2002, e.g.), you would have got an
> unresolved overloading also from entering [] to the prompt (this is no
> longer so). If such things happen, add an explicit typing, if that doesn't
> help, then you have a problem.
>
> To deepen the confusion, hugs has no problems with
>
> Prelude> 1.5 == 1.5
> True
>
> I'm not quite sure why this works, must be due to type defaulting, however,

Ah, I found out, carefully rereading the pertinent paragraph of the report 
(4.3.4) informed me that, for the defaulting rules to be applied,
*all Classes in the context must be defined in the Prelude or the standard 
libraries*, which of course ApproxEq isn't.

If you include 
default ()   or default (Integer)
in your script, 
1.5 == 2.4
will also lead to an unresolved overloading, so defaulting really works.

Bye for now,
Daniel
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


RE: [Haskell-cafe] Problems building GreenCard

2005-02-22 Thread Simon Peyton-Jones
-fno-prune-tydecls is a dead flag.  Just remove it.

Simon

| -Original Message-
| From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
| Dmitri Pissarenko
| Sent: 15 February 2005 21:04
| To: haskell-cafe@haskell.org
| Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED]
| Subject: Re: [Haskell-cafe] Problems building GreenCard
| 
| Hello!
| 
| I could fix the problem by replacing the line
| 
| GHC_OPTS = -cpp -fglasgow-exts -fno-prune-tydecls
| 
| in file lib/Makefile by this one
| 
| GHC_OPTS = -cpp -fglasgow-exts
| 
| However, I don't know what this -fno-prune-tydecls does and whether it
is
| important (for using Green Card to access Java).
| 
| Best regards
| 
| Dmitri Pissarenko
| --
| Dmitri Pissarenko
| Software Engineer
| http://dapissarenko.com
| 
| ___
| Haskell-Cafe mailing list
| Haskell-Cafe@haskell.org
| http://www.haskell.org/mailman/listinfo/haskell-cafe
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] ANN: HAppS -- Haskell Application Server v 0.2

2005-02-22 Thread S. Alexander Jacobson
HAppS is a Haskell library for building Internet applications, 
featuring:

* HAppS.ACID: Guarantee application integrity in the face of 
unplanned outages using this module's integrated write-ahead logging 
and checkpointing framework.

* HAppS.DBMS: Do relational operations in Haskell (rather than 
SQL) on Haskell sets (outside the IO Monad). Define custom indices for 
your Haskell datatypes (e.g. geographic/geometric types). Use in 
combination with ACID for a robust relational DBMS customized for your 
application.

* HAppS.Protocols: Expose your application using as an HTTP server 
and/or by recieving and sending SMTP.

- License
HAppS is released by HAppS.org under the terms of the GNU General 
Public License Version 2, a copy of which is enclosed with this 
package.

- How do I get HAppS?
More information is available at http://HAppS.org
A tarball of HAppS is available at 
http://HAppS.org/HAppS/happs.tar.gz. HAppS is also available via 
darcs:

  darcs get http://happs.org/HAppS

__
S. Alexander Jacobson tel:917-770-6565 http://alexjacobson.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] WASH defaults in inputFields

2005-02-22 Thread John Goerzen
Hi,

Hope this is not a stupid question, but I RTFM'd and couldn't find the
answer.

I am designing a form that will be used to edit some data that is in the
database.  I want users to pull up the form and have all the input
fields pre-filled with the current state of the database (so they don't
have to re-key all that), then the database gets updated with they hit
submit.  Simple to do in HTML, but I can't figure out how to do this
with Wash.  The inputFields don't seem to take a parameter giving a
default, nor does there appear to be any way to set it later.

Ideas?

Thanks,
John

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


Re: [Haskell-cafe] WASH defaults in inputFields

2005-02-22 Thread Tomasz Zielonka
On Tue, Feb 22, 2005 at 04:48:07PM +, John Goerzen wrote:
> Hi,
> 
> Hope this is not a stupid question, but I RTFM'd and couldn't find the
> answer.
> 
> I am designing a form that will be used to edit some data that is in the
> database.  I want users to pull up the form and have all the input
> fields pre-filled with the current state of the database (so they don't
> have to re-key all that), then the database gets updated with they hit
> submit.  Simple to do in HTML, but I can't figure out how to do this
> with Wash.  The inputFields don't seem to take a parameter giving a
> default, nor does there appear to be any way to set it later.
> 
> Ideas?

Most functions for creating fields (like textInputField) take a
parameter with type (WithHTML sth CGI ()). Using this you can
supply additional attributes to the INPUT tag, or whatever tag
it is. Now you can simply use ordinary HTML to fill the default
value. For example, if you use textInputField do this:

i <- textInputField (uaVALUE "default value" >> uaSIZE "10")

or this way if you use CGI, not GuaranteedCGI:

i <- textInputField (attr "value" "default value" >> attr "size" "10")

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


Re: [Haskell-cafe] WASH defaults in inputFields

2005-02-22 Thread John Goerzen
On Tue, Feb 22, 2005 at 06:26:29PM +0100, Tomasz Zielonka wrote:
> i <- textInputField (uaVALUE "default value" >> uaSIZE "10")
> 
> or this way if you use CGI, not GuaranteedCGI:

Speaking of which, I couldn't find any documentation on GuaranteedCGI at
all.  What's the difference between it and CGI?

Thanks!

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


Re: [Haskell-cafe] WASH defaults in inputFields

2005-02-22 Thread Jeremy Shaw
At Tue, 22 Feb 2005 18:26:29 +0100,
Tomasz Zielonka wrote:
> 
> On Tue, Feb 22, 2005 at 04:48:07PM +, John Goerzen wrote:
> > Hi,
> > 
> > Hope this is not a stupid question, but I RTFM'd and couldn't find the
> > answer.

> Most functions for creating fields (like textInputField) take a
> parameter with type (WithHTML sth CGI ()). Using this you can
> supply additional attributes to the INPUT tag, or whatever tag
> it is. Now you can simply use ordinary HTML to fill the default
> value. For example, if you use textInputField do this:
> 
> i <- textInputField (uaVALUE "default value" >> uaSIZE "10")
> 
> or this way if you use CGI, not GuaranteedCGI:
> 
> i <- textInputField (attr "value" "default value" >> attr "size" "10")

For what john asked, I usually do something like:

  i <- textInputField (fieldVALUE "the default value")

Not sure if there is any advantage/disadvantage to that. 

Jeremy Shaw.
--

This message contains information which may be confidential and privileged. 
Unless you are the 
addressee (or authorized to receive for the addressee), you may not use, copy 
or disclose to anyone 
the message or any information contained in the message. If you have received 
the message in error, 
please advise the sender and delete the message.  Thank you.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] WASH defaults in inputFields

2005-02-22 Thread John Goerzen
On Tue, Feb 22, 2005 at 01:53:08PM -0500, Jeremy Shaw wrote:
> For what john asked, I usually do something like:
> 
>   i <- textInputField (fieldVALUE "the default value")

Thanks for all the helpful answers.  Sorry it didn't occur to me what
this meant at first.  It should have :-)
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: new Haskell hacker seeking peer review

2005-02-22 Thread Bjorn Bringert
Isaac Jones wrote:
John Goerzen <[EMAIL PROTECTED]> writes:
Here's an alternative:
module Main where
(snip john's version)
And what list would be complete without a points-free version.  It
doesn't operate on stdin, though like John's does:
pointsFreeCat :: IO ()
pointsFreeCat = getArgs >>= mapM readFile >>= putStrLn . concat
Or why not the two characters shorter, but much less readable:
pointsFreeCat' = getArgs >>= mapM_ ((>>= putStr) . readFile)
or maybe:
pointsFreeCat'' = getArgs >>= mapM_ (putStr >>. readFile)
(>>.) :: (b -> IO c) -> (a -> IO b) -> a -> IO c
(>>.) = (.) . flip (>>=)
Is (>>.) in the standard libs? If not, should it be? I'm sure there is a 
shorter definition of (>>.) that I haven't thought of.

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


[Haskell-cafe] module Crypt_Discordian - code critique requested

2005-02-22 Thread Terrence Brannon

Hi, I am getting into Haskell so I decided to convert a Perl module of
mine:

http://cpan.uwinnipeg.ca/htdocs/Crypt-Discordian/Crypt/Discordian.html

into Haskell. I was pleased at the cleanliness and conciseness of the
Haskell code. However, I am sure that it can be improved on and am
soliciting any feedback you may have about this module.

Thanks,
metaperl on #haskell

module Crypt_Discordian 
where

import List

vowel_list = "aeiouAEIOU"

is_vowel c = c `elem` vowel_list

move_vowels lis = move_vowels' lis [] []

move_vowels' [] c v = v ++ c
move_vowels' (x:xs) c v
| is_vowel x  = move_vowels' xsc  (x:v)
| otherwise   = move_vowels' xs (x:c)v

remove_spaces str = filter (\x -> x /= ' ') str

encrypt str = List.sort $ move_vowels $ remove_spaces str

{-

The algorithm for Discordian text encryption is given at:

   http://www.principiadiscordia.com/book/78.php

After implementing this, I realized that all the early steps are a farce.

But anyway, here is the algorithm in case you don't enjoy tilting your 
head to read a page:

Step 1. Write out message (HAIL ERIS) and put all vowels at the end
(HLRSAIEI) 

Step 2. Reverse order (IEIASRLH)

Step 3. Convert to numbers (9-5-9-1-19-18-12-8)

Step 4. Put into numerical order (1-5-8-9-9-12-18-19)

Step 5. Convert back to letter (AEHIILRS)

This cryptographic cypher code is GUARANTEED TO BE 100% UNBREAKABLE

.. so says the Principia Discordia. But I think we can generate and
test to break it.

Many thanks to kosmikus and Pseudonym for their help in developing 
this module

-}


-- 
Carter's Compass: I know I'm on the right track when,
   by deleting something, I'm adding functionality.

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


[Haskell-cafe] GUI components for displaying Html pages

2005-02-22 Thread David Owen
Hi all,
I'm looking for a Haskell GUI library which supports the display of rendered 
Html pages in the same way that web browsers do.

I've been getting to grips recently with wxHaskell as it was recommended on 
haskell-cafe.  I was hoping that a special pane component (or something 
similar) existed in wxHaskell for the purpose.  I've looked through the API 
but can't seem to see anything which looks suitable.  Does anybody know if 
wxHaskell can support this?  If not is anybody aware of a Haskell GUI 
library which caters for this purpose.

Also, I am hoping to make use of HaXmL to deal with the Html parsing or 
failing that attempt a very simple home-made parser.   Should anybody out 
there know of a better way of attacking this aspect then that would be much 
appreciated too!

(Apologies, this email might have been better suited to the libraries 
mailing list!)

Cheers all!
David
(Swansea, UK)
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] GUI components for displaying Html pages

2005-02-22 Thread Lemmih
On Wed, 23 Feb 2005 03:25:47 +, David Owen <[EMAIL PROTECTED]> wrote:
> Hi all,
> 
> I'm looking for a Haskell GUI library which supports the display of rendered
> Html pages in the same way that web browsers do.
> 
> I've been getting to grips recently with wxHaskell as it was recommended on
> haskell-cafe.  I was hoping that a special pane component (or something
> similar) existed in wxHaskell for the purpose.  I've looked through the API
> but can't seem to see anything which looks suitable.  Does anybody know if
> wxHaskell can support this?  If not is anybody aware of a Haskell GUI
> library which caters for this purpose.

Is this what you're looking for:
http://wxhaskell.sourceforge.net/doc/Graphics.UI.WXCore.WxcClassesAL.html#88
?


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


Re: [Haskell-cafe] module Crypt_Discordian - code critique requested

2005-02-22 Thread Arthur van Leeuwen
On Wed, Feb 23, 2005 at 12:27:19AM +, Terrence Brannon wrote:
> 
> Hi, I am getting into Haskell so I decided to convert a Perl module of
> mine:
> 
> http://cpan.uwinnipeg.ca/htdocs/Crypt-Discordian/Crypt/Discordian.html
> 
> into Haskell. I was pleased at the cleanliness and conciseness of the
> Haskell code. However, I am sure that it can be improved on and am
> soliciting any feedback you may have about this module.
> 
> Thanks,
> metaperl on #haskell
> 
> module Crypt_Discordian 
> where
> 
> import List
> 
> vowel_list = "aeiouAEIOU"
> 
> is_vowel c = c `elem` vowel_list
> 
> move_vowels lis = move_vowels' lis [] []
> 
> move_vowels' [] c v = v ++ c
> move_vowels' (x:xs) c v
> | is_vowel x  = move_vowels' xsc  (x:v)
> | otherwise   = move_vowels' xs (x:c)v
> 
> remove_spaces str = filter (\x -> x /= ' ') str
> 
> encrypt str = List.sort $ move_vowels $ remove_spaces str

How about

> module CryptDiscordian
> where
>
> import List
>
> vowels = "aeiouAEIOU"
> isVowel = (flip elem) vowel_list
>
> moveVowels xs = filter (not . isSpace) $ 
> (filter (not . isVowel) xs ++ filter (is_vowel) xs)
>
> encryptDiscordian xs = map chr $ sort $ map (ord . toLower) $ 
> reverse $ moveVowels xs

[snip description of algorithm]

Obviously, if it is implemented differently it won't be the Discordian
encryption anymore, now will it? Note that my version is more conforming
than yours, as you don't convert to numbers and back...

Unfortunately, the algorithm doesn't state how to deal with capitalization,
so I chose to just map to lowercase...

Doei, Arthur.

-- 
  /\/ |   [EMAIL PROTECTED]   | Work like you don't need the money
 /__\  /  | A friend is someone with whom | Love like you have never been hurt
/\/__ | you can dare to be yourself   | Dance like there's nobody watching
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] module Crypt_Discordian - code critique requested

2005-02-22 Thread Arthur van Leeuwen
On Wed, Feb 23, 2005 at 08:46:23AM +0100, Arthur van Leeuwen wrote:
> On Wed, Feb 23, 2005 at 12:27:19AM +, Terrence Brannon wrote:

[snip, encryptia discordia]>

> How about
> 
> > module CryptDiscordian
> > where
> >
> > import List
> >
> > vowels = "aeiouAEIOU"
> > isVowel = (flip elem) vowel_list
> >
> > moveVowels xs = filter (not . isSpace) $ 
> > (filter (not . isVowel) xs ++ filter (is_vowel) xs)
> >
> > encryptDiscordian xs = map chr $ sort $ map (ord . toLower) $ 
> > reverse $ moveVowels xs

Which won't work, as it lacks an import Char.

Doei, Arthur. (Still waking up, apparently)

-- 
  /\/ |   [EMAIL PROTECTED]   | Work like you don't need the money
 /__\  /  | A friend is someone with whom | Love like you have never been hurt
/\/__ | you can dare to be yourself   | Dance like there's nobody watching
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe