[Haskell-cafe] instance Eq (a - b)

2010-04-14 Thread Ashley Yakeley
Why isn't there an instance Eq (a - b) ? allValues :: (Bounded a,Enum a) = [a] allValues = enumFrom minBound instance (Bounded a,Enum a,Eq b) = Eq (a - b) where p == q = fmap p allValues == fmap q allValues Of course, it's not perfect, since empty types are finite but not Bounded.

Re: [Haskell-cafe] instance Eq (a - b)

2010-04-14 Thread Ivan Miljenovic
On 14 April 2010 16:03, Ashley Yakeley ash...@semantic.org wrote: Why isn't there an instance Eq (a - b) ? How do you prove that f = (2*) and g x = x + x are equal? Mathematically, you can; but the only way you can prove it in Haskell is by comparing the values for the entire domain (which gets

Re: [Haskell-cafe] instance Eq (a - b)

2010-04-14 Thread Joe Fredette
Consider the set of all rationals with 1 as a numerator, and positive denominator, eg: S = {1/n, n : Nat} this is bounded, enumerable, but infinite. Which makes the whole checking every value bit somewhat, shall we say, difficult. :) So for instance, we want to show f : S

Re: [Haskell-cafe] instance Eq (a - b)

2010-04-14 Thread Ashley Yakeley
On Wed, 2010-04-14 at 16:11 +1000, Ivan Miljenovic wrote: but the only way you can prove it in Haskell is by comparing the values for the entire domain (which gets computationally expensive)... It's not expensive if the domain is, for instance, Bool. -- Ashley Yakeley

Re: [Haskell-cafe] instance Eq (a - b)

2010-04-14 Thread Jonas Almström Duregård
I guess nontermination is a problem (e.g. if one or both functions fail to terminate for some values, equality will be undecidable). /Jonas On 14 April 2010 08:42, Ashley Yakeley ash...@semantic.org wrote: On Wed, 2010-04-14 at 16:11 +1000, Ivan Miljenovic wrote: but the only way you can prove

[Haskell-cafe] Re: instance Eq (a - b)

2010-04-14 Thread Ashley Yakeley
Joe Fredette wrote: this is bounded, enumerable, but infinite. The question is whether there are types like this. If so, we would need a new class: class Finite a where allValues :: [a] instance (Finite a,Eq b) = Eq (a - b) where p == q = fmap p allValues == fmap q allValues

Re: [Haskell-cafe] Re: instance Eq (a - b)

2010-04-14 Thread Thomas Davie
Your instances of Finite are not quite right: bottom :: a bottom = doSomethingToLoopInfinitely. instance Finite () where allValues = [(), bottom] instance Finite Nothing where allValues = [bottom] Though at a guess an allValuesExculdingBottom function is also useful, perhaps the class

Re: [Haskell-cafe] What is the consensus about -fwarn-unused-do-bind ?

2010-04-14 Thread Roel van Dijk
Can anyone provide an example of an error that is prevented by this warning? When exactly is it dangerous to ignore a monadic function's return value? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

Re: [Haskell-cafe] Re: instance Eq (a - b)

2010-04-14 Thread Ashley Yakeley
On Wed, 2010-04-14 at 08:13 +0100, Thomas Davie wrote: Your instances of Finite are not quite right: bottom :: a bottom = doSomethingToLoopInfinitely. instance Finite () where allValues = [(), bottom] Bottom is not a value, it's failure to evaluate to a value. But if one did start

[Haskell-cafe] unboxed types in classes

2010-04-14 Thread Phyx
Hi all, I was wondering if it's possible to have a class declaration that would except both unlifted types and lifted types as instances. For instance, I'm looking for something like class Foo a b where bar :: a - b instance Foo Int Int where bar = id instance Foo Int#

Re: [Haskell-cafe] unboxed types in classes

2010-04-14 Thread Max Bolingbroke
Hi Phyx, instance Foo Int# Int where  bar = iBox What you want is not currently possible, for many of the same reasons that you cannot instantiate polymorphic types (e.g. that of id) at unboxed types. Because you can't then be polymorphic in the a in Foo a b if a might be an unboxed type,

Re: [Haskell-cafe] a way to convert partial functions to functions with Maybe's

2010-04-14 Thread Roel van Dijk
On Wed, Apr 14, 2010 at 2:32 AM, Ivan Miljenovic ivan.miljeno...@gmail.com wrote: Why not use Maybe for func1 in the first place?  Or are you wanting to automagically make all uses of head, tail, etc. safe? In which case there is already the 'safe' package:

Re: [Haskell-cafe] Re: instance Eq (a - b)

2010-04-14 Thread Jonas Almström Duregård
But if one did start considering bottom to be a value, one would have to distinguish different ones. For instance, (error ABC) vs. (error PQR). Obviously this is not finite. Nor is it computable, since it must distinguish terminating programs from nonterminating ones (i.e. the halting

Re: [Haskell-cafe] instance Eq (a - b)

2010-04-14 Thread Ketil Malde
Joe Fredette jfred...@gmail.com writes: Consider the set of all rationals with 1 as a numerator, and positive denominator, eg: S = {1/n, n : Nat} this is bounded, enumerable, but infinite. Isn't making this an instance of Enum something of an abuse? How would you use enumFromThenTo

Re: [Haskell-cafe] Re: instance Eq (a - b)

2010-04-14 Thread Thomas Davie
On 14 Apr 2010, at 08:29, Ashley Yakeley wrote: On Wed, 2010-04-14 at 08:13 +0100, Thomas Davie wrote: Your instances of Finite are not quite right: bottom :: a bottom = doSomethingToLoopInfinitely. instance Finite () where allValues = [(), bottom] Bottom is not a value, it's

Re: [Haskell-cafe] Re: instance Eq (a - b)

2010-04-14 Thread Thomas Davie
On 14 Apr 2010, at 09:01, Jonas Almström Duregård wrote: But if one did start considering bottom to be a value, one would have to distinguish different ones. For instance, (error ABC) vs. (error PQR). Obviously this is not finite. Nor is it computable, since it must distinguish terminating

[Haskell-cafe] Re: instance Eq (a - b)

2010-04-14 Thread Ashley Yakeley
Ketil Malde wrote: Another practical consideration is that checking a function taking a simple Int parameter for equality would mean 2^65 function evaluations. I think function equality would be too much of a black hole to be worth it. Oh FFS, _don't do that_. -- Ashley Yakeley

Re: [Haskell-cafe] Re: instance Eq (a - b)

2010-04-14 Thread Jonas Almström Duregård
f,g :: Bool - Int f x = 6 g x = 6 We can in Haskell compute that these two functions are equal, without solving the halting problem. Of course, this is the nature of generally undecidable problems. They are decidable in some cases, but not in general. /Jonas 2010/4/14 Thomas Davie

Re: [Haskell-cafe] Re: instance Eq (a - b)

2010-04-14 Thread Jonas Almström Duregård
f,g :: Bool - Int f x = 6 g x = 6 We can in Haskell compute that these two functions are equal, without solving the halting problem. what about these? f,g :: Bool - Int f x = 6 g x = x `seq` 6 /Jonas 2010/4/14 Thomas Davie tom.da...@gmail.com: On 14 Apr 2010, at 09:01, Jonas Almström

Re: [Haskell-cafe] Re: instance Eq (a - b)

2010-04-14 Thread Thomas Davie
On 14 Apr 2010, at 09:08, Jonas Almström Duregård wrote: f,g :: Bool - Int f x = 6 g x = 6 We can in Haskell compute that these two functions are equal, without solving the halting problem. Of course, this is the nature of generally undecidable problems. They are decidable in some

Re: [Haskell-cafe] Re: instance Eq (a - b)

2010-04-14 Thread Thomas Davie
On 14 Apr 2010, at 09:12, Jonas Almström Duregård wrote: f,g :: Bool - Int f x = 6 g x = 6 We can in Haskell compute that these two functions are equal, without solving the halting problem. what about these? f,g :: Bool - Int f x = 6 g x = x `seq` 6 As pointed out on #haskell by

[Haskell-cafe] Re: instance Eq (a - b)

2010-04-14 Thread Ashley Yakeley
Thomas Davie wrote: Certainly bottom is a value, and it's a value in *all* Haskell types. This is a matter of interpretation. If you consider bottom to be a value, then all the laws fail. For instance, (==) is supposed to be reflexive, but undefined == undefined is not True for almost any

[Haskell-cafe] Re: instance Eq (a - b)

2010-04-14 Thread Maciej Piechotka
On Tue, 2010-04-13 at 23:03 -0700, Ashley Yakeley wrote: Why isn't there an instance Eq (a - b) ? allValues :: (Bounded a,Enum a) = [a] allValues = enumFrom minBound instance (Bounded a,Enum a,Eq b) = Eq (a - b) where p == q = fmap p allValues == fmap q allValues Of

[Haskell-cafe] Re: instance Eq (a - b)

2010-04-14 Thread Thomas Davie
On 14 Apr 2010, at 09:17, Ashley Yakeley wrote: Thomas Davie wrote: Certainly bottom is a value, and it's a value in *all* Haskell types. This is a matter of interpretation. If you consider bottom to be a value, then all the laws fail. For instance, (==) is supposed to be reflexive, but

[Haskell-cafe] Re: instance Eq (a - b)

2010-04-14 Thread Ashley Yakeley
Maciej Piechotka wrote: I guess that the fact that: - It is costly. No, it's not. Evaluating equality for Bool - Int does not take significantly longer than for its isomorph (Int,Int). The latter has an Eq instance, so why doesn't the former? -- Ashley Yakeley

[Haskell-cafe] Re: instance Eq (a - b)

2010-04-14 Thread Maciej Piechotka
On Wed, 2010-04-14 at 01:21 -0700, Ashley Yakeley wrote: Maciej Piechotka wrote: I guess that the fact that: - It is costly. No, it's not. Evaluating equality for Bool - Int does not take significantly longer than for its isomorph (Int,Int). The latter has an Eq instance, so why

[Haskell-cafe] Re: instance Eq (a - b)

2010-04-14 Thread Ashley Yakeley
Thomas Davie wrote: Because we consider that the Functor laws must hold for all values in the type (including bottom). This is not so for IO, which is an instance of Functor. fmap id undefined is not bottom. -- Ashley Yakeley ___ Haskell-Cafe

[Haskell-cafe] Re: instance Eq (a - b)

2010-04-14 Thread Thomas Davie
On 14 Apr 2010, at 09:25, Ashley Yakeley wrote: Thomas Davie wrote: Because we consider that the Functor laws must hold for all values in the type (including bottom). This is not so for IO, which is an instance of Functor. fmap id undefined is not bottom. It isn't? fPrelude fmap id

[Haskell-cafe] Re: instance Eq (a - b)

2010-04-14 Thread Ashley Yakeley
On Wed, 2010-04-14 at 09:29 +0100, Thomas Davie wrote: It isn't? fPrelude fmap id (undefined :: IO ()) *** Exception: Prelude.undefined ghci is helpfully running the IO action for you. Try this: seq (fmap id (undefined :: IO ())) not bottom -- Ashley Yakeley

Re: [Haskell-cafe] Re: instance Eq (a - b)

2010-04-14 Thread Jonas Almström Duregård
what about these? f,g :: Bool - Int f x = 6 g x = x `seq` 6 As pointed out on #haskell by roconnor, we apparently don't care, this is a shame... We only care that x == y = f x == g y, and x == y can't tell if _|_ == _|_. So the facts that (1) f == g (2) f undefined = 6 (3) g undefined =

[Haskell-cafe] Re: instance Eq (a - b)

2010-04-14 Thread Thomas Davie
On 14 Apr 2010, at 09:31, Ashley Yakeley wrote: On Wed, 2010-04-14 at 09:29 +0100, Thomas Davie wrote: It isn't? fPrelude fmap id (undefined :: IO ()) *** Exception: Prelude.undefined ghci is helpfully running the IO action for you. Try this: seq (fmap id (undefined :: IO ())) not

Re: [Haskell-cafe] Re: instance Eq (a - b)

2010-04-14 Thread Thomas Davie
On 14 Apr 2010, at 09:35, Jonas Almström Duregård wrote: what about these? f,g :: Bool - Int f x = 6 g x = x `seq` 6 As pointed out on #haskell by roconnor, we apparently don't care, this is a shame... We only care that x == y = f x == g y, and x == y can't tell if _|_ == _|_. So

[Haskell-cafe] Re: instance Eq (a - b)

2010-04-14 Thread Ashley Yakeley
Thomas Davie wrote: I guess this further reinforces my point though – we have a mixture of places where we consider _|_ when considering laws, and places where we don't consider _|_. This surely needs better defined somewhere. It's easy: don't consider bottom as a value, and the laws work

[Haskell-cafe] Re: instance Eq (a - b)

2010-04-14 Thread Thomas Davie
On 14 Apr 2010, at 09:39, Ashley Yakeley wrote: Thomas Davie wrote: I guess this further reinforces my point though – we have a mixture of places where we consider _|_ when considering laws, and places where we don't consider _|_. This surely needs better defined somewhere. It's easy:

[Haskell-cafe] Re: instance Eq (a - b)

2010-04-14 Thread Ketil Malde
Ashley Yakeley ash...@semantic.org writes: Another practical consideration is that checking a function taking a simple Int parameter for equality would mean 2^65 function evaluations. I think function equality would be too much of a black hole to be worth it. Oh FFS, _don't do that_. I

Re: [Haskell-cafe] a way to convert partial functions to functions with Maybe's

2010-04-14 Thread Ozgur Akgun
Oh well, thanks for all the response. I have a module with lots of one line function definitons, and they just *look* ugly when I wrap the return type with Maybe. This is a straightforward, and trivial job (the conversion) and I really don't care about other problems (such as non-termination plus

Re: [Haskell-cafe] Strange error with type classes + associated types

2010-04-14 Thread Stephen Tetley
On 14 April 2010 03:48, Brent Yorgey byor...@seas.upenn.edu wrote: Can someone more well-versed in the intricacies of type checking with associated types explain this?  Or is this a bug in GHC? Hi Brent Maybe you can't compose linear maps of the same type, and thus can't build a valid monoid

[Haskell-cafe] Re: instance Eq (a - b)

2010-04-14 Thread Ashley Yakeley
Ketil Malde wrote: (If you'd made clear from the start that when you say Enum a, Bounded a you really mean Bool, you might have avoided these replies that you apparently find offensive.) I don't mean Bool. There are lots of small finite types, for instance, (), Word8, Maybe Bool, and so on.

Re: [Haskell-cafe] instance Eq (a - b)

2010-04-14 Thread Ivan Lazar Miljenovic
Ashley Yakeley ash...@semantic.org writes: On Wed, 2010-04-14 at 16:11 +1000, Ivan Miljenovic wrote: but the only way you can prove it in Haskell is by comparing the values for the entire domain (which gets computationally expensive)... It's not expensive if the domain is, for instance,

Re: [Haskell-cafe] What is the consensus about -fwarn-unused-do-bind ?

2010-04-14 Thread Ivan Lazar Miljenovic
Roel van Dijk vandijk.r...@gmail.com writes: Can anyone provide an example of an error that is prevented by this warning? When exactly is it dangerous to ignore a monadic function's return value? See Neil's original rationale in the bug report: http://hackage.haskell.org/trac/ghc/ticket/3263

[Haskell-cafe] Re: instance Eq (a - b)

2010-04-14 Thread Ashley Yakeley
Jonas Almström Duregård wrote: So the facts that (1) f == g (2) f undefined = 6 (3) g undefined = undefined is not a problem? This is not a problem. f and g represent the same moral function, they are just implemented differently. f is smart enough to know that its argument doesn't matter,

[Haskell-cafe] Re: instance Eq (a - b)

2010-04-14 Thread Ashley Yakeley
Ivan Lazar Miljenovic wrote: Ashley Yakeley ash...@semantic.org writes: On Wed, 2010-04-14 at 16:11 +1000, Ivan Miljenovic wrote: but the only way you can prove it in Haskell is by comparing the values for the entire domain (which gets computationally expensive)... It's not expensive if the

[Haskell-cafe] Data instance for a GADT

2010-04-14 Thread Ozgur Akgun
Cafe, How can I provide a Data instance for a GADT? I am trying to TH on it, and Uniplate requires Data. I tried StandaloneDeriving, but it seems not to work. Best, -- Ozgur Akgun ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

[Haskell-cafe] Re: Data instance for a GADT

2010-04-14 Thread Ozgur Akgun
answering to myself: I guess this is related: http://hackage.haskell.org/trac/ghc/ticket/3497 On 14 April 2010 10:13, Ozgur Akgun ozgurak...@gmail.com wrote: Cafe, How can I provide a Data instance for a GADT? I am trying to TH on it, and Uniplate requires Data. I tried StandaloneDeriving,

Re: [Haskell-cafe] Vector to Monadic Stream and back, how?

2010-04-14 Thread Roman Leshchinskiy
On 14/04/2010, at 09:05, Xiao-Yong Jin wrote: I want to use 'mapM' on Data.Vector.Vector, but it looks like the only 'mapM' defined is in Data.Vector.Fusion.Stream.Monadic. I'm able to use 'stream' and 'liftStream' to convert a 'Vector' to a monadic stream, on which I can use 'mapM'. But I

[Haskell-cafe] Re: Data instance for a GADT

2010-04-14 Thread Ozgur Akgun
Seeing this old thread[1], I hope something happened towards enabling this. Does anybody know the current status about using TH on GADTs? [1] http://www.haskell.org/pipermail/template-haskell/2006-August/000567.html On 14 April 2010 10:32, Ozgur Akgun ozgurak...@gmail.com wrote: answering to

[Haskell-cafe] Re: Simple game: a monad for each player

2010-04-14 Thread Heinrich Apfelmus
Bertram Felgenhauer wrote: Yves Parès wrote: I answered my own question by reading this monad-prompt example: http://paste.lisp.org/display/53766 But one issue remains: those examples show how to make play EITHER a human or an AI. I don't see how to make a human player and an AI play

Re: [Haskell-cafe] Re: True Random Numbers

2010-04-14 Thread James Andrew Cook
I have now had a chance to experiment with these a bit, and have come up with some changes that bring random-fu's speed in these tests into line with Control.Monad.Random's when compiled with ghc-6.12.1, although it is still a bit slower when using GHC 6.10.4. This is partially because one of

Re: [Haskell-cafe] Re: instance Eq (a - b)

2010-04-14 Thread Henning Thielemann
Ashley Yakeley schrieb: Joe Fredette wrote: this is bounded, enumerable, but infinite. The question is whether there are types like this. If so, we would need a new class: I assume that comparing functions is more oftenly a mistake then actually wanted. Say I have compared f x == f y and

Re: [Haskell-cafe] Re: instance Eq (a - b)

2010-04-14 Thread roconnor
On Wed, 14 Apr 2010, Ashley Yakeley wrote: Joe Fredette wrote: this is bounded, enumerable, but infinite. The question is whether there are types like this. If so, we would need a new class: class Finite a where allValues :: [a] instance (Finite a,Eq b) = Eq (a - b) where p == q

Re: [Haskell-cafe] ghc #defines

2010-04-14 Thread Ivan Lazar Miljenovic
gladst...@gladstein.com writes: I may need to put some #ifdef conditionalizations into some cross-platform code. I'm wondering where I can find the definitions of symbols like __NHC__. I tried googling but I'm swamped by uses, no definitions that I can see. Looks like they're here:

Re: [Haskell-cafe] Re: instance Eq (a - b)

2010-04-14 Thread Luke Palmer
On Wed, Apr 14, 2010 at 4:41 AM, rocon...@theorem.ca wrote: As ski noted on #haskell we probably want to extend this to work on Compact types and not just Finite types instance (Compact a, Eq b) = Eq (a - b) where ... For example (Int - Bool) is a perfectly fine Compact set that isn't

RE: [Haskell-cafe] problem getting cabal-install to work on CentOS 5.2

2010-04-14 Thread Chris Dornan
Thanks very much Corey -- your suspicion is very well founded, and of course it neatly explains the peculiar behaviour. It looks as if exec has obviously been modified on RHEL and friends to refuse to execute anything in /tmp. With a bit of luck I should be able to get cabal-install working

Re: [Haskell-cafe] Re: instance Eq (a - b)

2010-04-14 Thread Luke Palmer
On Wed, Apr 14, 2010 at 5:13 AM, Luke Palmer lrpal...@gmail.com wrote: On Wed, Apr 14, 2010 at 4:41 AM,  rocon...@theorem.ca wrote: As ski noted on #haskell we probably want to extend this to work on Compact types and not just Finite types instance (Compact a, Eq b) = Eq (a - b) where ...

Re: [Haskell-cafe] problem getting cabal-install to work on CentOS 5.2

2010-04-14 Thread Lars Viklund
On Wed, Apr 14, 2010 at 06:27:53AM -0500, Chris Dornan wrote: Thanks very much Corey -- your suspicion is very well founded, and of course it neatly explains the peculiar behaviour. It looks as if exec has obviously been modified on RHEL and friends to refuse to execute anything in /tmp. I

Re: [Haskell-cafe] What is the consensus about -fwarn-unused-do-bind ?

2010-04-14 Thread Antoine Latter
On Tue, Apr 13, 2010 at 9:59 PM, Max Cantor mxcan...@gmail.com wrote: I'm in the camp of adding -fno-warn-unused-do-bind to my cabal files.  I hate sacrificing the purity of -Wall but I have so many forkIOs in my code that I think it was the best option. Max I think a nice compromise

Re: [Haskell-cafe] Strange error with type classes + associated types

2010-04-14 Thread Brent Yorgey
On Wed, Apr 14, 2010 at 09:51:52AM +0100, Stephen Tetley wrote: On 14 April 2010 03:48, Brent Yorgey byor...@seas.upenn.edu wrote: Can someone more well-versed in the intricacies of type checking with associated types explain this?  Or is this a bug in GHC? If you take the definition of

Re: [Haskell-cafe] Simple game: a monad for each player

2010-04-14 Thread Limestraël
Yves, that is exactly how I designed my program so far. Human player needs a monad IO, AI needs just a monad, whatever it is, and I make both run in IO. And, as you said, the type of the ai (bot :: Monad m = Player m) contains no IO, so I know that, even if I make it run in IO, it won't make any

Re: [Haskell-cafe] Strange error with type classes + associated types

2010-04-14 Thread Roman Leshchinskiy
On 15/04/2010, at 00:30, Brent Yorgey wrote: On Wed, Apr 14, 2010 at 09:51:52AM +0100, Stephen Tetley wrote: On 14 April 2010 03:48, Brent Yorgey byor...@seas.upenn.edu wrote: Can someone more well-versed in the intricacies of type checking with associated types explain this? Or is this a

Re: [Haskell-cafe] Vector to Monadic Stream and back, how?

2010-04-14 Thread Xiao-Yong Jin
On Wed, 14 Apr 2010 19:37:22 +1000, Roman Leshchinskiy wrote: On 14/04/2010, at 09:05, Xiao-Yong Jin wrote: I want to use 'mapM' on Data.Vector.Vector, but it looks like the only 'mapM' defined is in Data.Vector.Fusion.Stream.Monadic. I'm able to use 'stream' and 'liftStream' to convert a

Re: [Haskell-cafe] Strange error with type classes + associated types

2010-04-14 Thread Brent Yorgey
On Thu, Apr 15, 2010 at 12:48:20AM +1000, Roman Leshchinskiy wrote: Right, this seems weird to me. Why is there still a 'u' mentioned in the constraints? Actually, I don't even see why there ought to be both v and v1. The type of (*.*) mentions three type variables, u, v, and w:

Re: [Haskell-cafe] ghc #defines

2010-04-14 Thread Thomas Schilling
__NHC__ is defined when the code is compiled with the nhc98 compiler [1]. Similarly Hugs is another Haskell implementation. [1]: http://www.haskell.org/nhc98/ On 14 April 2010 11:36, gladst...@gladstein.com wrote: I may need to put some #ifdef conditionalizations into some cross-platform

Re: [Haskell-cafe] Re: Simple game: a monad for each player

2010-04-14 Thread Limestraël
I have some difficulties to see the use of PromptT, because in the tutorial, this type is never mentioned, and its operations (Return and :=) are instead constructors of ProgramT... Would you have some concrete examples? Because there I'm a bit lost (since the tutorial doesn't match the

Re: [Haskell-cafe] problem getting cabal-install to work on CentOS 5.2

2010-04-14 Thread Brandon S. Allbery KF8NH
On Apr 14, 2010, at 07:27 , Chris Dornan wrote: Thanks very much Corey -- your suspicion is very well founded, and of course it neatly explains the peculiar behaviour. It looks as if exec has obviously been modified on RHEL and friends to refuse to execute anything in /tmp. Unlikely that

[Haskell-cafe] Re: Simple game: a monad for each player

2010-04-14 Thread Heinrich Apfelmus
Limestraël wrote: I have some difficulties to see the use of PromptT, because in the tutorial, this type is never mentioned, and its operations (Return and :=) are instead constructors of ProgramT... Would you have some concrete examples? Because there I'm a bit lost (since the tutorial

Fwd: [Haskell-cafe] Re: Simple game: a monad for each player

2010-04-14 Thread Limestraël
Okay, I just understood that 'Prompt' was just a sort of view for 'Program'. I'd like to make it very accessible, so please don't hesitate to report any difficulties with finding and understanding documentation and examples! Then I think the name 'Prompt' may be misleading for those who doesn't

Re: Fwd: [Haskell-cafe] Re: Simple game: a monad for each player

2010-04-14 Thread Bertram Felgenhauer
Limestraël wrote: Okay, I just understood that 'Prompt' was just a sort of view for 'Program'. Right. runMyStackT :: MyStackT (Player m) a - Player m a According to what Bertram said, each strategy can pile its own custom monad stack ON the (Player m) monad. Yes, and I meant what

Re: Fwd: [Haskell-cafe] Re: Simple game: a monad for each player

2010-04-14 Thread Limestraël
Okay, I start to understand better... Just, Heinrich, how would implement the mapMonad function in terms of the operational package? You just shown the signature. 2010/4/14 Bertram Felgenhauer bertram.felgenha...@googlemail.com Limestraėl wrote: Okay, I just understood that 'Prompt' was just

[Haskell-cafe] Re: instance Eq (a - b)

2010-04-14 Thread Ashley Yakeley
On 2010-04-14 03:41, rocon...@theorem.ca wrote: For example (Int - Bool) is a perfectly fine Compact set that isn't finite Did you mean Integer - Bool? Int - Bool is finite, but large. -- Ashley Yakeley ___ Haskell-Cafe mailing list

Re: [Haskell-cafe] What is the consensus about -fwarn-unused-do-bind ?

2010-04-14 Thread Nicolas Pouillard
On Wed, 14 Apr 2010 09:15:04 -0500, Antoine Latter aslat...@gmail.com wrote: On Tue, Apr 13, 2010 at 9:59 PM, Max Cantor mxcan...@gmail.com wrote: I'm in the camp of adding -fno-warn-unused-do-bind to my cabal files.  I hate sacrificing the purity of -Wall but I have so many forkIOs in my

Re: [Haskell-cafe] Re: instance Eq (a - b)

2010-04-14 Thread John Meacham
On Wed, Apr 14, 2010 at 02:07:52AM -0700, Ashley Yakeley wrote: So the facts that (1) f == g (2) f undefined = 6 (3) g undefined = undefined is not a problem? This is not a problem. f and g represent the same moral function, they are just implemented differently. f is smart enough to

[Haskell-cafe] Re: instance Eq (a - b)

2010-04-14 Thread Stefan Monnier
Why isn't there an instance Eq (a - b) ? I guess it's because even for those cases where it can be written, it will rarely be what you want to do, so it's better to require the programmer to explicitly request a function-comparison than to risk silently using such a costly operation when the

[Haskell-cafe] Re: instance Eq (a - b)

2010-04-14 Thread Ertugrul Soeylemez
Stefan Monnier monn...@iro.umontreal.ca wrote: While we're here, I'd be more interested in a dirtyfast comparison operation which could look like: eq :: a - a - IO Bool where the semantics is if (eq x y) returns True, then x and y are the same object, else they may be different.

Re: [Haskell-cafe] What is the consensus about -fwarn-unused-do-bind ?

2010-04-14 Thread John Meacham
On Fri, Apr 09, 2010 at 09:07:29AM -0700, Bryan O'Sullivan wrote: On Fri, Apr 9, 2010 at 6:44 AM, Ivan Lazar Miljenovic ivan.miljeno...@gmail.com wrote: As of 6.12.1, the new -fwarn-unused-do-bind warning is activated with -Wall. This is based off a bug report by Neil Mitchell:

Re: [Haskell-cafe] Re: instance Eq (a - b)

2010-04-14 Thread Casey McCann
On Wed, Apr 14, 2010 at 2:22 PM, Stefan Monnier monn...@iro.umontreal.ca wrote: While we're here, I'd be more interested in a dirtyfast comparison operation which could look like:    eq :: a - a - IO Bool where the semantics is if (eq x y) returns True, then x and y are the same object,

[Haskell-cafe] Re: instance Eq (a - b)

2010-04-14 Thread roconnor
On Wed, 14 Apr 2010, Ashley Yakeley wrote: On 2010-04-14 03:41, rocon...@theorem.ca wrote: For example (Int - Bool) is a perfectly fine Compact set that isn't finite Did you mean Integer - Bool? Int - Bool is finite, but large. Yes, I meant Integer - Bool. -- Russell O'Connor

[Haskell-cafe] Nomic game in Haskell

2010-04-14 Thread Dupont Corentin
Hello Café, do you know Nomic? It's a fabulous and strange game where you have the right to change the rules in the middle of the game! In fact, changing the rules is the goal of the game. Changing a rule is considered as a move. Of course even that could be changed! www.nomic.net I'm wondering

[Haskell-cafe] Re: instance Eq (a - b)

2010-04-14 Thread Ashley Yakeley
On 2010-04-14 11:12, John Meacham wrote: On Wed, Apr 14, 2010 at 02:07:52AM -0700, Ashley Yakeley wrote: So the facts that (1) f == g (2) f undefined = 6 (3) g undefined = undefined is not a problem? This is not a problem. f and g represent the same moral function, they are just implemented

Re: [Haskell-cafe] Re: instance Eq (a - b)

2010-04-14 Thread Alexander Solla
On Apr 14, 2010, at 12:16 PM, Ashley Yakeley wrote: They are distinct Haskell functions, but they represent the same moral function. If you're willing to accept that distinct functions can represent the same moral function, you should be willing to accept that different bottoms

[Haskell-cafe] GHC, odd concurrency space leak

2010-04-14 Thread Jesper Louis Andersen
A problem with GHC? === This post describes some odd behaviour I have seen in GHC 6.12.1 when writing Combinatorrent. The post is literate Haskell so you can run it. The executive summary: A space leak occurs when a new process is spawned from inside another process - and I can't

[Haskell-cafe] Re: instance Eq (a - b)

2010-04-14 Thread Ashley Yakeley
On 2010-04-14 13:03, Alexander Solla wrote: If you're willing to accept that distinct functions can represent the same moral function, you should be willing to accept that different bottoms represent the same moral value. Bottoms should not be considered values. They are failures to calculate

[Haskell-cafe] Re: instance Eq (a - b)

2010-04-14 Thread Alexander Solla
On Apr 14, 2010, at 1:24 PM, Ashley Yakeley wrote: Bottoms should not be considered values. They are failures to calculate values, because your calculation would never terminate (or similar condition). And yet you are trying to recover the semantics of comparing bottoms.

[Haskell-cafe] Re: instance Eq (a - b)

2010-04-14 Thread Ashley Yakeley
On 2010-04-14 13:31, Alexander Solla wrote: And yet you are trying to recover the semantics of comparing bottoms. No, I don't think so. -- Ashley Yakeley ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

Re: [Haskell-cafe] Re: instance Eq (a - b)

2010-04-14 Thread roconnor
On Wed, 14 Apr 2010, Ashley Yakeley wrote: On 2010-04-14 13:03, Alexander Solla wrote: If you're willing to accept that distinct functions can represent the same moral function, you should be willing to accept that different bottoms represent the same moral value. Bottoms should not be

Re: [Haskell-cafe] GHC, odd concurrency space leak

2010-04-14 Thread Gregory Collins
Jesper Louis Andersen jesper.louis.ander...@gmail.com writes: This post describes some odd behaviour I have seen in GHC 6.12.1 when writing Combinatorrent. The post is literate Haskell so you can run it. The executive summary: A space leak occurs when a new process is spawned from inside

Re: [Haskell-cafe] GHC, odd concurrency space leak

2010-04-14 Thread Jason Dagit
On Wed, Apr 14, 2010 at 2:13 PM, Gregory Collins g...@gregorycollins.netwrote: Jesper Louis Andersen jesper.louis.ander...@gmail.com writes: This post describes some odd behaviour I have seen in GHC 6.12.1 when writing Combinatorrent. The post is literate Haskell so you can run it. The

Re: [Haskell-cafe] GHC, odd concurrency space leak

2010-04-14 Thread Jason Dagit
On Wed, Apr 14, 2010 at 2:44 PM, Jason Dagit da...@codersbase.com wrote: On Wed, Apr 14, 2010 at 2:13 PM, Gregory Collins g...@gregorycollins.netwrote: Jesper Louis Andersen jesper.louis.ander...@gmail.com writes: This post describes some odd behaviour I have seen in GHC 6.12.1 when

[Haskell-cafe] Re: instance Eq (a - b)

2010-04-14 Thread Ashley Yakeley
On 2010-04-14 13:59, rocon...@theorem.ca wrote: There is some notion of value, let's call it proper value, such that bottom is not one. In other words bottom is not a proper value. Define a proper value to be a value x such that x == x. So neither undefined nor (0.0/0.0) are proper values

Re: [Haskell-cafe] GHC, odd concurrency space leak

2010-04-14 Thread Daniel Fischer
Am Mittwoch 14 April 2010 23:13:13 schrieb Gregory Collins: Jesper Louis Andersen jesper.louis.ander...@gmail.com writes: This post describes some odd behaviour I have seen in GHC 6.12.1 when writing Combinatorrent. The post is literate Haskell so you can run it. The executive summary: A

Re: [Haskell-cafe] GHC, odd concurrency space leak

2010-04-14 Thread Daniel Fischer
Am Mittwoch 14 April 2010 23:49:43 schrieb Jason Dagit: It will be interesting to hear what fixes this! forever' m = do _ - m                 forever' m When I define that version of forever, the space leak goes away. Not with optimisations.

RE: [Haskell-cafe] problem getting cabal-install to work on CentOS 5.2

2010-04-14 Thread Chris Dornan
Right: in this case /tmp is being mounted noexec. Thanks again. Chris -Original Message- From: Brandon S. Allbery KF8NH [mailto:allb...@ece.cmu.edu] Sent: 14 April 2010 10:41 AM To: Chris Dornan Cc: Brandon S. Allbery KF8NH; 'Corey O'Connor'; Haskell-Cafe@haskell.org Subject: Re:

Re: [Haskell-cafe] GHC, odd concurrency space leak

2010-04-14 Thread Jason Dagit
On Wed, Apr 14, 2010 at 3:13 PM, Daniel Fischer daniel.is.fisc...@web.dewrote: Am Mittwoch 14 April 2010 23:49:43 schrieb Jason Dagit: It will be interesting to hear what fixes this! forever' m = do _ - m forever' m When I define that version of forever, the

Re: [Haskell-cafe] Nomic game in Haskell

2010-04-14 Thread Brent Yorgey
On Wed, Apr 14, 2010 at 09:14:18PM +0200, Dupont Corentin wrote: Hello Café, do you know Nomic? It's a fabulous and strange game where you have the right to change the rules in the middle of the game! In fact, changing the rules is the goal of the game. Changing a rule is considered as a

Re: [Haskell-cafe] GHC, odd concurrency space leak

2010-04-14 Thread Daniel Fischer
Am Donnerstag 15 April 2010 00:52:22 schrieb Jason Dagit: The bad version, ghc --make NonTermination.hs: \begin{code} {-# OPTIONS -O2 #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} -- Note: Change the optimization to -O1 to get a terminating version Doesn't seem to terminate with -O1 here

Re: [Haskell-cafe] Simple game: a monad for each player

2010-04-14 Thread Reid Barton
On Wed, Apr 14, 2010 at 04:43:20PM +0200, Limestraël wrote: Yves, that is exactly how I designed my program so far. Human player needs a monad IO, AI needs just a monad, whatever it is, and I make both run in IO. And, as you said, the type of the ai (bot :: Monad m = Player m) contains no

[Haskell-cafe] Re: instance Eq (a - b)

2010-04-14 Thread Ashley Yakeley
On 2010-04-14 14:58, Ashley Yakeley wrote: On 2010-04-14 13:59, rocon...@theorem.ca wrote: There is some notion of value, let's call it proper value, such that bottom is not one. In other words bottom is not a proper value. Define a proper value to be a value x such that x == x. So neither

Re: [Haskell-cafe] Nomic game in Haskell

2010-04-14 Thread Brandon S. Allbery KF8NH
On Apr 14, 2010, at 19:24 , Brent Yorgey wrote: On Wed, Apr 14, 2010 at 09:14:18PM +0200, Dupont Corentin wrote: I'm wondering if it could be possible to implement a Nomic (or an helper for the game) in Haskell. Haskell seems appropriate for that, since functions are first order objects,

Re: [Haskell-cafe] Re: instance Eq (a - b)

2010-04-14 Thread Alexander Solla
On Apr 14, 2010, at 5:10 PM, Ashley Yakeley wrote: Worse, this rules out values of types that are not Eq. In principle, every type is an instance of Eq, because every type satisfies the identity function. Unfortunately, you can't DERIVE instances in general. As you are finding out...

Re: [Haskell-cafe] Can't login to GHC trac

2010-04-14 Thread Jason Dagit
On Tue, Apr 13, 2010 at 3:47 AM, Erik de Castro Lopo mle...@mega-nerd.commle%2...@mega-nerd.com wrote: Daniel Fischer wrote: Am Dienstag 13 April 2010 09:29:18 schrieb Erik de Castro Lopo: Anyone else have the same problem? I have that problem with my hackage (Cabal/cabal-install)

[Haskell-cafe] Re: instance Eq (a - b)

2010-04-14 Thread Maciej Piechotka
On Wed, 2010-04-14 at 12:16 -0700, Ashley Yakeley wrote: On 2010-04-14 11:12, John Meacham wrote: On Wed, Apr 14, 2010 at 02:07:52AM -0700, Ashley Yakeley wrote: So the facts that (1) f == g (2) f undefined = 6 (3) g undefined = undefined is not a problem? This is not a problem. f

  1   2   >