[Haskell-cafe] Re: [Haskell] ANNOUNCE: HStringTemplate -- An Elegant, Functional, Nifty Templating Engine for Haskell

2008-01-14 Thread Don Stewart
s.clover:
 HStringTemplate is a port of Terrence Parr’s lovely StringTemplate  
 (http://www.stringtemplate.org) engine to Haskell.
 
 It is available, cabalized, at:
 darcs get http://code.haskell.org/HStringTemplate/

Looks very useful!  Will this be on hackage.haskell.org soon?

I can't wait to:

cabal install HStringTemplate

:)

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


Re: [Haskell-cafe] All equations must have the same arity - why?

2008-01-14 Thread Lennart Augustsson
There is no technical reason for this.  It's a matter of taste.  As someone
else pointed out, different arities is usually a bug.

  -- Lennart

On Jan 13, 2008 3:12 PM, Neil Mitchell [EMAIL PROTECTED] wrote:

 Hi,

 It's nice to write functions in point free style:

 f = sort . nub

 But sometimes I have to add an extra case, on a certain value:

 f [] = [1]
 f = sort . nub

 But now these equations have different arities, and its rejected by
 Haskell. Why does this not simply desugar to:

 f [] = [1]
 f x = (sort . nub) x

 i.e. lift the arities to the longest argument list.

 Is there a reason this isn't done?

 Thanks

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

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


RE: [Haskell-cafe] Possibility to port vshaskell to VS2008?

2008-01-14 Thread Simon Peyton-Jones
Yes, the VS Shell indeed looks an attractive platform, because it's free.  It'd 
be great if someone wanted to port Visual Haskell to the VS Shell.

Simon

| -Original Message-
| From: Peter Verswyvelen
| Sent: 13 January 2008 21:15
| Subject: Re: [Haskell-cafe] Possibility to port vshaskell to VS2008?
|
| It might be even better to port it to the freely available downloadable
| Visual Studio Shell:
| http://msdn2.microsoft.com/en-us/vsx2008/products/bb933751.aspx
|
| The F# plugin works for that environment, giving a very good free IDE.
|
| Cheers,
| Peter (on Fedora 8 using, woohoo, my first steps on Linux :)
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


RE: [Haskell-cafe] Possibility to port vshaskell to VS2008?

2008-01-14 Thread Peter Verswyvelen
Yes, would be really nice. And in the meanwhile update it to GHC 6.8.2
and add support for debugging/stepping now that GHC supports it :-)

Peter

On Mon, 2008-01-14 at 08:45 +, Simon Peyton-Jones wrote:
 Yes, the VS Shell indeed looks an attractive platform, because it's free.  
 It'd be great if someone wanted to port Visual Haskell to the VS Shell.
 
 Simon
 
 | -Original Message-
 | From: Peter Verswyvelen
 | Sent: 13 January 2008 21:15
 | Subject: Re: [Haskell-cafe] Possibility to port vshaskell to VS2008?
 |
 | It might be even better to port it to the freely available downloadable
 | Visual Studio Shell:
 | http://msdn2.microsoft.com/en-us/vsx2008/products/bb933751.aspx
 |
 | The F# plugin works for that environment, giving a very good free IDE.
 |
 | Cheers,
 | Peter (on Fedora 8 using, woohoo, my first steps on Linux :)
 

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


[Haskell-cafe] Code folding in Emacs

2008-01-14 Thread Johan Tibell
It would be pretty neat for Haskell hacking if the Emacs Haskell mode
could do the following. Imagine you have written some code like so:

-- | The parse state.
data S = S {-# UNPACK #-} !B.ByteString  -- current chunk
   L.ByteString  -- rest of the input
   {-# UNPACK #-} !Int64 -- bytes read

-- | The 'Parser' monad is just a State monad carrying around the
-- input ByteString.
newtype Parser a = Parser { unParser :: S - Consumed (Reply a) }

-- | Match byte that fulfills predicate.
satisfy :: (Word8 - Bool)  -- ^ Predicate that byte must fulfill.
- Parser Word8 -- ^ Matched byte.
satisfy p =
Parser $ \(S s ss pos) -
if B.null s
  then (if L.null ss
then Empty (Error (ParseError pos))
else case L.splitAt 1 ss of
   (consuming,rest) -
   let now = B.concat . L.toChunks $ consuming
   b   = B.head now
   in
   if p b then
   Consumed $ Ok b (S (B.tail now) rest (pos + 1))
 else Empty $ Error $ ParseError pos
   )
  else let b = B.head s in
   if p b then Consumed $ Ok (B.head s) (S (B.tail s) ss (pos + 1))
   else Empty $ Error $ ParseError pos

Now you want an overview of your source file. One way would be to
replace all the implementation parts with ellipses, like so:

-- | The parse state.
data S = S {-# UNPACK #-} !B.ByteString  -- current chunk
   L.ByteString  -- rest of the input
   {-# UNPACK #-} !Int64 -- bytes read

-- | The 'Parser' monad is just a State monad carrying around the
-- input ByteString.
newtype Parser a = Parser { unParser :: S - Consumed (Reply a) }

-- | Match byte that fulfills predicate.
satisfy :: (Word8 - Bool)  -- ^ Predicate that byte must fulfill.
- Parser Word8 -- ^ Matched byte.
satisfy p = ...

Binding a haskell-fold-source function to a key chain would enable you
to get a quick overview of your module showing only the comments and
type signatures. I've used the little function from
http://emacs.wordpress.com/2007/01/16/quick-and-dirty-code-folding/
but it doesn't work well together with indented type signatures like
in the example above.

Anyone with strong Emacs-fu that knows how one could implement such a function?

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


Re: [Haskell-cafe] Computer Science Books using Haskell

2008-01-14 Thread jerzy . karczmarczuk
Don Stewart writes: 


One textbook on algorithms with a functional approach is by Fethi Rabhi
and Guy Lapalme: Algorithms: A functional programming approach
published by Addison-Wesley, 235 pages, ISBN 0-201-59604-0 


I'd imagine they wouldn't use many OCR unfriendly characters.


I perhaps misunderstand this phrase, but if you suggest that it would be
useful to snatch the code examples from within the book, I believe that
no OCR is needed, they are here: 

http://www.iro.umontreal.ca/~lapalme/AlgoFP/code.html 

Jerzy Karczmarczuk 



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


Re: [Haskell-cafe] How to add ENV variable in runhaskell shell script

2008-01-14 Thread John Meacham
only one argument is allowed after the #! on the first line. however the
following should be portable if you must set the variable before
runhaskell is executed:

#!/bin/sh
--  /dev/null 21; MYENV=foo runhaskell $_  

import System.Environment

main = getEnv MYENV = print



-- 
John Meacham - ⑆repetae.net⑆john⑈
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] All equations must have the same arity - why?

2008-01-14 Thread Bulat Ziganshin
Hello Neil,

Monday, January 14, 2008, 2:12:52 AM, you wrote:

 But sometimes I have to add an extra case, on a certain value:

 f [] = [1]
 f = sort . nub

 Is there a reason this isn't done?

this may be also due an error, and in most cases it actually will be
due an error. then it makes type inference trickier and will led to
very strange error messages instead of simple different amount of
arguments. so, we will buy power but lose simplicity


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re: [Haskell-cafe] Code folding in Emacs

2008-01-14 Thread Valery V. Vorotyntsev
On 1/14/08, Johan Tibell [EMAIL PROTECTED] wrote:
 It would be pretty neat for Haskell hacking if the Emacs Haskell mode
 could do the following. Imagine you have written some code like so:

 [...]

 Binding a haskell-fold-source function to a key chain would enable you
 to get a quick overview of your module showing only the comments and
 type signatures. I've used the little function from
 http://emacs.wordpress.com/2007/01/16/quick-and-dirty-code-folding/
 but it doesn't work well together with indented type signatures like
 in the example above.

AFAIU the problem, ..

data StupidTypeNameIntendedToBeLong =
Foo

functionWithLngName :: Foo
- Bar
functionWithLngName = undefined

.. you don't like the way haskell-mode indents the `- Bar' line.

If this is the case, you could `newline-and-indent' (`C-j') right
after `::'.

anotherFunctionWithLongName ::
Foo - Bar
anotherFunctionWithLongName = undefined

And what's this haskell-fold-source function you were talking about?

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


[Haskell-cafe] Re: [newbie question] Memoization automatic in Haskell?

2008-01-14 Thread Stephane Bortzmeyer
On Sun, Jan 13, 2008 at 12:25:53AM +0100,
 Henning Thielemann [EMAIL PROTECTED] wrote 
 a message of 28 lines which said:

 Caching is not the default, but you can easily code this by
 yourself: Define an array and initialize it with all function
 values. Because of lazy evaluation the function values are computed
 only when they are requested and then they persist in the array.

It works only if the argument of the function is an integer or an
enumerated type. If the argument is a string and you do not know the
string values in advance, you cannot use the array.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: Code folding in Emacs

2008-01-14 Thread Joe Buehler
Johan Tibell wrote:

 Anyone with strong Emacs-fu that knows how one could implement such a 
 function?

This looks like a straightforward application of outline mode.  I believe
it might be as simple as setting up a regex and enabling the mode, but
check the LISP source for outline mode or perhaps the emacs manual.

Joe Buehler

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


Re: [Haskell-cafe] [IETF Apps meeting] A Theory of Templating Languages

2008-01-14 Thread Mario Blazevic



I did find one paper that makes a start at such work, Enforcing
Strict Model-View Separation in Template Engines,
but the theory is a little weak and it focuses on the nebulous idea of
separation of model and view, as opposed to
a classification of capabilities and limitations.



	When I did the research for my template engine paper, that was also the 
most theoretically-inclined paper I could find. In fact, it was almost 
the only paper focusing on template languages. That entire area, of 
considerable importance in practice, seems to be completely ignored by 
computer science.


	 My own work was more on the practical side, but its first section may 
be of some interest for its (sadly informal) pointing out of 
relationships between template engines and functional programming. The 
paper and the slides can be found at:


http://www.idealliance.org/papers/extreme/proceedings/html/2007/Blazevic01/EML2007Blazevic01.xml


Good luck.


--
Mario Blazevic
[EMAIL PROTECTED]
Stilo Corporation

This message, including any attachments, is for the sole use of the
intended recipient(s) and may contain confidential and privileged
information. Any unauthorized review, use, disclosure, copying, or
distribution is strictly prohibited. If you are not the intended
recipient(s) please contact the sender by reply email and destroy
all copies of the original message and any attachments.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Code folding in Emacs

2008-01-14 Thread Johan Tibell
On Jan 14, 2008 2:30 PM, Valery V. Vorotyntsev [EMAIL PROTECTED] wrote:
 On 1/14/08, Johan Tibell [EMAIL PROTECTED] wrote:
  It would be pretty neat for Haskell hacking if the Emacs Haskell mode
  could do the following. Imagine you have written some code like so:
 
  [...]
 
  Binding a haskell-fold-source function to a key chain would enable you
  to get a quick overview of your module showing only the comments and
  type signatures. I've used the little function from
  http://emacs.wordpress.com/2007/01/16/quick-and-dirty-code-folding/
  but it doesn't work well together with indented type signatures like
  in the example above.

 AFAIU the problem, ..

 data StupidTypeNameIntendedToBeLong =
 Foo

 functionWithLngName :: Foo
 - Bar
 functionWithLngName = undefined

 .. you don't like the way haskell-mode indents the `- Bar' line.

 If this is the case, you could `newline-and-indent' (`C-j') right
 after `::'.

No, I like the way haskell-mode indents. :)

However the simple folding snippet I linked to above doesn't work with
it since that code simple collapses everything that's indented.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: All equations must have the same arity - why?

2008-01-14 Thread Achim Schneider
Jonathan Cast [EMAIL PROTECTED] wrote:

 On 13 Jan 2008, at 5:49 PM, Achim Schneider wrote:
 
  Jonathan Cast [EMAIL PROTECTED] wrote:
 
  On 13 Jan 2008, at 5:27 PM, Achim Schneider wrote:
  Answer #2:
 
  Because you can't write
 
  f x = case x of
[] - [1]
  - sort.nub
 
  But why not?
 
  Because arities aren't lifted to the longest argument list.
 
 I think you lost the point of my question...
 
I'm glad you are capable of ever so nobly assigning the purest   
imaginable motives to me. You are a true inspiration.
 
  Treating case as syntax sugar for a higher-order
  function, so that all binding occurrences of lambdas in the
  unsugared code are associated with lambdas, is a good thing, and
  offers a natural way of desugaring the above, one case at a time.
 
  What about
 
  f x = [1]
  f - = sort.nub
 
  ?
 
  You could also do things like
 
  f - x = (foo x).bar
 
  with it. No more rewriting of pointfree code because of added
  arguments...
 
 So `-' as a pattern means `implicitly apply the RHS to whatever this  
 pattern matches'?  I like it.
 
Yes. I suppose _ is a better idea, or something else beginning with _,
as the rest of the characters could be functions.


-- 
(c) this sig last receiving data processing entity. Inspect headers for
past copyright information. All rights reserved. Unauthorised copying,
hiring, renting, public performance and/or broadcasting of this
signature prohibited. 

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


Re: [Haskell-cafe] Re: 0/0 1 == False

2008-01-14 Thread David Roundy
On Fri, Jan 11, 2008 at 07:10:20PM -0800, Jonathan Cast wrote:
 On 11 Jan 2008, at 10:12 AM, Achim Schneider wrote:
 
 David Roundy [EMAIL PROTECTED] wrote:
 
 Prelude let x=1e-300/1e300
 Prelude x
 0.0
 Prelude x/x
 NaN
 
 The true answer here is that x/x == 1.0 (not 0 or +Infinity), but
 there's no way for the computer to know this, so it's NaN.
 
 Didn't catch this the first time around, but: only to a physicist.

I don't understand what you're saying below.  Do you mean that the
true answer is not 1.0, or that it's not reasonable for the computer to
call it NaN?  Since 1.0 is the answer you get for high-precision
computations, it's hard to see how you can argue that it's a wrong answer.

 (I mean no disrespect to the author of darcs, but nevertheless the  
 point stands).  Back in the real world, 0 / 0 may be defined  
 arbitrarily, or left undefined.  (Defining it breaks the wonderful  
 property that, if lim (xn) = x, lim (yn) = y, and x/y = z, then lim  
 (xn / yn) = z.  This is considered a Bad Thing by real  
 mathematicians).  In fact, in integration theory 0 * inf = 0 for  
 certain 'multiplications', which gives the lie to 0 / 0.
-- 
David Roundy
Department of Physics
Oregon State University
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Computer Science Books using Haskell

2008-01-14 Thread Bryan O'Sullivan
PR Stanley wrote:

 Can the list recommend books that use Haskell - or any FP language but
 preferably Haskell - to illustrate the principles of compilers and/or
 algorithms?

Try Andrew Appel's Modern Compiler Implementation in ML
http://www.cs.princeton.edu/~appel/modern/ml/ which, as it uses SML for
everything, should translate quite readily to Haskell.

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


[Haskell-cafe] cabal and hpc?

2008-01-14 Thread Greg Fitzgerald
Has the Haskell Program Coverage tool been integrated into Cabal?  That is,
is there anything like runhaskell Setup.hs coverage to generate a coverage
report?

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


Re: [Haskell-cafe] cabal and hpc?

2008-01-14 Thread Don Stewart
garious:
Has the Haskell Program Coverage tool been integrated into Cabal?  That
is, is there anything like runhaskell Setup.hs coverage to generate a
coverage report?

Not yet, but definitely on the todo list (its a variant of the test
target, that would add -fhpc to each compile, so might be a bit tricky). 

Until then, you can hook hpc into your testsuite. I'd also recommend
linking to the hpc coverage logs from your cabal file's 'description'
field., until hackage can compute hpc results automatically.

Bring on the code quality!

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


Re: [Haskell-cafe] Getting frantic with FranTk

2008-01-14 Thread Justin Bailey
On Jan 13, 2008 5:54 AM, Torsten Otto [EMAIL PROTECTED] wrote:

 Howdy,

 with a just-in-time-learning approach I managed to teach my class of
 advanced high schoolers the basics of functional programming using
 Haskell (I had only used Scheme before). Now to show them that Haskell


That is awesome. I commend you. I only ever learned BASIC in school.


 I have Hugs installed at /opt/local/bin/hugs in MacOS 10.4/10.5. What
 do I do to get Hugs to recognize FranTk? I have downloaded it, but I
 can't even get the demo to work, none of the imports can be found:


I don't know much about Hugs and less about FranTk. You should probably
verify that FranTk is still compatible with recent versions of Hugs. If they
are, maybe try putting all the libraries in your current directory and then
look for  command line options to force hugs to look for them there?


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


Re: [Haskell-cafe] Yi editor tutorial

2008-01-14 Thread gwern0
On 2008.01.14 13:34:42 +, Andrew Birkett [EMAIL PROTECTED] scribbled 0.8K 
characters:
 [EMAIL PROTECTED] wrote:
 I'm going through them now, and I like them a lot. (Maybe I'll finally
 begin doing stuff with Yi!)
 Is there any particular reason you didn't put your tutorials on the
 Haskell wiki? I'd think they'd be good there.

 Cool, thanks.  :-)

 I agree it'll be a good idea to move it to the wiki, and I'll do that soon.
  On my own site, I can make lots of little changes locally and then
 atomically (well, quickly at least!) rsync the new version up onto the
 server.  It makes life easier when I'm likely to change around the top
 level structure.  The wiki makes a lot of sense though, because it's
 central and other people can extend the tutorial and fix bugs.

I'd say editing a wiki is even easier. :) But if you want to wait until you've 
gotten it to a state where you're happy with it, that's good too.

 It's also nice to be able to check the server logs and gauge interest too
 (about 5000 hits since yesterday).

 Andrew

True, but the interest won't last forever; so maybe after the Reddit links go 
quiescent?

--
gwern
rico Glock telex million propellants Warfare Ortega CNN 8182 Vauxhall


pgpokedMhOryB.pgp
Description: PGP signature
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: MonadPrompt + Gtk2Hs = ?

2008-01-14 Thread Felipe Lessa
On Jan 13, 2008 6:49 PM, apfelmus [EMAIL PROTECTED] wrote:
K. Claessen. Poor man's concurrency monad.
http://www.cs.chalmers.se/~koen/pubs/jfp99-monad.ps

P. Li, S. Zdancewic. Combining events and threads for scalable
network services.
http://www.seas.upenn.edu/~lipeng/homepage/papers/lz07pldi.pdf

Two great papers! Thanks for pointing them out!

  Eventually this feature rang some bells: you can save not only when you
  want to undo, but also when you want to ask something to the user.
  Unfortunately, I still haven't come up with a nice higher order function
  that generalizes this work without reinventing Prompt on an isomorphic type.

 Oh, what kind of generalization do you have in mind?

Leaking Prompt(..) in the export list to the GUI code seems wrong to
me, I like 'runPromptM' because it hides the Prompt(..) data type from
the user [module]. But after some rest I think I found a nice
corresponding function:

 contPromptM :: Monad m = (r - m ())
 - (forall a. p a - (a - m ()) - m ())
 - Prompt p r - m ()
 contPromptM done _ (PromptDone r)  = done r
 contPromptM done cont (Prompt p c) = cont p (contPromptM done cont . c)

This way all the Prompts get hidden so that 'lastAttempt' may be coded as

 lastAttempt' :: AttemptCode
 lastAttempt' showInfo entry button = guessGameNew = contPromptM done cont
 where
  cont :: forall a. GuessP a - (a - IO ()) - IO () -- signature needed
  cont (Print s) c = showInfo s  c ()
  cont Guess c = do
mfix $ \cid -
  onClicked button $ do {signalDisconnect cid;
 guess - entryGetText entry;
 c (read guess)}
return ()
  done attempts = showInfo $ You took  ++ show attempts ++  attempts.

Nice and clean, and much better to read as well. Now the only question
unanswered for me is if there are any relations between

(forall a. p a - (a - m ()) - m ())   -- from contPromptM

and

(ContT r m a - (a - m r) - m r)   -- from runContT

besides the fact that both carry a continuation. I have a feeling that
I am missing something clever here.

Cheers,

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


[Haskell-cafe] Strange GLFW linker problem on Linux

2008-01-14 Thread Peter Verswyvelen
Because apparently GHC works much better on Linux than Windows, I
switched to that platform. I'm currently trying Fedora 8. So now I'm
completely alone in the dark: no experience with Haskell, no experience
with Linux; I left decades of experience with Microsoft products behind
me ;-) 

I tried compiling GFLW (used by SOE) and a Haskell test app on my
laptop, and that worked fine. Then I installed Fedora on my desktop,
installed all development tools, and GLFW (both the C library and
Haskell wrapper) also compiled and linked fine, but when trying to link
the test app to GLFW, I got linker errors (see below).

It seems these symbols are defined in libXrandr, but I have both the
binary as the devel package installed:

[EMAIL PROTECTED] dev]# yum list installed | grep Xrandr
libXrandr.i386 1.2.2-1.fc8installed   
libXrandr-devel.i386   1.2.2-1.fc8installed   

So I have no idea what to do. The main difference between the laptop and
desktop is that I installed the NVidia drivers on the desktop manually
(first installed the kernel-devel package, and then downloaded and
installed the linux driver from the nvidia website)

Any hints?

Thanks,
Peter

Linker errors reported by ghc --make Main.hs:

/usr/local/lib/GLFW-0.1/ghc-6.8.2/libHSGLFW-0.1.a(x11_window.o): In
function `_glfwPlatformRefreshWindowParams':
x11_window.c:(.text+0x803): undefined reference to `XRRGetScreenInfo'
x11_window.c:(.text+0x80d): undefined reference to
`XRRConfigCurrentRate'
x11_window.c:(.text+0x81b): undefined reference to
`XRRFreeScreenConfigInfo'
/usr/local/lib/GLFW-0.1/ghc-6.8.2/libHSGLFW-0.1.a(x11_window.o): In
function `_glfwPlatformCloseWindow':
x11_window.c:(.text+0xb7a): undefined reference to `XRRGetScreenInfo'
x11_window.c:(.text+0xb9d): undefined reference to `XRRSetScreenConfig'
x11_window.c:(.text+0xba6): undefined reference to
`XRRFreeScreenConfigInfo'
/usr/local/lib/GLFW-0.1/ghc-6.8.2/libHSGLFW-0.1.a(x11_window.o): In
function `_glfwPlatformPollEvents':
x11_window.c:(.text+0x115b): undefined reference to
`XRRUpdateConfiguration'
/usr/local/lib/GLFW-0.1/ghc-6.8.2/libHSGLFW-0.1.a(x11_window.o): In
function `_glfwPlatformOpenWindow':
x11_window.c:(.text+0x1fa5): undefined reference to `XRRSelectInput'
/usr/local/lib/GLFW-0.1/ghc-6.8.2/libHSGLFW-0.1.a(x11_fullscreen.o): In
function `_glfwPlatformGetVideoModes':
x11_fullscreen.c:(.text+0x1ca): undefined reference to
`XRRGetScreenInfo'
x11_fullscreen.c:(.text+0x1db): undefined reference to `XRRConfigSizes'
x11_fullscreen.c:(.text+0x219): undefined reference to
`XRRFreeScreenConfigInfo'
/usr/local/lib/GLFW-0.1/ghc-6.8.2/libHSGLFW-0.1.a(x11_fullscreen.o): In
function `_glfwSetVideoModeMODE':
x11_fullscreen.c:(.text+0x329): undefined reference to
`XRRGetScreenInfo'
x11_fullscreen.c:(.text+0x344): undefined reference to
`XRRConfigCurrentConfiguration'
x11_fullscreen.c:(.text+0x394): undefined reference to
`XRRSetScreenConfigAndRate'
x11_fullscreen.c:(.text+0x3ac): undefined reference to
`XRRSetScreenConfig'
/usr/local/lib/GLFW-0.1/ghc-6.8.2/libHSGLFW-0.1.a(x11_fullscreen.o): In
function `_glfwGetClosestVideoMode':
x11_fullscreen.c:(.text+0x3fa): undefined reference to
`XRRGetScreenInfo'
x11_fullscreen.c:(.text+0x408): undefined reference to `XRRConfigSizes'
x11_fullscreen.c:(.text+0x48f): undefined reference to `XRRConfigRates'
x11_fullscreen.c:(.text+0x4dc): undefined reference to
`XRRFreeScreenConfigInfo'
x11_fullscreen.c:(.text+0x512): undefined reference to
`XRRFreeScreenConfigInfo'
/usr/local/lib/GLFW-0.1/ghc-6.8.2/libHSGLFW-0.1.a(x11_fullscreen.o): In
function `_glfwSetVideoModeMODE':
x11_fullscreen.c:(.text+0x3be): undefined reference to
`XRRFreeScreenConfigInfo'
/usr/local/lib/GLFW-0.1/ghc-6.8.2/libHSGLFW-0.1.a(x11_init.o): In
function `_glfwPlatformInit':
x11_init.c:(.text+0xea): undefined reference to `XRRQueryExtension'
collect2: ld returned 1 exit status



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


[Haskell-cafe] First Israel Haskell Event

2008-01-14 Thread B K
Hello all,

A Haskell gathering will take place for the first time in Israel:

Friday, January 18 2008 at 11:00 AM
Village Green, 33 Jaffa Rd, (corner of Rivlin St), Jerusalem

This will be an informal event where everyone can introduce themselves
and talk about their thoughts on Haskell. Everyone and anyone are
invited.

If you are in the area then please stop by, and email me with any questions.

Looking forward to an enlightening time,
Benny
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: Strange GLFW linker problem on Linux

2008-01-14 Thread Achim Schneider
Peter Verswyvelen [EMAIL PROTECTED] wrote:

 Any hints?
 
Look at ghc --make -v and make sure that ghc uses the right -l and -L
options when it calls the linker.

-- 
(c) this sig last receiving data processing entity. Inspect headers for
past copyright information. All rights reserved. Unauthorised copying,
hiring, renting, public performance and/or broadcasting of this
signature prohibited. 

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


Re: [Haskell-cafe] Getting frantic with FranTk

2008-01-14 Thread Torsten Otto
Thank you for the encouragement, Justin. Unfortunately I did try that.  
But it may also be where my basic understanding is missing: the  
libraries - do I have to somehow compile all the source or can I just  
use it? The source is Haskell, but it all comes with makefiles - are  
these for use with GHC or something more? I have a feeling I have to  
compile something somehow into some special location. I guess I'll  
just keep mucking around until I find a clue somewhere... All I know  
so far is how to use modules in Hugs which is enough for High School,  
but there is so much more out there...


The Readme points out for the underlying Tcl:
***
If on unix compile up the TclPrim.so library and run the tclexe
script, with hugs as the argument program ie
../bin/tclexe hugs
***
Ok, I can find tclexe, but how do I compile up the TclPrim? Probably  
pretty standard, I'm working on that (hints would still be  
appreciated...).
I'm confused at the point where the demo imports FranTk allright, but  
then I've hunted the web for missing modules which left me with  
something else missing:

Hugs :l Demos.lhs
ERROR ./Utils.hs - Error while importing DLL ./Utils.so:
dlopen(./Utils.so, 9): image not found

Foreign.Marshal.Alloc

I don't begin to understand what this is telling me...

If I get it to work, I'll put in on the Web for others to find.

Torsten


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


[Haskell-cafe] Haskell and GUI

2008-01-14 Thread Torsten Otto
Seeing my woes with FranTk - what else is out there that people use if  
a (simple) GUI is desired for a Haskell app? Just a few textboxes and  
a button or two would do me.


Thanks in advance!

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


Re: [Haskell-cafe] Haskell and GUI

2008-01-14 Thread Neil Mitchell
Hi Torsten,

 Seeing my woes with FranTk - what else is out there that people use if
 a (simple) GUI is desired for a Haskell app? Just a few textboxes and
 a button or two would do me.

Gtk2hs in GHC: http://www.haskell.org/gtk2hs/

Thanks

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


Re: [Haskell-cafe] Getting frantic with FranTk

2008-01-14 Thread Duncan Coutts

On Sun, 2008-01-13 at 14:54 +0100, Torsten Otto wrote:
 Howdy,
 
 with a just-in-time-learning approach I managed to teach my class of  
 advanced high schoolers the basics of functional programming using  
 Haskell (I had only used Scheme before). Now to show them that Haskell  
 is not a weirdo esoteric command line only language, I thought I'd end  
 the class with spoken output (easy enough with the System module and  
 say in Mac OS) and a GUI for input using FranTk.

Honestly, if you could get FranTk to work I'd be very impressed. My
impression is that it is extremely bitrotted. I would suggest trying one
of the other GUI libs that has seen some maintenance this century. (I'm
not joking - http://haskell.org/FranTk/ says it works with ghc-4.04
which was released in 1999)

That also probably means using ghc rather than hugs since most of the
modern GUI libs only work with ghc. The only exception is HGL, which is
rumoured to still work wit hugs (though again it has seen little to no
maintenance in recent years).

So I'd recommend the new SOE, OpenGL, Gtk2Hs or wxHaskell. All of those
come with some demos you can show off. SOE and OpenGL are purely for
doing drawings and animation (OpenGL is 3D of course). The other two are
full blown GUI toolkits.

http://haskell.org/soe
http://haskell.org/haskellwiki/Opengl
http://haskell.org/gtk2hs
http://wxhaskell.sourceforge.net/

Duncan

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


[Haskell-cafe] Re: MonadPrompt + Gtk2Hs = ?

2008-01-14 Thread apfelmus

Felipe Lessa wrote:

apfelmus wrote:

Oh, what kind of generalization do you have in mind?


Leaking Prompt(..) in the export list to the GUI code seems wrong to
me, I like 'runPromptM' because it hides the Prompt(..) data type from
the user [module]. But after some rest I think I found a nice
corresponding function:


contPromptM :: Monad m = (r - m ())
- (forall a. p a - (a - m ()) - m ())
- Prompt p r - m ()
contPromptM done _ (PromptDone r)  = done r
contPromptM done cont (Prompt p c) = cont p (contPromptM done cont . c)


This way all the Prompts get hidden so that 'lastAttempt' may be coded as


lastAttempt' :: AttemptCode
lastAttempt' showInfo entry button = guessGameNew = contPromptM done cont
where
 cont :: forall a. GuessP a - (a - IO ()) - IO () -- signature needed
 cont (Print s) c = showInfo s  c ()
 cont Guess c = do
   mfix $ \cid -
 onClicked button $ do {signalDisconnect cid;
guess - entryGetText entry;
c (read guess)}
   return ()
 done attempts = showInfo $ You took  ++ show attempts ++  attempts.


Nice and clean, and much better to read as well.


The type of  contPromptM  is even more general than that:

  casePromptOf' :: (r - f b)
- (forall a,b. p a - (a - f b) - f b)
- Prompt p r - f b
  casePromptOf' done cont (PromptDone r) = done r
  casePromptOf' done cont (Prompt p c  ) = cont p (casePromptOf' done 
cont . c)


In other words, it's (almost) the case expression / dual for the Prompt 
data type. So, only exporting this function and not the  Prompt 
constructors is like exporting only


  either :: (a - c) - (b - c) - Either a b - c

instead of  Left  and  Right  for pattern matching. This way, you can do 
(simulated) pattern matching with them, but may not use them for 
construction. Which is probably what you want here.



Except that there is a subtle difference, namely that  c  in  Prompt p c 
 has type


  c :: a - Prompt p r

whereas the argument to  casePromptOf'  expects it as

  c' = casePromptOf' done cont . c  :: a - f b

This means that not exporting constructors could reduce the number of 
programs that are possible to implement, but I can't (dis-)prove it. 
(That's basically the question at the end of 
http://thread.gmane.org/gmane.comp.lang.haskell.cafe/31842/focus=32218). 
Of course, you can just change the argument type to


  (forall a,b. p a - (a - Prompt p b) - f b)

for the full flexibility.


 Now the only question unanswered for me is if there are any
relations between

(forall a. p a - (a - m ()) - m ())   -- from contPromptM

and

(ContT r m a - (a - m r) - m r)   -- from runContT

besides the fact that both carry a continuation. I have a feeling that
I am missing something clever here.


The link to  ContT m a = (forall b . (a - m b) - m b)  is apparent in 
the case of  casePromptOf'  and is no surprise: you can omit  p a  and 
Prompt p r  entirely and implement them directly as continuations 
(thereby loosing the ability to use it with different m, which would 
defeat the whole point here.) See also


  Implementing the State Monad.
  http://article.gmane.org/gmane.comp.lang.haskell.cafe/31486

for the details.


Regards,
apfelmus

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


[Haskell-cafe] Re: Re: Displaying # of reductions after eachcomputation in ghci?

2008-01-14 Thread Ben Franksen
Lennart Augustsson wrote:
 What is a reduction anyway?

I am not an expert but I thought in lambda calculus one has primitive rules
for evaluation, e.g. beta reduction. So a reduction is a 'smallest step' in
reducing an expression to normal form, no?

Cheers
Ben

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


Re: [Haskell-cafe] Haskell and GUI

2008-01-14 Thread Sebastian Sylvan
On Jan 14, 2008 10:09 PM, Torsten Otto [EMAIL PROTECTED] wrote:

 Seeing my woes with FranTk - what else is out there that people use if
 a (simple) GUI is desired for a Haskell app? Just a few textboxes and
 a button or two would do me.

 Thanks in advance!


I like wxHaskell. It seems that GTK2HS is more active though, but I never
did manage to install it on windows.



-- 
Sebastian Sylvan
+44(0)7857-300802
UIN: 44640862
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: Displaying # of reductions after eachcomputation in ghci?

2008-01-14 Thread apfelmus

Ben Franksen wrote:

Lennart Augustsson wrote:

What is a reduction anyway?


I am not an expert but I thought in lambda calculus one has primitive rules
for evaluation, e.g. beta reduction. So a reduction is a 'smallest step' in
reducing an expression to normal form, no?


Yes and no, a single beta reduction step like

  (\x.c(d(e(f(x) g
 = c(d(e(f(g

may take 5 steps in some reduction strategies since you have to walk 
down the expression tree to find the variable and replace it with its 
value. In the end, seconds are a better measure for time :)



Regards,
apfelmus

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


Re: [Haskell-cafe] QuickCheck properties: export or not?

2008-01-14 Thread Don Stewart
paul:
 I was recently sent a patch for my Ranged Sets library which exported 
 all the QuickCheck properties.  I'd left them unexported on the grounds 
 that they clutter up the documentation (although simplified versions are 
 included in the documentation) and you can easily run them with the 
 standard quickcheck script.  The contributor, [EMAIL PROTECTED] 
 suggested an explicit test harness instead.
 
 I'm not unduly bothered one way or the other, but I thought I'd ask the 
 community: what is the best practice here?

Most libs seem to include an external Properties.hs or similar file.
The only tension there is how much do you need to test thoroughly.
You might still end up exporting more than you wish to.

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


[Haskell-cafe] Re: Why purely in haskell?

2008-01-14 Thread Ben Franksen
[EMAIL PROTECTED] wrote:
 Wolfgang Jeltsch wrote:
 My impression is that staying close to math is good from a software
 technology point of view.  And it has the advantage of less confusion
 for the user.
 
 What does it mean close to math?
 How close? Does math raise exceptions upon the division by zero?
 Does *MATH* answer the question what is: (0/0)==(0/0) ? Nope!

Exactly. So why try to give an answer in Haskell? MATH says: the expression
0/0 is undefined, thus comparing (0/0)==(0/0) is undefined, too. I would
expect Haskell to say the same.

Cheers
Ben

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


[Haskell-cafe] QuickCheck properties: export or not?

2008-01-14 Thread Paul Johnson
I was recently sent a patch for my Ranged Sets library which exported 
all the QuickCheck properties.  I'd left them unexported on the grounds 
that they clutter up the documentation (although simplified versions are 
included in the documentation) and you can easily run them with the 
standard quickcheck script.  The contributor, [EMAIL PROTECTED] 
suggested an explicit test harness instead.


I'm not unduly bothered one way or the other, but I thought I'd ask the 
community: what is the best practice here?


Paul.

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


Re: [Haskell-cafe] QuickCheck properties: export or not?

2008-01-14 Thread Don Stewart
ndmitchell:
 Hi
 
  standard quickcheck script.  The contributor, [EMAIL PROTECTED]
  suggested an explicit test harness instead.
 
 Unless you have a test harness (ideally through Cabal), the properties
 will go out of sync, and you'll forget to run them. Tests are good,
 they should be able to be invoked as standard. Every time I've *not*
 done a test harness, and then relied on manually remembering things or
 putting them in the documentation, it has gone wrong very quickly!

I usually have a main = runTests file, and then use darcs to ensure the
tests are up to date:

$ cat _darcs/prefs/prefs 
test ghc -no-recomp -Onot -fasm -itests tests/Unit.hs --make -odir /tmp  
tests/Unit

darcs will run the testsuite, and it needs to pass, before a commit will
be accepted. We do a similar thing for xmonad.

The test command to run on every commit can be set via,

darcs setpref test my test command

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


[Haskell-cafe] Re: Why purely in haskell?

2008-01-14 Thread Achim Schneider
[EMAIL PROTECTED] wrote:

 When math says that something is undefined, in my little brain I
 understand that there is no answer.
 NO answer. 

Math doesn't say that something is undefined, but tells you that you
did something that's illegal, i.e. impossible, in the system you're
working with.

Trying to divide by zero is like trying to break out of a mental asylum
with a banana: It's neither a good tool to fight your way free, as
well as using it will get you back into the asylum, by system-inherent
laws.

The mathematically right, and only really sane way to handle such
things is not to do them at all, which would change Haskell's semantics
rather drastically.

There just is no unsafePerformMath :: Math a - a.

-- 
(c) this sig last receiving data processing entity. Inspect headers for
past copyright information. All rights reserved. Unauthorised copying,
hiring, renting, public performance and/or broadcasting of this
signature prohibited. 

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


[Haskell-cafe] Re: Why purely in haskell?

2008-01-14 Thread jerzy . karczmarczuk
Ben Franksen writes: 


[EMAIL PROTECTED] wrote:

...

Does *MATH* answer the question what is: (0/0)==(0/0) ? Nope!


Exactly. So why try to give an answer in Haskell? MATH says: the 
expression 0/0 is undefined, thus comparing (0/0)==(0/0) is undefined, 
too. I would expect Haskell to say the same.


I don't know whether you are serious, or you are pulling my leg...
Let's suppose that it is serious. 


When math says that something is undefined, in my little brain I understand
that there is no answer.
NO answer. 


Is this the undefined you want to have? The bottom non-termination? Now,
this is obviously the *worst* possible reaction of the system, the IEEE
indefinite is much better, at least you know what had happened. 


Would you propose the non-termination as the issue of all errors, such as
negative argument to the real sqrt, etc?
Well, as you wish... But don't write medical software, please... 



Jerzy Karczmarczuk 



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


Re: [Haskell-cafe] Haskell and GUI

2008-01-14 Thread Thomas Davie
There's also the HOC (Haskell Objective-C bridge), which lets you use  
Apple's Cocoa APIs.


Bob

On 14 Jan 2008, at 22:09, Torsten Otto wrote:

Seeing my woes with FranTk - what else is out there that people use  
if a (simple) GUI is desired for a Haskell app? Just a few textboxes  
and a button or two would do me.


Thanks in advance!

Regards,
Torsten
___
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] Re: Why purely in haskell?

2008-01-14 Thread jerzy . karczmarczuk
Achim Schneider writes: 

[EMAIL PROTECTED] wrote: 


When math says that something is undefined, in my little brain I
understand that there is no answer. 



Math doesn't say that something is undefined, but tells you that you
did something that's illegal, i.e. impossible, in the system you're
working with.


Yeah, sure. 


Thanks God, we have on this list a fellow who gets direct telephone calls
from her Majesty the Queen Mathematics. And knows better.
Go tell to all people who use the word 'undefined' in math that they are
stupid. At least, more stupid than you. 


http://mathworld.wolfram.com/Undefined.html
http://en.wikipedia.org/wiki/Defined_and_undefined
http://mathforum.org/library/drmath/view/53336.html
http://encarta.msn.com/encyclopedia_761568582/Calculus_(mathematics).html
etc. 

Jerzy Karczmarczuk 



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


Re: [Haskell-cafe] Re: Why purely in haskell?

2008-01-14 Thread Luke Palmer
On Jan 15, 2008 12:29 AM,  [EMAIL PROTECTED] wrote:
 Ben Franksen writes:

  [EMAIL PROTECTED] wrote:
 ...
  Does *MATH* answer the question what is: (0/0)==(0/0) ? Nope!
 
  Exactly. So why try to give an answer in Haskell? MATH says: the
  expression 0/0 is undefined, thus comparing (0/0)==(0/0) is undefined,
  too. I would expect Haskell to say the same.

 I don't know whether you are serious, or you are pulling my leg...
 Let's suppose that it is serious.

 When math says that something is undefined, in my little brain I understand
 that there is no answer.
 NO answer.

I'm not sure if I'm agreeing or disagreeing with you here.  Depends on exactly
what you mean by no answer.

When I was a TA for calculus 2, students were presented with something like the
following problem:

  Find the limit:

lim  (sin x / x)
x-0

And proceeding, they would reduce this to:

   sin 0 / 0
   0 / 0

Look in the book that said 0/0 is undefined, and write undefined
on the paper
as if that were the answer.

For the calculus uninclined (I figure that is a vast minority on this list), the
answer is 1.  In that case, undefined meant you did the problem
wrong.  And the
error was precisely when they wrote 0 on the bottom of the division sign.

To me, when math says undefined... let me stop there.  Math doesn't
say undefined.
Instead, when mathematicians say undefined, they usually mean not
that the question
has no answer, but that the question you're asking doesn't even make
sense as a question.
For example, division is only defined when the denominator is not 0.
Asking what the
answer to 0/0 is is like asking what happens when I move the king
across the board in
chess?. That operation doesn't even make sense with those arguments.

However, Haskell is not blessed (cursed?) with dependent types, so it
is forced to
answer such questions even though they don't make sense.  But looking to math
(at least with a classical interpretation of numbers) is just not going to work.

Personally, I loathe the existence of NaN and +-Infinity in floating
point types.
Someone here made an enlightinging point encouraging us to think of
floating point
numbers not as numbers but as intervals.  That makes me slightly more
okay with the
infinities, but NaN still bugs me.  I'd prefer an error: Haskell's way
of saying you
did the problem wrong.  That would be most useful in the kinds of
things I do with
floating point numbers (games).  But there are probably other areas
where the IEEE
semantics are more useful.

Well... that paragraph was just a long-winded way of saying I have an
opinion, but
I don't think it's very important

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


[Haskell-cafe] Re: Why purely in haskell?

2008-01-14 Thread Achim Schneider
[EMAIL PROTECTED] wrote:

 Achim Schneider writes: 
 
  [EMAIL PROTECTED] wrote: 
  
  When math says that something is undefined, in my little brain I
  understand that there is no answer. 
 
  Math doesn't say that something is undefined, but tells you that you
  did something that's illegal, i.e. impossible, in the system you're
  working with.
 
 Yeah, sure. 
 
 Thanks God, we have on this list a fellow who gets direct telephone
 calls from her Majesty the Queen Mathematics. And knows better.
 Go tell to all people who use the word 'undefined' in math that they
 are stupid. At least, more stupid than you. 
 
That's funny, you just proved that I am more stupid than myself, as I
use the term. For things that are illegal or impossible in the system
I'm working with. It's not that I posted it because I didn't agree
with what you said.


-- 
(c) this sig last receiving data processing entity. Inspect headers for
past copyright information. All rights reserved. Unauthorised copying,
hiring, renting, public performance and/or broadcasting of this
signature prohibited. 

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


Re: [Haskell-cafe] fast fractional part of floating point number - modf?

2008-01-14 Thread John Meacham
On Sun, Jan 13, 2008 at 01:08:49AM +0100, Henning Thielemann wrote:
 Is there a fast and reliable way to compute the fraction of a floating
 point number?

no, and this has bothered me to the point I consider it a bug in the
language spec that all 'rounding' style functions give back an integral
type. These sort of operations are often used on floating point values
when you want the same type out you put in, and in particular you want
it to handle things like infinities and nan's properly which the
conversion through integral does not (plus, these usually coorespond to
a single machine instruction so are more 'primitive' in a sense and thus
better building blocks for a RealFrac class).

To alleviate this I added the following to the RealFrac class in jhc

-- TODO Doubles
class  (Real a, Fractional a) = RealFrac a  where

...
-- new stuff added by jhc
properFractionf   :: a - (a,a)
truncatef, roundf :: a - a
ceilingf, floorf  :: a - a

truncatef x   =  m  where (m,_) = properFractionf x
roundf x  =  fromInteger (round x)
ceilingf x=  if r  0 then n + 1 else n
where (n,r) = properFractionf x
floorf x  =  if r  0 then n - 1 else n
where (n,r) = properFractionf x


the meaning should be clear, they perform the same operation as their
non f counterparts but maintain the same type.

John


-- 
John Meacham - ⑆repetae.net⑆john⑈
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: 0/0 1 == False

2008-01-14 Thread Jonathan Cast

On 14 Jan 2008, at 9:56 AM, David Roundy wrote:


On Fri, Jan 11, 2008 at 07:10:20PM -0800, Jonathan Cast wrote:

On 11 Jan 2008, at 10:12 AM, Achim Schneider wrote:


David Roundy [EMAIL PROTECTED] wrote:


Prelude let x=1e-300/1e300
Prelude x
0.0
Prelude x/x
NaN

The true answer here is that x/x == 1.0 (not 0 or +Infinity), but
there's no way for the computer to know this, so it's NaN.


Ah.  My apologies.  Must remember to read first, then flame...

You are right that, in Ratio Integer, you get this result.  But you  
can't get that answer in Double.


jcc

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


Re: [Haskell-cafe] Re: MonadPrompt + Gtk2Hs = ?

2008-01-14 Thread Ryan Ingram
On Jan 14, 2008 2:28 PM, Felipe Lessa [EMAIL PROTECTED] wrote:
  lastAttempt' :: AttemptCode
  lastAttempt' showInfo entry button = guessGameNew = contPromptM done cont
  where
   cont :: forall a. GuessP a - (a - IO ()) - IO () -- signature needed
   cont (Print s) c = showInfo s  c ()
   cont Guess c = do
 mfix $ \cid -
   onClicked button $ do {signalDisconnect cid;
  guess - entryGetText entry;
  c (read guess)}
 return ()
   done attempts = showInfo $ You took  ++ show attempts ++  attempts.

Excellent work; I love it.

I'll definitely have to give this a try when I get back from vacation.
 I'd been wondering what the best way to interface with GUI code is
and it's nice to have a sample to work from.

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


[Haskell-cafe] Re: [Haskell] ANNOUNCE: HStringTemplate -- An Elegant, Functional, Nifty Templating Engine for Haskell

2008-01-14 Thread Sterling Clover
I'm absolutely planning to get it up there, but it needs a bit more  
work first. Just today, gwern sent a bunch of very nice patches that  
cleaned up some -Wall messages, and fixed a build issue with 6.8. And  
then, thanks to an email from Martin Lütke, I realized that I had  
foolishly not exported a function to query groups, because I was too  
worried about functions to compose them! So yeah, letting your baby  
out into the world is a bit scary, but everyone's been quite helpful  
and supportive so far, and hopefully I'll feel ready to get it on  
hackage in the next week or two.


(Of course, after that, I'm now puzzling over the best typesafe ways  
to represent html entity encoding and url escaping, planning to pull  
together some more documentation on all the loveliness of the  
stringtemplate grammar, there are more quickcheck properties to be  
written, you know.. the usual. :-) )


--S

On Jan 14, 2008, at 3:09 AM, Don Stewart wrote:


s.clover:

HStringTemplate is a port of Terrence Parr’s lovely StringTemplate
(http://www.stringtemplate.org) engine to Haskell.

It is available, cabalized, at:
darcs get http://code.haskell.org/HStringTemplate/


Looks very useful!  Will this be on hackage.haskell.org soon?

I can't wait to:

cabal install HStringTemplate

:)

-- Don


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


Re: [Haskell-cafe] Re: Re: Displaying # of reductions after eachcomputation in ghci?

2008-01-14 Thread Lennart Augustsson
In lambda calculus you can take a beta reduction as the step.
But Haskell is not normally implemented by lambda calculus so you have to
pick something else.
There are measures of reduction that you can come up with but they will
vary, e.g., by compiler, optimization level, etc.
I think time is a much more interesting measure, since that's what you
really care about in the end.

On Jan 14, 2008 2:03 PM, Ben Franksen [EMAIL PROTECTED] wrote:

 Lennart Augustsson wrote:
  What is a reduction anyway?

 I am not an expert but I thought in lambda calculus one has primitive
 rules
 for evaluation, e.g. beta reduction. So a reduction is a 'smallest step'
 in
 reducing an expression to normal form, no?

 Cheers
 Ben

 ___
 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] ErrorT and catchError question

2008-01-14 Thread Adam Smyczek

Hi,

I'm trying to use ErrorT transformer based
on Don Stewart's Shell example:
http://cgi.cse.unsw.edu.au/~dons/blog/2007/03/10#programmable-semicolons
It's probably a trivial question, but I cannot figure out
how to implement the catchError function in:

instance MonadError String Shell where
throwError  = error . (Shell failed: ++)
catchError l h = ???

Thanks for help,
Adam


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


Re: [Haskell-cafe] QuickCheck properties: export or not?

2008-01-14 Thread David Benbennick
I think that type classes with nontrivial requirements should export
QuickCheck properties that test those requirements.  For example, the
Data.Monoid module
(http://haskell.org/ghc/docs/latest/html/libraries/base/Data-Monoid.html)
could export properties that check the monoid laws (for an Arbitrary
Monoid with Eq).  That would serve as a formal specification of the
requirements, and allow any user to check that their implementation is
right.

-- 
I'm doing Science and I'm still alive.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] ErrorT and catchError question

2008-01-14 Thread Brandon S. Allbery KF8NH


On Jan 15, 2008, at 0:28 , Adam Smyczek wrote:


It's probably a trivial question, but I cannot figure out
how to implement the catchError function in:

instance MonadError String Shell where
throwError  = error . (Shell failed: ++)
catchError l h = ???


Take a look at Control.Exception.catch for starters.

--
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] [EMAIL PROTECTED]
system administrator [openafs,heimdal,too many hats] [EMAIL PROTECTED]
electrical and computer engineering, carnegie mellon universityKF8NH


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


Re: [Haskell-cafe] fast fractional part of floating point number - modf?

2008-01-14 Thread Henning Thielemann

On Mon, 14 Jan 2008, John Meacham wrote:

 On Sun, Jan 13, 2008 at 01:08:49AM +0100, Henning Thielemann wrote:
  Is there a fast and reliable way to compute the fraction of a floating
  point number?

 no, and this has bothered me to the point I consider it a bug in the
 language spec that all 'rounding' style functions give back an integral
 type.

I find returning an Integral is appropriate. The type expresses perfectly
what kind of values you can expect. Sure, there should be some
optimization rule like
  fromInteger (round x)  =  roundf x  .
 However, the 'fraction' function gets a fraction and returns a fraction
and doesn't care about the type of the integer part. As I see this is also
missing from your RealFrac class extension.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe