Re: [Haskell-cafe] Functional Parsers in GHCI

2010-05-23 Thread Ivan Lazar Miljenovic
Amiruddin Nagri amir.na...@gmail.com writes:

 Hi All,

 I am a newbie to Haskell, and have been using Programming in Haskell along
 with Eric Meijer videos covering the book syllabus. I am currently on
 Chapter 8 Functional Parsers, and trying to implement few of the examples
 given in the book.

 Following is the example :

 item = \inp - case inp of
 [] - []
 (x:xs) - [(x,xs)]

 p = do  x - item
 y - item
 z - item
 return (x,y,z)

 =

 When I compile it using GHCI, I get the following error :

 [1 of 1] Compiling Main ( parser.hs, interpreted )

 parser.hs:5:8:
 No instance for (Monad ((-) [t]))
   arising from a do statement at parser.hs:5:8-16

Try importing Control.Monad.Instances and see if that gets it to work.

 Possible fix: add an instance declaration for (Monad ((-) [t]))
 In a stmt of a 'do' expression: x - item
 In the expression:
 do x - item
y - item
z - item
return (x, y, z)
 In the definition of `p':
 p = do x - item
y - item
z - item

 Failed, modules loaded: none.

 =

 I tried googling for samples, above error message etc. But not getting to
 solution. Can anyone guide me as to what am I doing wrong and how can I fix
 this.

 Regards,
 Amiruddin Nagri,
 India

 GTalk : amir.na...@gmail.com
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe

-- 
Ivan Lazar Miljenovic
ivan.miljeno...@gmail.com
IvanMiljenovic.wordpress.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Functional Parsers in GHCI

2010-05-23 Thread Stephen Tetley
Hi

The code in this chapter isn't actually Haskell - some details are
elided to make the presentation clearer. To run the code you want to
get the file mentioned in the closing remarks of the chapter (page 85,
section 8.9).


http://www.cs.nott.ac.uk/~gmh/book.html

http://www.cs.nott.ac.uk/~gmh/parser.lhs

Best wishes

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


Re: [Haskell-cafe] Functional Parsers in GHCI

2010-05-23 Thread Stephen Tetley
On 23 May 2010 08:41, Stephen Tetley stephen.tet...@gmail.com wrote:

 The code in this chapter isn't actually Haskell - some details are
 elided to make the presentation clearer.


There is also the paper - Monadic Parsing in Haskell - which presents
the parsers as legal Haskell98:

http://www.cs.nott.ac.uk/~gmh/pearl.pdf
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: Proof question -- (==) over Bool

2010-05-23 Thread Jon Fairbairn
Alexander Solla a...@2piix.com writes:

 On May 22, 2010, at 1:32 AM, Jon Fairbairn wrote:

 Since Bool is a type, and all Haskell types include ⊥, you need
 to add conditions in your proofs to exclude it.

 Not really.  Bottom isn't a value, so much as an expression
 for computations that don't refer to real values.  It's
 close enough to  be treated as a value in many contexts, but
 this isn't one of them.

It seems to me relevant here, because one of the uses to which
one might put the symmetry rule is to replace an expression “e1
== e2” with “e2 == e1”, which can turn a programme that
terminates into a programme that does not.

-- 
Jón Fairbairn jon.fairba...@cl.cam.ac.uk
http://www.chaos.org.uk/~jf/Stuff-I-dont-want.html  (updated 2009-01-31)

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


Re: [Haskell-cafe] Re: Proof question -- (==) over Bool

2010-05-23 Thread Alexander Solla


On May 23, 2010, at 1:35 AM, Jon Fairbairn wrote:


It seems to me relevant here, because one of the uses to which
one might put the symmetry rule is to replace an expression “e1
== e2” with “e2 == e1”, which can turn a programme that
terminates into a programme that does not.


I don't see how that can be (but if you have a counter example, please  
show us).  Even if we extend == to apply to equivalence classes of  
bottom values, we would have to evaluate both e1 and e2 to determine  
the value of e1 == e2 or e2 == e1.


Prelude undefined == True
*** Exception: Prelude.undefined
Prelude True == undefined
*** Exception: Prelude.undefined
Prelude undefined == undefined
*** Exception: Prelude.undefined

That is, if one case is exceptional, so is the other.

You can't really even quantify over bottoms in Haskell, as a  
language.  The language runtime is able to do some evaluation and  
sometimes figure out that a bottom is undefined.  Sometimes.  But the  
runtime isn't a part of the language.  The runtime is an  
implementation of the language's interpetation function.  Bottoms are  
equivalent by conceptual fiat (in other words, vacuously) since not  
even the id :: a - a function applies to them.___

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


Re: [Haskell-cafe] Re: Proof question -- (==) over Bool

2010-05-23 Thread Lennart Augustsson
For Bool, I'm not sure, but for, e.g., () it's certainly true.
Take this definition of ==
  () == _  =  True
Using case analysis of just the constructors, ignoring the value
bottom, you can easily prove symmetry.
But '() == undefined' terminates, whereas 'undefined == ()' does not.

Ignore bottom at your own peril.

BTW, the id function works fine on bottom, both from a semantic and
implementation point of view.

  -- Lennart

On Sun, May 23, 2010 at 11:23 AM, Alexander Solla a...@2piix.com wrote:

 On May 23, 2010, at 1:35 AM, Jon Fairbairn wrote:

 It seems to me relevant here, because one of the uses to which
 one might put the symmetry rule is to replace an expression “e1
 == e2” with “e2 == e1”, which can turn a programme that
 terminates into a programme that does not.

 I don't see how that can be (but if you have a counter example, please show
 us).  Even if we extend == to apply to equivalence classes of bottom values,
 we would have to evaluate both e1 and e2 to determine the value of e1 == e2
 or e2 == e1.

 Prelude undefined == True
 *** Exception: Prelude.undefined
 Prelude True == undefined
 *** Exception: Prelude.undefined
 Prelude undefined == undefined
 *** Exception: Prelude.undefined

 That is, if one case is exceptional, so is the other.

 You can't really even quantify over bottoms in Haskell, as a language.  The
 language runtime is able to do some evaluation and sometimes figure out that
 a bottom is undefined.  Sometimes.  But the runtime isn't a part of the
 language.  The runtime is an implementation of the language's interpetation
 function.  Bottoms are equivalent by conceptual fiat (in other words,
 vacuously) since not even the id :: a - a function applies to
 them.___
 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] double2Float is faster than (fromRational . toRational)

2010-05-23 Thread wren ng thornton

Daniel Fischer wrote:
There are more rules elsewhere. If you compile with optimisations, GHC 
turns your realToFrac into double2Float# nicely, so it's okay to use 
realToFrac.
However, without optimisations, no rules fire, so you'll get 
(fromRational . toRational).


That must be new, because it didn't used to be the case. Also, rewrite 
rules can be fragile. Not to mention that the (fromRational . 
toRational) definition is incorrect for converting between Float and 
Double because Rational cannot properly encode the transfinite values in 
Float/Double.


The robust solution is to use the RealToFrac class from the logfloat 
package:


http://hackage.haskell.org/packages/archive/logfloat/0.12.1/doc/html/Data-Number-RealToFrac.html

--
Live well,
~wren
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Declaring a tuple of instances of Enums as an instance of the Enum class

2010-05-23 Thread R J

Say I've got a type Month declared as an instance of the Enum class, and a 
type MonthPair declared as a pair of months:
data Month =  January   |  February 
  |  March   |  April   
|  May   |  June   
|  July   |  August   |  
September   |  October   |  
November   |  December   
deriving (Eq, Enum, Ord, Show)
type MonthPair =  (Month, Month)   deriving 
(Enum)
The deriving on MonthPair gives me the error parse error on input 
'deriving'.
Why is this error generated?  Is there a syntax error, or is there a conceptual 
problem with enumerating a Cartesian product, such as Month x Month?  The 
cardinality of the Cartesian product is finite (including the bottom values, 
cardinality = 1 + (12 + 1)*(12 + 1) = 170), and so the product is amenable at 
least to some arbitrary enumeration (such as Cantor's diagonal method).
Thanks. 

  
_
The New Busy think 9 to 5 is a cute idea. Combine multiple calendars with 
Hotmail. 
http://www.windowslive.com/campaign/thenewbusy?tile=multicalendarocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_5___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] double2Float is faster than (fromRational . toRational)

2010-05-23 Thread Daniel Fischer
On Sunday 23 May 2010 13:12:16, wren ng thornton wrote:
 Daniel Fischer wrote:
  There are more rules elsewhere. If you compile with optimisations, GHC
  turns your realToFrac into double2Float# nicely, so it's okay to use
  realToFrac.
  However, without optimisations, no rules fire, so you'll get
  (fromRational . toRational).

 That must be new, because it didn't used to be the case.

GHC.Float.lhs contains the rules for
(realToFrac :: (Float|Double) - (Float|Double))
since 6.8.1 at least, I didn't look at previous releases.

 Also, rewrite rules can be fragile.

True. I don't see how you would construct such a situation for these rules, 
but if several rules match a piece of code, you can't know which one fires 
first, perhaps making the others not match anymore.
And inlining may prevent rules from matching, too.

If you need rewrite rules, it is advisable to check whether they actually 
fired.

 Not to mention that the (fromRational . toRational) definition is
 incorrect for converting between Float and Double because Rational
 cannot properly encode the transfinite values in Float/Double.

 The robust solution is to use the RealToFrac class from the logfloat
 package:

 http://hackage.haskell.org/packages/archive/logfloat/0.12.1/doc/html/Dat
a-Number-RealToFrac.html

Yes.

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


Re: [Haskell-cafe] Declaring a tuple of instances of Enums as an instance of the Enum class

2010-05-23 Thread Ivan Lazar Miljenovic
R J rj248...@hotmail.com writes:

 Say I've got a type Month declared as an instance of the Enum
 class, and a type MonthPair declared as a pair of months:
 data Month = January | February | March | April | May | June | July |
 August | September | October | November | December deriving (Eq, Enum,
 Ord, Show)
 type MonthPair = (Month, Month) deriving (Enum)
 The deriving on MonthPair gives me the error parse error on input
 deriving'.

You can't derive instances for type aliases (as its mainly there for
documentation reasons, etc.).  However, pairs don't have Enum instances
by default so you still can't use its instance.

If you define data MonthPair = MonthPair Month Month then you should
be able to derive Enum.

-- 
Ivan Lazar Miljenovic
ivan.miljeno...@gmail.com
IvanMiljenovic.wordpress.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Haskell and scripting

2010-05-23 Thread Limestraël
As some people were advising me to peek in Lua, I did so. Well, I find it
far too laxist and bug prone : weak-typing, variables which are global by
default, non-existing variables which contain nil when we access them
instead of failing...
I mean, I like Haskell especially because it is rigorous and because the
type-system continually saves the day: Lua is the total opposite. I don't
hope to enjoy Haskell's tightness with a scripting language, but being
interpreted and dynamically typed doesn't prevent to be somewhat painstaking
(Python is, for instance)**.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Declaring a tuple of instances of Enums as an instance of the Enum class

2010-05-23 Thread Daniel Fischer
On Sunday 23 May 2010 15:33:58, Ivan Lazar Miljenovic wrote:
 R J rj248...@hotmail.com writes:
  Say I've got a type Month declared as an instance of the Enum
  class, and a type MonthPair declared as a pair of months:
  data Month = January | February | March | April | May | June | July |
  August | September | October | November | December deriving (Eq, Enum,
  Ord, Show)
  type MonthPair = (Month, Month) deriving (Enum)
  The deriving on MonthPair gives me the error parse error on input
  deriving'.

 You can't derive instances for type aliases (as its mainly there for
 documentation reasons, etc.).  However, pairs don't have Enum instances
 by default so you still can't use its instance.

 If you define data MonthPair = MonthPair Month Month then you should
 be able to derive Enum.

No, per the report (http://haskell.org/onlinereport/derived.html)

Derived instance declarations for the class Enum are only possible for 
enumerations (data types with only nullary constructors).

You can derive Enum instances for newtype wrappers around Enums with GHC 
(possibly others), but for types such as MonthPair you have to give the 
instances yourself (maybe you can let them be generated by tools like 
Derive).
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Declaring a tuple of instances of Enums as an instance of the Enum class

2010-05-23 Thread Ivan Lazar Miljenovic
Daniel Fischer daniel.is.fisc...@web.de writes:

 On Sunday 23 May 2010 15:33:58, Ivan Lazar Miljenovic wrote:
 R J rj248...@hotmail.com writes:
  Say I've got a type Month declared as an instance of the Enum
  class, and a type MonthPair declared as a pair of months:
  data Month = January | February | March | April | May | June | July |
  August | September | October | November | December deriving (Eq, Enum,
  Ord, Show)
  type MonthPair = (Month, Month) deriving (Enum)
  The deriving on MonthPair gives me the error parse error on input
  deriving'.

 You can't derive instances for type aliases (as its mainly there for
 documentation reasons, etc.).  However, pairs don't have Enum instances
 by default so you still can't use its instance.

 If you define data MonthPair = MonthPair Month Month then you should
 be able to derive Enum.

 No, per the report (http://haskell.org/onlinereport/derived.html)

 Derived instance declarations for the class Enum are only possible for 
 enumerations (data types with only nullary constructors).

Whoops, you're right.

-- 
Ivan Lazar Miljenovic
ivan.miljeno...@gmail.com
IvanMiljenovic.wordpress.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Clean proof?

2010-05-23 Thread R J

Given the following definition of either, from the prelude:
either  :: (a - c, b - c) - Either a b - c
either (f, g) (Left x)  =  f xeither (f, g) (Right x) =  g x
what's a clean proof that:
h . either (f, g) = either (h . f, g . h)?
The only proof I can think of requires the introduction of an anonymous 
function of z, with case analysis on z (Case 1:  z = Left x, Case 2:  z = Right 
y), but the use of anonymous functions and case analysis is ugly, and I'm not 
sure how to tie up the two cases neatly at the end.  For example here's the 
Left case:
  h . either (f, g)  ={definition of \}  \z - (h . either (f, 
g)) z  ={definition of .}  \z - (h (either (f, g) z)
  ={definition of either in case z = Left x}  \z - (h (f x))  =
{definition of .}  \z - (h . f) x  ={definition of .}  h . f 
Thanks.   
_
The New Busy is not the too busy. Combine all your e-mail accounts with Hotmail.
http://www.windowslive.com/campaign/thenewbusy?tile=multiaccountocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_4___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Clean proof?

2010-05-23 Thread Lennart Augustsson
There is no clean proof of that statement because it is false.
(Consider the argument 'undefined'.)

2010/5/23 R J rj248...@hotmail.com:
 Given the following definition of either, from the prelude:
     either                      :: (a - c, b - c) - Either a b - c
     either (f, g) (Left x)      =  f x
     either (f, g) (Right x)     =  g x
 what's a clean proof that:
     h . either (f, g) = either (h . f, g . h)?
 The only proof I can think of requires the introduction of an anonymous
 function of z, with case analysis on z (Case 1:  z = Left x, Case 2:  z =
 Right y), but the use of anonymous functions and case analysis is ugly, and
 I'm not sure how to tie up the two cases neatly at the end.  For example
 here's the Left case:
       h . either (f, g)
   =    {definition of \}
       \z - (h . either (f, g)) z
   =    {definition of .}
       \z - (h (either (f, g) z)
   =    {definition of either in case z = Left x}
       \z - (h (f x))
   =    {definition of .}
       \z - (h . f) x
   =    {definition of .}
       h . f

 Thanks.
 
 The New Busy is not the too busy. Combine all your e-mail accounts with
 Hotmail. Get busy.
 ___
 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] Clean proof -- correction

2010-05-23 Thread R J

Correction:  the theorem is
h . either (f, g) = either (h . f, h . g)

(Thanks to Lennart for pointing out the typo.)
From: rj248...@hotmail.com
To: haskell-cafe@haskell.org
Subject: Clean proof?
Date: Sun, 23 May 2010 15:41:20 +








Given the following definition of either, from the prelude:
either  :: (a - c, b - c) - Either a b - c
either (f, g) (Left x)  =  f xeither (f, g) (Right x) =  g x
what's a clean proof that:
h . either (f, g) = either (h . f, g . h)?
The only proof I can think of requires the introduction of an anonymous 
function of z, with case analysis on z (Case 1:  z = Left x, Case 2:  z = Right 
y), but the use of anonymous functions and case analysis is ugly, and I'm not 
sure how to tie up the two cases neatly at the end.  For example here's the 
Left case:
  h . either (f, g)  ={definition of \}  \z - (h . either (f, 
g)) z  ={definition of .}  \z - (h (either (f, g) z)
  ={definition of either in case z = Left x}  \z - (h (f x))  =
{definition of .}  \z - (h . f) x  ={definition of .}  h . f 
Thanks.   
The New Busy is not the too busy. Combine all your e-mail accounts with 
Hotmail. Get busy.
_
The New Busy is not the old busy. Search, chat and e-mail from your inbox.
http://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_3___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Clean proof -- correction

2010-05-23 Thread Per Vognsen
Lennart wasn't pointing out a typo. He was pointing out a fundamental
issue with such identities in a partial call-by-name language. If

h = const 42

then

(h . either (f, g)) undefined

evaluates to 42. But the evaluation of

(either (h . f, h . g)) undefined

is non-terminating.

This is a canonical example of an equation that holds in a partial
call-by-value language but not in a partial call-by-name language:

CBV has more sum equations; CBN has more product equations.

-Per

2010/5/23 R J rj248...@hotmail.com:
 Correction:  the theorem is
     h . either (f, g) = either (h . f, h . g)

 (Thanks to Lennart for pointing out the typo.)
 
 From: rj248...@hotmail.com
 To: haskell-cafe@haskell.org
 Subject: Clean proof?
 Date: Sun, 23 May 2010 15:41:20 +

 Given the following definition of either, from the prelude:
     either                      :: (a - c, b - c) - Either a b - c
     either (f, g) (Left x)      =  f x
     either (f, g) (Right x)     =  g x
 what's a clean proof that:
     h . either (f, g) = either (h . f, g . h)?
 The only proof I can think of requires the introduction of an anonymous
 function of z, with case analysis on z (Case 1:  z = Left x, Case 2:  z =
 Right y), but the use of anonymous functions and case analysis is ugly, and
 I'm not sure how to tie up the two cases neatly at the end.  For example
 here's the Left case:
       h . either (f, g)
   =    {definition of \}
       \z - (h . either (f, g)) z
   =    {definition of .}
       \z - (h (either (f, g) z)
   =    {definition of either in case z = Left x}
       \z - (h (f x))
   =    {definition of .}
       \z - (h . f) x
   =    {definition of .}
       h . f

 Thanks.
 
 The New Busy is not the too busy. Combine all your e-mail accounts with
 Hotmail. Get busy.
 
 The New Busy is not the old busy. Search, chat and e-mail from your inbox.
 Get started.
 ___
 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] Clean proof -- correction

2010-05-23 Thread Daniel Fischer
On Sunday 23 May 2010 18:24:50, R J wrote:
 Correction:  the theorem is
     h . either (f, g) = either (h . f, h . g)

Still not entirely true,

const True . either (undefined, undefined) $ undefined = True

while

either (const True . undefined, const True . undefined) undefined = 
undefined

But if we ignore bottom,

h . either (f, g) $ Left x
  = h (either (f,g) (Left x))
  = h (f x)

either (h . f, h . g) $ Left x
  = (h . f) x
  = h (f x)


h . either (f,g) $ Right y
  = h (either (f,g) (Right y))
  = h (g y)

either (h .f, h . g) $ Right y
  = (h . g) y
  = h (g y)
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Clean proof -- correction

2010-05-23 Thread Lennart Augustsson
Actually, I didn't notice the typo.  It's still not a true statement.

(h . either (f, g)) undefined /= (either (h . f, h . g)) undefined

Also, it's not exactly the function either from the Prelude.

  -- Lennart

2010/5/23 R J rj248...@hotmail.com:
 Correction:  the theorem is
     h . either (f, g) = either (h . f, h . g)

 (Thanks to Lennart for pointing out the typo.)
 
 From: rj248...@hotmail.com
 To: haskell-cafe@haskell.org
 Subject: Clean proof?
 Date: Sun, 23 May 2010 15:41:20 +

 Given the following definition of either, from the prelude:
     either                      :: (a - c, b - c) - Either a b - c
     either (f, g) (Left x)      =  f x
     either (f, g) (Right x)     =  g x
 what's a clean proof that:
     h . either (f, g) = either (h . f, g . h)?
 The only proof I can think of requires the introduction of an anonymous
 function of z, with case analysis on z (Case 1:  z = Left x, Case 2:  z =
 Right y), but the use of anonymous functions and case analysis is ugly, and
 I'm not sure how to tie up the two cases neatly at the end.  For example
 here's the Left case:
       h . either (f, g)
   =    {definition of \}
       \z - (h . either (f, g)) z
   =    {definition of .}
       \z - (h (either (f, g) z)
   =    {definition of either in case z = Left x}
       \z - (h (f x))
   =    {definition of .}
       \z - (h . f) x
   =    {definition of .}
       h . f

 Thanks.
 
 The New Busy is not the too busy. Combine all your e-mail accounts with
 Hotmail. Get busy.
 
 The New Busy is not the old busy. Search, chat and e-mail from your inbox.
 Get started.
 ___
 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] Clean proof -- correction

2010-05-23 Thread Derek Elkins
On Sun, May 23, 2010 at 11:38 AM, Daniel Fischer
daniel.is.fisc...@web.de wrote:
 On Sunday 23 May 2010 18:24:50, R J wrote:
 Correction:  the theorem is
     h . either (f, g) = either (h . f, h . g)

 Still not entirely true,

 const True . either (undefined, undefined) $ undefined = True

 while

 either (const True . undefined, const True . undefined) undefined =
 undefined

 But if we ignore bottom,

If we ignore bottom we say By parametricity.  The theorem is a free theorem.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] An online forum for Haskell questions

2010-05-23 Thread Don Stewart
Hey all,

I thought I might just draw attention to a relatively new forum for
Haskell information on the interwebs, that hasn't been mentioned here
before.

The Stack Overflow Haskell questions forum:

http://stackoverflow.com/questions/tagged/haskell

We've had more than 1000 questions asked and answered about Haskell
there now, and for many readers of haskell-cafe@ it might be a more
efficient way to get quick questions answered. Norman Ramsey is waiting
patiently to help you! :-)

For in-depth, or open questions, haskell-cafe exploration is more
appropriate, in my opinion -- and we continue to have special
communities for particular projects (e.g. libraries@ ,
glasgow-haskell-users@, happstack@ xmonad@) . But if you have a problem
you know others might have solved already, consider the haskell tag on SO.

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


Re: [Haskell-cafe] [reactive] A pong and integrate

2010-05-23 Thread Ben Christy
I keep asking myself the question is Haskell and/or FRP even suitable for
game programming.
And if so are there any design patterns.

2010/5/19 Patai Gergely patai_gerg...@fastmail.fm

  I that the saw sleep time at each loop is fixed (0.02). So game speed
  will
  depend on processor speed, since with a more powerful CPU frames will be
  computed quicklier?
 Yes, that's how it works.

  So we don't have (with the Simple branch) some way to say I want my
  sprite
  to move 100 pixels *per second* on the left, except if we provide
  ourselves a time signal?
 That's exactly the case, although I'd probably provide a delta time
 signal. The Simple version is a discrete stream library, and it doesn't
 pretend to have continuous-time abstractions.

 Gergely

 --
 http://www.fastmail.fm - Access your email from home and the web

 ___
 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] [reactive] A pong and integrate

2010-05-23 Thread Peter Verswyvelen
IMO: For AAA game programming? Definitely not. For exploring new ways
of doing game programming and having a lot of fun and frustration?
Sure! For making casual games? I don't know.

On Sun, May 23, 2010 at 9:09 PM, Ben Christy ben.chri...@gmail.com wrote:
 I keep asking myself the question is Haskell and/or FRP even suitable for
 game programming.
 And if so are there any design patterns.
 2010/5/19 Patai Gergely patai_gerg...@fastmail.fm

  I that the saw sleep time at each loop is fixed (0.02). So game speed
  will
  depend on processor speed, since with a more powerful CPU frames will be
  computed quicklier?
 Yes, that's how it works.

  So we don't have (with the Simple branch) some way to say I want my
  sprite
  to move 100 pixels *per second* on the left, except if we provide
  ourselves a time signal?
 That's exactly the case, although I'd probably provide a delta time
 signal. The Simple version is a discrete stream library, and it doesn't
 pretend to have continuous-time abstractions.

 Gergely

 --
 http://www.fastmail.fm - Access your email from home and the web

 ___
 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 mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] [reactive] A pong and integrate

2010-05-23 Thread Brandon S. Allbery KF8NH

On May 23, 2010, at 15:09 , Ben Christy wrote:
I keep asking myself the question is Haskell and/or FRP even  
suitable for game programming.


Well, that's the question.  FRP is a research project, not a  
production framework/paradigm; anyone working on it currently is there  
to help answer that question.  If you're looking for a mature  
framework, this is not (yet) the place for you.


--
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allb...@kf8nh.com
system administrator [openafs,heimdal,too many hats] allb...@ece.cmu.edu
electrical and computer engineering, carnegie mellon universityKF8NH




PGP.sig
Description: This is a digitally signed message part
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] [reactive] A pong and integrate

2010-05-23 Thread Jake McArthur

On 05/23/2010 02:17 PM, Peter Verswyvelen wrote:

IMO: For AAA game programming? Definitely not.


Why not? I suppose it may depend on your definition of AAA, since 
there doesn't seem to be any consensus on it. I have seen it mean 
various combinations of the following, but rarely, if ever, all of them:


  * Big development budget
  * Big marketing budget
  * High quality
  * Large number of sales and/or high revenue
  * High hardware requirements
  * Released by one of a small group of accepted AAA publishers

While I think it's very unlikely that the last one will happen any time 
soon, I don't see any reason that Haskell and/or FRP (or as I now prefer 
to call my research in the area, Denotative Continuous-Time Programming, 
or DCTP) inherently can't be a major part of the development of a game 
that fits any of the definitions in the list.


I suppose DCTP is not itself *ready* for somebody to risk a business 
investment on it, although it may be in the future, but Haskell as a 
whole would not be all that risky, in my opinion.


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


Re: [Haskell-cafe] [reactive] A pong and integrate

2010-05-23 Thread Ben Christy
Assuming Haskell is ready has any work gone into creating design patterns or
the like. One of the biggest problems is ALL of the literature regarding
game programming is written in an imperative style. My goal for learning
Haskell is to make a hobby game written in a Functional language but I am at
a loss how to go about it. I an imperative language I would set up a central
entity management system and then have subsystems register with it and
either transform the entities such as AI or user interface or do something
with them IE graphics. This paradigm just will not work as far as I can
imagine in Haskell.

On Sun, May 23, 2010 at 6:30 PM, Jake McArthur jake.mcart...@gmail.comwrote:

 On 05/23/2010 02:17 PM, Peter Verswyvelen wrote:

 IMO: For AAA game programming? Definitely not.


 Why not? I suppose it may depend on your definition of AAA, since there
 doesn't seem to be any consensus on it. I have seen it mean various
 combinations of the following, but rarely, if ever, all of them:

  * Big development budget
  * Big marketing budget
  * High quality
  * Large number of sales and/or high revenue
  * High hardware requirements
  * Released by one of a small group of accepted AAA publishers

 While I think it's very unlikely that the last one will happen any time
 soon, I don't see any reason that Haskell and/or FRP (or as I now prefer to
 call my research in the area, Denotative Continuous-Time Programming, or
 DCTP) inherently can't be a major part of the development of a game that
 fits any of the definitions in the list.

 I suppose DCTP is not itself *ready* for somebody to risk a business
 investment on it, although it may be in the future, but Haskell as a whole
 would not be all that risky, in my opinion.

 - Jake

 ___
 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] [reactive] A pong and integrate

2010-05-23 Thread Peter Verswyvelen
On Mon, May 24, 2010 at 12:30 AM, Jake McArthur jake.mcart...@gmail.com wrote:
 On 05/23/2010 02:17 PM, Peter Verswyvelen wrote:

 IMO: For AAA game programming? Definitely not.

 Why not? I suppose it may depend on your definition of AAA, since there
 doesn't seem to be any consensus on it. I have seen it mean various
 combinations of the following, but rarely, if ever, all of them:

  * Big development budget
  * Big marketing budget
  * High quality
  * Large number of sales and/or high revenue
  * High hardware requirements
  * Released by one of a small group of accepted AAA publishers

 While I think it's very unlikely that the last one will happen any time
 soon, I don't see any reason that Haskell and/or FRP (or as I now prefer to
 call my research in the area, Denotative Continuous-Time Programming, or
 DCTP) inherently can't be a major part of the development of a game that
 fits any of the definitions in the list.

I'm not saying it will never happen, I'm just saying that IMO Haskell
is not ready for doing AAA development (and with that I meant your
first 5 bullets) right now.

 I suppose DCTP is not itself *ready* for somebody to risk a business
 investment on it, although it may be in the future, but Haskell as a whole
 would not be all that risky, in my opinion.

Well, in my opinion - based on hands on experience - Haskell was very
risky for serious game development a couple of years ago. Not sure if
this is still the case today...
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] [reactive] A pong and integrate

2010-05-23 Thread Ben Christy
I guess Im thinking of a overarching pattern for creating games in a
functional language similar to
http://www.acims.arizona.edu/PUBLICATIONS/PDF/JeffPlummerMSthesis_wo_Appendix.pdf
.

On Sun, May 23, 2010 at 6:51 PM, Ben Christy ben.chri...@gmail.com wrote:

 Assuming Haskell is ready has any work gone into creating design patterns
 or the like. One of the biggest problems is ALL of the literature regarding
 game programming is written in an imperative style. My goal for learning
 Haskell is to make a hobby game written in a Functional language but I am at
 a loss how to go about it. I an imperative language I would set up a central
 entity management system and then have subsystems register with it and
 either transform the entities such as AI or user interface or do something
 with them IE graphics. This paradigm just will not work as far as I can
 imagine in Haskell.

 On Sun, May 23, 2010 at 6:30 PM, Jake McArthur jake.mcart...@gmail.comwrote:

 On 05/23/2010 02:17 PM, Peter Verswyvelen wrote:

 IMO: For AAA game programming? Definitely not.


 Why not? I suppose it may depend on your definition of AAA, since there
 doesn't seem to be any consensus on it. I have seen it mean various
 combinations of the following, but rarely, if ever, all of them:

  * Big development budget
  * Big marketing budget
  * High quality
  * Large number of sales and/or high revenue
  * High hardware requirements
  * Released by one of a small group of accepted AAA publishers

 While I think it's very unlikely that the last one will happen any time
 soon, I don't see any reason that Haskell and/or FRP (or as I now prefer to
 call my research in the area, Denotative Continuous-Time Programming, or
 DCTP) inherently can't be a major part of the development of a game that
 fits any of the definitions in the list.

 I suppose DCTP is not itself *ready* for somebody to risk a business
 investment on it, although it may be in the future, but Haskell as a whole
 would not be all that risky, in my opinion.

 - Jake

 ___
 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] [reactive] A pong and integrate

2010-05-23 Thread Peter Verswyvelen
What papers did you read?

When I read most of the Yampa papers, most of the design patterns
became obvious for AFRP (arrow-based FRP) style of programming. That
doesn't mean I could apply the design patterns immediately; I
understood them but writing a game in it was difficult since I also
was too used to the imperative approach. Note that in AFRP the design
patterns are actually functions and combinators itself (dpSwitch and
the like), and no fuzzy descriptions like in imperative programming.

Regarding user interfaces, FRUIT (also AFRP based) is also nice IMO.

But above systems suffer from scalability and performance (and the
annoying fact that a random number generator is not embedded in the
framework) , although for simple games, I don't think this would be an
issue.

Newer work like Reactive is much more faithful to functional
programming (no arrow syntax needed), but since no pong game was never
made with it yet, I would classify this as ongoing research.

Elerea finds middle ground between the two, and unlike Yampa, it's
examples would still work I guess.


On Mon, May 24, 2010 at 12:51 AM, Ben Christy ben.chri...@gmail.com wrote:
 Assuming Haskell is ready has any work gone into creating design patterns or
 the like. One of the biggest problems is ALL of the literature regarding
 game programming is written in an imperative style. My goal for learning
 Haskell is to make a hobby game written in a Functional language but I am at
 a loss how to go about it. I an imperative language I would set up a central
 entity management system and then have subsystems register with it and
 either transform the entities such as AI or user interface or do something
 with them IE graphics. This paradigm just will not work as far as I can
 imagine in Haskell.
 On Sun, May 23, 2010 at 6:30 PM, Jake McArthur jake.mcart...@gmail.com
 wrote:

 On 05/23/2010 02:17 PM, Peter Verswyvelen wrote:

 IMO: For AAA game programming? Definitely not.

 Why not? I suppose it may depend on your definition of AAA, since there
 doesn't seem to be any consensus on it. I have seen it mean various
 combinations of the following, but rarely, if ever, all of them:

  * Big development budget
  * Big marketing budget
  * High quality
  * Large number of sales and/or high revenue
  * High hardware requirements
  * Released by one of a small group of accepted AAA publishers

 While I think it's very unlikely that the last one will happen any time
 soon, I don't see any reason that Haskell and/or FRP (or as I now prefer to
 call my research in the area, Denotative Continuous-Time Programming, or
 DCTP) inherently can't be a major part of the development of a game that
 fits any of the definitions in the list.

 I suppose DCTP is not itself *ready* for somebody to risk a business
 investment on it, although it may be in the future, but Haskell as a whole
 would not be all that risky, in my opinion.

 - Jake
 ___
 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 mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] ANN: atom-1.0.4

2010-05-23 Thread Tom Hawkins
Atom [1] is an Haskell DSL for hard realtime embedded programming.
This release adds 'exactPhase' to precisely control the phasing of
Atom rule executions.  This patch was contributed by Lee Pike.

BTW, I created a google group [2] for discussions related to the use
for functional programming in embedded systems.

-Tom

[1] http://hackage.haskell.org/package/atom
[2] http://groups.google.com/group/fp-embedded
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Proposal to solve Haskell's MPTC dilemma

2010-05-23 Thread Carlos Camarao
Sorry to correct myself:

On Sat, May 22, 2010 at 10:24 PM, Carlos Camarao
carlos.cama...@gmail.comwrote:

 ...
 =
 PS: I think that a definition of orphan/non-orphan instance definition
 for MPTCs should be different.
 Letting:  ...

   instance-def(I,C,M,tv) = I is an instance definition of class C,
 occurring in
   module M, that instantiates class variable tv


Should be: instance-def(I,C,M,tv,T) = I is an instance def of class C,
occurring in
  module M, that instanticates class
variable tv to datatype T
and replace occurrences of instance-def(I,C,M,tv) to
instance-def(I,C,M,tv,T).

And I think a correct definition of orphan/non-orphan for MPTCs should

be along the line:
 ...
 That is, an instance should be considered non-orphan if there exists
 at least one datatype to which a class type variable in such instance
 is instantiated, because other instances which instantiate such class
 type variable to such datatype would be non-orphan.


 (delete non-.)
 ... type variable to such datatype would be orphan.

Cheers,

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


Re: [Haskell-cafe] [reactive] A pong and integrate

2010-05-23 Thread Limestraël
 Elerea finds middle ground between the two, and unlike Yampa, it's
 examples would still work I guess.

Yes that's the big problem of Yampa: all of the examples are very old, and
some even don't work anymore.
It's the same for the papers/tutorials (they're all 6 years old or more),
and it would be less of a problem if the functions were documented! (Check
hackage, you'll see...)
I find Elerea fine so far, but it is still experimental and more limited
than Yampa.

2010/5/24 Peter Verswyvelen bugf...@gmail.com

 What papers did you read?

 When I read most of the Yampa papers, most of the design patterns
 became obvious for AFRP (arrow-based FRP) style of programming. That
 doesn't mean I could apply the design patterns immediately; I
 understood them but writing a game in it was difficult since I also
 was too used to the imperative approach. Note that in AFRP the design
 patterns are actually functions and combinators itself (dpSwitch and
 the like), and no fuzzy descriptions like in imperative programming.

 Regarding user interfaces, FRUIT (also AFRP based) is also nice IMO.

 But above systems suffer from scalability and performance (and the
 annoying fact that a random number generator is not embedded in the
 framework) , although for simple games, I don't think this would be an
 issue.

 Newer work like Reactive is much more faithful to functional
 programming (no arrow syntax needed), but since no pong game was never
 made with it yet, I would classify this as ongoing research.

 Elerea finds middle ground between the two, and unlike Yampa, it's
 examples would still work I guess.


 On Mon, May 24, 2010 at 12:51 AM, Ben Christy ben.chri...@gmail.com
 wrote:
  Assuming Haskell is ready has any work gone into creating design patterns
 or
  the like. One of the biggest problems is ALL of the literature regarding
  game programming is written in an imperative style. My goal for learning
  Haskell is to make a hobby game written in a Functional language but I am
 at
  a loss how to go about it. I an imperative language I would set up a
 central
  entity management system and then have subsystems register with it and
  either transform the entities such as AI or user interface or do
 something
  with them IE graphics. This paradigm just will not work as far as I can
  imagine in Haskell.
  On Sun, May 23, 2010 at 6:30 PM, Jake McArthur jake.mcart...@gmail.com
  wrote:
 
  On 05/23/2010 02:17 PM, Peter Verswyvelen wrote:
 
  IMO: For AAA game programming? Definitely not.
 
  Why not? I suppose it may depend on your definition of AAA, since
 there
  doesn't seem to be any consensus on it. I have seen it mean various
  combinations of the following, but rarely, if ever, all of them:
 
   * Big development budget
   * Big marketing budget
   * High quality
   * Large number of sales and/or high revenue
   * High hardware requirements
   * Released by one of a small group of accepted AAA publishers
 
  While I think it's very unlikely that the last one will happen any time
  soon, I don't see any reason that Haskell and/or FRP (or as I now prefer
 to
  call my research in the area, Denotative Continuous-Time Programming, or
  DCTP) inherently can't be a major part of the development of a game that
  fits any of the definitions in the list.
 
  I suppose DCTP is not itself *ready* for somebody to risk a business
  investment on it, although it may be in the future, but Haskell as a
 whole
  would not be all that risky, in my opinion.
 
  - Jake
  ___
  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 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: hledger 0.10 released

2010-05-23 Thread Simon Michael
hledger 0.10 is released, with installation and bug fixes and api  
improvements.


Best,
-Simon

home: http://hledger.org

Release notes:

2010/05/23 hledger 0.10


  * fix too-loose testpack dependency, missing safe dependency

  * fix ghc 6.12 compatibility with -fweb

  * fix handling of non-ascii arguments with ghc 6.12

  * fix 0.8 in --version output

  * fix an occasional stack overflow error due to infinite recursion
 in Posting/Transaction equality tests

  * the -fwebhappstack build flag is gone for now, to avoid a
 cabal problem

  * parsing: if there is no description, don't require a space after
 the transaction date

  * parsing: balance balanced-virtual postings separately, allow
 them to have an implicit amount

  * parsing: timelog entries now generate balanced transactions,
 using virtual postings

  * parsing: simpler high-level parse error message

  * parsing: clearer bad date errors

  * add: fix wrongful program exit on bad dates

  * print: negative account patterns now exclude transactions
 containing any posting to a matched account

  * vty: rename the ui command to vty for consistency

  * vty: fix restricted account scope when backing up to top level

  * web: fix non-ascii handling with ghc 6.12

  * web: fix a bug possibly affecting reload-on-change

  * consolidate module namespace under Hledger, api cleanups

  Stats:
  44 days, 81 commits since last release.
  Now at 4904 lines of code including tests, 144 tests, 53% coverage.

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


[Haskell-cafe] Best way to instance Fix?

2010-05-23 Thread Sam Martin

Hi!

I'm trying to work out the best way to generate (ideally derive) instances for 
the Fix type. Here's a cut down example:

data Greet x = AlloAllo x x | AuRevoir deriving Show
newtype Fix f = In { out :: f (Fix f) } -- deriving Show -- DOESN'T COMPILE

-- workaround
instance Show (Fix Greet) where show (In i) = In  ++ show i

In other words, given a number of parametised types that I can derive, say, 
Ord, Eq and Show for, how should I go about getting the instances for the Fix-d 
version of them as well? I've tried a few things, but no luck so far. 

Any clues?

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


[Haskell-cafe] Haskell, Queries and Monad Comprehension

2010-05-23 Thread Günther Schmidt

Hi all,

is there anybody currently using Haskell to construct or implement a 
query language?


I have read a couple of papers on Monad Comprehension Calculus and 
similar but none using Haskell nor any other existing programming 
language to build an actual implementation.


Most papers give some sort of Pseudo code, but I couldn't find any meat.



Günther

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


Re: [Haskell-cafe] Best way to instance Fix?

2010-05-23 Thread Ivan Miljenovic
On 24 May 2010 11:13, Sam Martin sam.mar...@geomerics.com wrote:

 Hi!

 I'm trying to work out the best way to generate (ideally derive) instances
 for the Fix type. Here's a cut down example:

 data Greet x = AlloAllo x x | AuRevoir deriving Show
 newtype Fix f = In { out :: f (Fix f) } -- deriving Show -- DOESN'T COMPILE

I think this is because for Fix to have a Show instance, it needs f to
have a Show instance, which only works if the parameter passed to it
has a Show instance, which means Fix needs to have a Show instance,
etc.  My guess is that the deriving tool doesn't like infinite
loops...

 -- workaround
 instance Show (Fix Greet) where show (In i) = In  ++ show i

Are you using OverlappingInstances or something to get this to work?

 In other words, given a number of parametised types that I can derive, say,
 Ord, Eq and Show for, how should I go about getting the instances for the
 Fix-d version of them as well? I've tried a few things, but no luck so far.

Does (==) = (==) `on` out works for the Eq instance?

-- 
Ivan Lazar Miljenovic
ivan.miljeno...@gmail.com
IvanMiljenovic.wordpress.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Best way to instance Fix?

2010-05-23 Thread Reid Barton
On Mon, May 24, 2010 at 02:13:32AM +0100, Sam Martin wrote:
 
 Hi!
 
 I'm trying to work out the best way to generate (ideally derive) instances 
 for the Fix type. Here's a cut down example:
 
 data Greet x = AlloAllo x x | AuRevoir deriving Show
 newtype Fix f = In { out :: f (Fix f) } -- deriving Show -- DOESN'T COMPILE
 
 -- workaround
 instance Show (Fix Greet) where show (In i) = In  ++ show i
 
 In other words, given a number of parametised types that I can derive, say, 
 Ord, Eq and Show for, how should I go about getting the instances for the 
 Fix-d version of them as well? I've tried a few things, but no luck so far. 
 
 Any clues?

You can use GHC's standalone deriving mechanism for this, described at
http://www.haskell.org/ghc/docs/6.12.2/html/users_guide/deriving.html


{-# LANGUAGE StandaloneDeriving, FlexibleContexts, UndecidableInstances #-}

data Greet x = AlloAllo x x | AuRevoir deriving Show
newtype Fix f = In { out :: f (Fix f) }

deriving instance Show (f (Fix f)) = Show (Fix f)


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


RE: [Haskell-cafe] TagSoup 0.9

2010-05-23 Thread Ralph Hodgson
Thanks Neil,

 

Using Network.HTTP worked.

 

However something else I have just run into concerns some web pages that
start with:

 

?xml version=1.0 encoding=iso-8859-1?

!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd;

 

I get the following bad result:

 

TagText HTTP/1.1 200 OK\r\nContent-Type: text/html\r\nLast-Modified: Tue,
27 Oct 2009 19:30:40 GMT\r\nETag: \6f248cf73b57ca1:25e2\\r\nDate: Sun, 23
May 2010 22:46:41 GMT\r\nTransfer-Encoding:  chunked\r\nConnection:
close\r\nConnection:
Transfer-Encoding\r\n\r\n4000\r\n\255\254\NUL?\NULx\NULm\NULl\NUL
\NULv\NULe\NULr\NULs\NULi\NULo\NULn\NUL=\NUL\\NUL1\NUL.\NUL0\NUL\\NUL
\NULe\NULn\NULc\NULo\NULd\NULi\NULn\NULg\NUL=\NUL\\NULi\NULs\NULo\NUL-\NUL8
\NUL8\NUL5\NUL9\NUL-\NUL1\NUL\\NUL

 

etc etc

 

Is this an easy thing to fix? I've started to look over the code.

 

-Original Message-
From: Neil Mitchell [mailto:ndmitch...@gmail.com] 
Sent: Wednesday, May 19, 2010 12:19 PM
To: Ralph Hodgson
Cc: Daniel Fischer; haskell-cafe@haskell.org; Don Stewart
Subject: Re: [Haskell-cafe] TagSoup 0.9

 

Hi Ralph,

 

 I was using TagSoup 0.8 with great success. On upgrading to 0.9 I have
this error:

 

 TQ\TagSoup\TagSoupExtensions.lhs:29:17:

`Tag' is not applied to enough type arguments

Expected kind `*', but `Tag' has kind `* - *'

In the type synonym declaration for `Bundle'

 Failed, modules loaded: TQ.Common.TextAndListHandling.

 

My change notes have this being a change between 0.6 and 0.8. As

Malcolm says, any old uses of Tag should become Tag String. The

reason is that Tag is now parameterised, and you can use Tag

ByteString etc. However, I should point out that Tag ByteString won't

be any faster than Tag String in this version (it's in the future work

pile).

 

  Forgot to add: I now need to understand the following warnings on this

  line  import Text.HTML.Download:

 

Everyone's comments have been right. I previously included

Text.HTML.Download so that it was easy to test tagsoup against the

web. Since I first wrote that snippet the HTTP downloading libraries

have improved substantially, so people should use those in favour of

the version in tagsoup - you'll be able to connect to more websites in

more reliable ways, go through proxies etc. I don't intend to remove

the Download module any time soon, but I will do eventually.

 

Thanks, Neil

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