[Haskell-cafe] How to fix this problem in FreeBSD ?

2010-05-29 Thread zaxis

/usr/ports/devel/hs-ghc-pathssudo make install clean
===   hs-ghc-paths-0.1.0.5_1 depends on executable: ghc - found
===  Configuring for hs-ghc-paths-0.1.0.5_1
[1 of 1] Compiling Main ( Setup.hs, Setup.o )

Setup.hs:18:22: Not in scope: `preMakefile'
*** Error code 1

Stop in /usr/ports/devel/hs-ghc-paths.

Sincerely!

-
e^(π⋅i) + 1 = 0
-- 
View this message in context: 
http://old.nabble.com/How-to-fix-this-problem-in-FreeBSD---tp28714271p28714271.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

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


Re: [Haskell-cafe] How to fix this problem in FreeBSD ?

2010-05-29 Thread Ivan Lazar Miljenovic
Which version of GHC, which version of Cabal, and what is the Makefile?

zaxis z_a...@163.com writes:

 /usr/ports/devel/hs-ghc-pathssudo make install clean
 ===   hs-ghc-paths-0.1.0.5_1 depends on executable: ghc - found
 ===  Configuring for hs-ghc-paths-0.1.0.5_1
 [1 of 1] Compiling Main ( Setup.hs, Setup.o )

 Setup.hs:18:22: Not in scope: `preMakefile'
 *** Error code 1

 Stop in /usr/ports/devel/hs-ghc-paths.

 Sincerely!

 -
 e^(π⋅i) + 1 = 0

-- 
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] How to fix this problem in FreeBSD ?

2010-05-29 Thread zaxis

ghc --version
The Glorious Glasgow Haskell Compilation System, version 6.10.4

cabal --version
cabal-install version 0.8.2
using version 1.8.0.2 of the Cabal library

cat Makefile 
# New ports collection makefile for: hs-ghc-paths
# Date created:July 09 2009
# Whom:Giuseppe Pilichi aka Jacula Modyun jac...@gmail.com
#
# $FreeBSD: ports/devel/hs-ghc-paths/Makefile,v 1.3 2010/05/26 11:18:37
jacula Exp $

PORTNAME=   ghc-paths
PORTVERSION=0.1.0.5
PORTREVISION=   1
CATEGORIES= devel haskell

MAINTAINER= hask...@freebsd.org
COMMENT=Utility looking for GHC installation directories

CABAL_SETUP=Setup.hs

.if defined(SLAVE)
GHC_CMD=ghc
.endif

.include ${.CURDIR}/../../lang/ghc/bsd.cabal.mk
.include bsd.port.mk



Ivan Miljenovic wrote:
 
 Which version of GHC, which version of Cabal, and what is the Makefile?
 
 zaxis z_a...@163.com writes:
 
 /usr/ports/devel/hs-ghc-pathssudo make install clean
 ===   hs-ghc-paths-0.1.0.5_1 depends on executable: ghc - found
 ===  Configuring for hs-ghc-paths-0.1.0.5_1
 [1 of 1] Compiling Main ( Setup.hs, Setup.o )

 Setup.hs:18:22: Not in scope: `preMakefile'
 *** Error code 1

 Stop in /usr/ports/devel/hs-ghc-paths.

 Sincerely!

 -
 e^(π⋅i) + 1 = 0
 
 -- 
 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
 
 


-
e^(π⋅i) + 1 = 0
-- 
View this message in context: 
http://old.nabble.com/How-to-fix-this-problem-in-FreeBSD---tp28714271p28714430.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

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


Re: [Haskell-cafe] Wire GUI

2010-05-29 Thread Andrew Coppin

Malcolm Wallace wrote:
I'm looking at a project which involves a GUI where you can insert 
components and wire up connections between them. Obviously the 
details of what the components are and what code gets executed for 
them is domain-specific, however the general idea of graphically 
wiring things together is quite generic. Has anybody already put 
together a Haskell library for doing this kind of thing?


Blobs.  (warning: some danger of bitrot)

http://www.cs.york.ac.uk/fp/darcs/Blobs/


Thanks for the tip.

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


Re: [Haskell-cafe] Wire GUI

2010-05-29 Thread Christopher Done
Conal Elliot's talk on Tangible Functional Programming might be of
interest. http://www.youtube.com/watch?v=faJ8N0giqzw

On 29 May 2010 09:43, Andrew Coppin andrewcop...@btinternet.com wrote:
 Malcolm Wallace wrote:

 I'm looking at a project which involves a GUI where you can insert
 components and wire up connections between them. Obviously the details of
 what the components are and what code gets executed for them is
 domain-specific, however the general idea of graphically wiring things
 together is quite generic. Has anybody already put together a Haskell
 library for doing this kind of thing?

 Blobs.  (warning: some danger of bitrot)

 http://www.cs.york.ac.uk/fp/darcs/Blobs/

 Thanks for the tip.

 ___
 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: Math questions

2010-05-29 Thread Pete Chown

Mujtaba Boori wrote:


sure I did enjoy the discussion here Yitzchak Gale. I have already
submitted several questions ,and you guys were very helpful. However , I
am not sure how I will use Haskell other than my Haskell course that has
just finished.


I would very much recommend the Real World Haskell book if you want to 
write real programs with it.  I was interested in Haskell for a long 
time, but it was only after I read that book that I could see how to 
structure larger programs.


I've only written a few real world programs with Haskell, but I do think 
there are some situations where it reduces development time compared to 
other languages.  Ideally, I suppose, you would have a type-safe 
language with the flexibility of Python.  Haskell isn't quite that, but 
it probably gets closer than other languages, thanks to its flexible 
type system and support for type inference.  It's also particularly good 
for parsing text (Parsec is much nicer than yacc) and multithreading 
(the STM module is particularly good).


Downsides: the libraries aren't as complete or well tested as some other 
languages.  Also I suppose it has to be said that functions which update 
state can become clumsy.  The state monad helps with this, but you can 
still find yourself writing more code than you would need in other 
languages.


Pete

PS here is a more serious answer to the original question...

test f1 f2 = and [f1 i == f2 i | i - [1..100]]

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


[Haskell-cafe] Re: [Haskell] Re: Work on Video Games in Haskell

2010-05-29 Thread Benjamin L. Russell
Edward Kmett ekm...@gmail.com writes:

 On Wed, May 26, 2010 at 5:22 PM, Pierre-Etienne Meunier span 
 dir=ltrmailto:pierreetienne.meun...@gmail.com/span wrote:
 Well in this case I#39;d be really interested in seeing how the can tell the 
 difference, be it only from a simple complexity theoretic point of view ! I 
 understand they may look for common patterns in their compiler code to tell 
 the difference between GHC#39;s generated code and theirs, but pretending 
 they can do it in this case only shows that Apple lawyers never communicate 
 with the engineers.
 I think it is more a matter of Jobs trying to find any way he could to 
 quickly block Adobe#39;s attempted end-run around his blockade against Flash 
 apps.While we can all acknowledge the technical impossibility of identifying 
 the original source language of a piece of code, all they need is to raise 
 the spectre of doubt, and they have practically gutted all concern of a cross 
 platform development environment emerging, because no sound business plan can 
 be built on I hope my major and only possible distributor doesn#39;t figure 
 out what I#39;m doing!

While it may be difficult to identify the original source language of an
arbitrary piece of code, it is much simpler to identify Haskell as the
original source language of a GHC-compiled piece of code for most pieces
of code.

There are a number of interesting discussions on this issue at the sites
below:

[1] Daring Fireball: New iPhone Developer Agreement Bans the Use of Adobe's
Flash-to-iPhone Compiler
http://daringfireball.net/2010/04/iphone_agreement_bans_flash_compiler

[2] Hacker News | Getting away from the frenzied rhetoric, my opinion is
that what Apple really wa...
http://news.ycombinator.com/item?id=1250946

[3] Knowing .NET » Blog Archive » The Absurdity of Apple’s New iPhone
Restrictions
http://www.knowing.net/index.php/2010/04/09/using-mathematica-to-generate-the-elements-appebook/

[4] Why does everything suck?: Steve Jobs Has Just Gone Mad
http://whydoeseverythingsuck.com/2010/04/steve-jobs-has-just-gone-mad.html

[5] Apple takes aim at Adobe... or Android?
http://arstechnica.com/apple/news/2010/04/apple-takes-aim-at-adobe-or-android.ars

In addition, the following article sheds some light on the historical
background for the initial Apple vs. Adobe schism:

[6] Rhapsody and blues
http://arstechnica.com/staff/fatbits/2008/04/rhapsody-and-blues.ars

Curiously, in the original Apple Macintosh Superbowl commercial (see
http://video.google.com/videoplay?docid=-715862862672743260#), Apple
(then Apple Computer) proclaimed the following:

 On January 24th, Apple Computer will introduce Macintosh.  And you'll
 see why 1984 won't be like 1984.

George Orwell's novel, _1984_, was essentially about freedom of expression
(among a number of other freedoms).

Ironically, by prohibiting freedom of expression in the choice of a
programming language for the iPhone and requiring that all applications
be originally written in Objective-C, C, C++, or JavaScript as executed
by the iPhone OS Webkit engine, Apple has now become the epitome of the
very thing it had originally set out *not* to be.

-- Benjamin L. Russell

[1] Gruber, John. New iPhone Developer Agreement Bans the Use of
Adobe’s Flash-to-iPhone Compiler. n.p. 8 Apr. 2010. Web. 29 May
2010. http://daringfireball.net/2010/04/iphone_agreement_bans_flash_compiler.

[2] raganwald. n.t. _Hacker News._ Y Combinator.  9 Apr. 2010. Web. 29
May 2010. http://news.ycombinator.com/item?id=1250946.

[3] O'Brien, Larry. The Absurdity of Apple’s New iPhone Restrictions.
_Knowing .NET._ n.p. 9 Apr. 2010. Web. 29 May
2010. 
http://www.knowing.net/index.php/2010/04/09/using-mathematica-to-generate-the-elements-appebook/
.

[4] Williams, Hank. Steve Jobs Has Just Gone Mad. _Why does
everything suck?: Exploring the tech marketplace from 10,000 feet._
n.p. 8 Apr. 2010. Web. 29 May
2010. 
http://whydoeseverythingsuck.com/2010/04/steve-jobs-has-just-gone-mad.html.

[5] Bright, Peter. Apple takes aim at Adobe... or Android? _Ars
Technica._ Condé Nast Digital. Apr. 2010. Web. 29 May
2010. 
http://arstechnica.com/apple/news/2010/04/apple-takes-aim-at-adobe-or-android.ars.

[6] Siracusa, John. Rhapsody and blues. _Ars Technica._ Condé Nast
Digital. 3 Apr. 2008. Web. 29 May
2010. http://arstechnica.com/staff/fatbits/2008/04/rhapsody-and-blues.ars.

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


[Haskell-cafe] Reproducible Bug in Emacs' haskell-mode

2010-05-29 Thread aditya siram
Hi all,
I have a reproducible bug in Emacs' Haskell mode where Emacs gets
stuck in an endless loop. I am using GNU Emacs 23.0.93.1. To
reproduce:
1. Use a bad Language pragma eg.
{-# LANGUAGE FlexibleTypes #-}
2. Load a GHCI instance with C-c C-l. GHCI outputs the following error:
unsupported extension: FlexibleTypes
3. Fix the pragma:
{-# FlexibleInstances -#}
4. Try to load the file again with C-c C-l and Emacs gets stuck.

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


[Haskell-cafe] Re: [web-devel] Google Summer of Code: BlazeHTML RFC

2010-05-29 Thread Matt Parker
 Q3: Which HTML version would you preferably use?


HTML 5. google summer of code should be about pushing the new and exciting.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: [web-devel] Google Summer of Code: BlazeHTML RFC

2010-05-29 Thread Gregory Collins
Matt Parker moonmaster9...@gmail.com writes:

 Q3: Which HTML version would you preferably use?

 HTML 5. google summer of code should be about pushing the new and exciting. 

Yes, definitely, this should be the default IMO.

G
-- 
Gregory Collins g...@gregorycollins.net
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Reproducible Bug in Emacs' haskell-mode

2010-05-29 Thread Ivan Lazar Miljenovic
Try the following:

1) M-x toggle-debug-on-quit (so that it's enabled)

2) Follow your instructions below

3) When it's stuck, do C-g to stop it trying to load the file.

Just so you know, there's also a dedicated mailing list for the Haskell
mode in Emacs; see here for more information:
http://projects.haskell.org/haskellmode-emacs/

aditya siram aditya.si...@gmail.com writes:

 Hi all,
 I have a reproducible bug in Emacs' Haskell mode where Emacs gets
 stuck in an endless loop. I am using GNU Emacs 23.0.93.1. To
 reproduce:
 1. Use a bad Language pragma eg.
 {-# LANGUAGE FlexibleTypes #-}
 2. Load a GHCI instance with C-c C-l. GHCI outputs the following error:
 unsupported extension: FlexibleTypes
 3. Fix the pragma:
 {-# FlexibleInstances -#}
 4. Try to load the file again with C-c C-l and Emacs gets stuck.

 -deech
 ___
 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] Why Either = Left | Right instead of something like Result = Success | Failure

2010-05-29 Thread Yitzchak Gale
Vo Minh Thu wrote:
 Control.Monad.Error provides an instance for Either.

Donn Cave wrote:
 ... in the mtl transformer library, in case anyone else besides
 myself didn't know that. And I see it has to be there because
 it depends on the Error typeclass.

Daniel Fischer daniel.is.fisc...@web.de writes:
 Which is considered a wart by some. (Either left) has a perfectly valid
 Monad instance for any type left

Indeed, and it is one of the most useful Monads there is.
The Either monad provides short-circuiting logic, so that
you can exit an arbitrary number of levels of nested calculation.
The type Either a b returns a if the calculation exits,
or b if it completes without exiting.

Exiting on an error condition is one tiny corner case of
multi-level exit, so it is a shame that the mtl library defines
an orphan instance. By doing that, it hijacks the Either monad
and monopolizes it for its own specialized purpose. This is the
classic example why defining orphan instances is so dangerous.

Now, instead of the natural use of Either for short-circuiting logic,
we are forced to find other solutions, such as:

o use the MonadPlus instance of Maybe and write everything
  additively, using mplus and return instead of (=) and Left.
  That is equivalent to the Either monad, but in practice it ends
  up looking a lot messier and harder to read.

o use a CPS-based monad, like Cont or LogicT. I find those
  highly obfuscated, and a huge amount of complexity overkill
  for most tasks.

o use a clone of Either, like the Exit monad. That is currently the
  best workaround, in my opinion.

http://www.haskell.org/haskellwiki/New_monads/MonadExit

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


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

2010-05-29 Thread Carlos Camarao
On Fri, May 28, 2010 at 2:36 AM, Isaac Dupree 
m...@isaac.cedarswampstudios.org wrote:

 On 05/27/10 17:42, Carlos Camarao wrote:

 On Thu, May 27, 2010 at 5:43 PM, David Menendezd...@zednenem.com
  wrote:

  On Thu, May 27, 2010 at 10:39 AM, Carlos Camarao
 carlos.cama...@gmail.com  wrote:

 Isaac Dupree:

 Your proposal appears to allow /incoherent/ instance selection.
 This means that an expression can be well-typed in one module, and
 well-typed in another module, but have different semantics in the
 two modules.  For example (drawing from above discussion) :

 module C where

 class F a b where f :: a -  b
 class O a where o :: a

 module P where
 import C

 instance F Bool Bool where f = not
 instance O Bool where o = True
 k :: Bool
 k = f o

 module Q where
 import C
 instance F Int Bool where f = even
 instance O Int where o = 0
 k :: Bool
 k = f o

 module Main where
 import P
 import Q
 -- (here, all four instances are in scope)
 main = do { print P.k ; print Q.k }
 -- should result, according to your proposal, in
 -- False
 -- True
 -- , am I correct?


 If qualified importation of k from both P and from Q was specified, we
 would have two *distinct* terms, P.k and Q.k.


 I think Isaac's point is that P.k and Q.k have the same definition (f
 o). If they don't produce the same value, then referential
 transparency is lost.

 --
 Dave Menendezd...@zednenem.com
 http://www.eyrie.org/~zednenem/ http://www.eyrie.org/%7Ezednenem/
 http://www.eyrie.org/%7Ezednenem/


 The definitions of P.k and Q.k are textually the same but the contexts are
 different. f and o denote distinct values in P and Q. Thus, P.k and
 Q.k
 don't have the same definition.


 Oh, I guess you are correct: it is like defaulting: it is a similar effect
 where the same expression means different things in two different modules as
 if you had default (Int) in one, and default (Bool) in the other.  Except:
 Defaulting according to the standard only works in combination with the 8
 (or however many it is) standard classes; and defaulting in Haskell is
 already a bit poorly designed / frowned upon / annoying that it's specified
 per-module when nothing else in the language is*.(that's a rather
 surmountable argument)


 It may be worth reading the GHC user's guide which attempts to explain the
 difference between incoherent and non-incoherent instance selection,

 http://www.haskell.org/ghc/docs/6.12.2/html/users_guide/type-class-extensions.html#instance-overlap
 I didn't read both it and your paper closely enough that I'm sure anymore
 whether GHC devs would think your extension would require or imply
 -XIncoherentInstances ... my intuition was that IncoherentInstances would be
 implied...

 *(it's nice when you can substitute any use of a variable, such as P.k,
 with the expression that it is defined as -- i.e. the expression written so
 that it refer to the same identifiers, not a purely textual substitution --
 but in main above, you can't write [assuming you imported C] print (f o)
 because it will be rejected for ambiguity. (Now, there is already an
 instance-related situation like this where Main imports two different
 modules that define instances that overlap in an incompatible way, such as
 two different instances for Functor (Either e) -- not everyone is happy
 about how GHC handles this, but at least those overlaps are totally useless
 and could perhaps legitimately result in a compile error if they're even
 imported into the same module.))
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe


I have no idea why you think IncoherentInstances would be implied. The
proposal says: do not issue ambiguity error if, using whatever means
permitted and specified (OverlappingInstances, IncoherentInstances,
whatever),  you can select a single instance.

The situation is as if we a FD:

module C where
  class F a b | a-b where f :: a -  b
  class O a where o :: a

module P where
  import C; instance F Bool Bool where f = not
  instance O Bool where o = True
  g:: Bool - Bool
  g = f
  k::Bool
  k = g o

module Q where
  import C
  instance F Int Bool where f = even
  instance O Int where o = 0
  g::Int-Bool
  g = f
  k :: Bool
  k = g o

module Main where
   import P
   import Q
   main = do { print P.k ; print Q.k }

Cheers,

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


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

2010-05-29 Thread Isaac Dupree

On 05/29/10 21:24, Carlos Camarao wrote:

The situation is as if we a FD:


Well, that is indeed equivalent here in the second argument of class F, 
but I constructed the example to show an issue in the class's *first* 
argument.


Notice you needed to add type-signatures, on the functions you named g 
-- in particular their first arguments -- to make the example work with 
only FDs?



module C where
   class F a b | a-b where f :: a -   b
   class O a where o :: a

module P where
   import C; instance F Bool Bool where f = not
   instance O Bool where o = True
   g:: Bool -  Bool
   g = f
   k::Bool
   k = g o

module Q where
   import C
   instance F Int Bool where f = even
   instance O Int where o = 0
   g::Int-Bool
   g = f
   k :: Bool
   k = g o


you can inline these k-definitions into module Main and it will work 
(modulo importing C).


module Main where
import C
import P
import Q
main = do { print (((f :: Bool - Bool) o) :: Bool);
print (((f :: Int - Bool) o) :: Bool) }

These are two different expressions that are being printed, because
 :: Bool - Bool is different from  :: Int - Bool.  In my example 
of using your proposal, one cannot inline in the same way, if I 
understand correctly (the inlining would cause ambiguity errors -- 
unless of course the above distinct type-signatures are added).


If your proposal was able to require those -- and only those -- bits of 
type signatures that were essential to resolve the above ambiguity; for 
example, the ( :: Int) below,

module Q where
   import C
   instance F Int Bool where f = even
   instance O Int where o = 0
   k = f (o :: Int)
, then I would be fine with your proposal (but then I suspect it would 
have to be equivalent to FDs -- or in other words, that it's not really 
practical to change your proposal to have that effect).


I stand by my assertion that the same expression means different things 
in two different modules is undesirable, (and that I suspect but am 
unsure that this undesirability is named incoherent instances).
I'm trying to work out whether it's possible to violate the invariants 
of a Map by using your extension (having it select a different instance 
in two different places, given the same type).. I think, no it is not 
possible for Ord or any single-parameter typeclass, though there might 
be some kind of issues with multi-parameter typeclasses, if the library 
relies on a FD-style relationship between two class type-parameters and 
then two someones each add an instance that together violate that 
implied FD-relationship (which is allowed under your scheme, unlike if 
there was an actual FD).  Er, odd, I need to play with some actual FD 
code to think about this, but I'm too sleepy / busy packing for a trip.


Did any of the above make sense to you?  It's fine if some didn't, type 
systems are complicated... and please point out if something I said was 
outright wrong.



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


[Haskell-cafe] A question on existential types and Church encoding

2010-05-29 Thread Cory Knapp
Hello,

A professor of mine was recently playing around during a lecture with Church
booleans (I.e., true = \x y - x; false = \x y - y) in Scala and OCaml. I
missed what he did, so I reworked it in Haskell and got this:

type CB a = a - a - a

ct :: CB aC
ct x y = x

cf :: CB a
cf x y = y

cand :: CB (CB a) - CB a - CB a
cand p q = p q cf

cor :: CB (CB a) - CB a - CB a
cor p q = p ct q

I found the lack of type symmetry (the fact that the predicate arguments
don't have the same time) somewhat disturbing, so I tried to find a way to
fix it. I remembered reading about existential types being used for similar
type-hackery, so I added quantification to the CB type and got

type CB a = forall a . a - a - a

ctrue :: CB a
ctrue x y = x

cfalse :: CB a
cfalse x y = y

cand :: CB a - CB a - CB a
cand p q = p q cfalse

cor :: CB a - CB a - CB a
cor p q = p ctrue q

which works. But I haven't the faintest idea why that forall in the type
makes things work... I just don't fully understand existential type
quantification. Could anyone explain to me what's going on that makes the
second code work?

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