RE: [Haskell-cafe] Where does ~> come from?

2008-03-11 Thread Simon Peyton-Jones
| I think, it won’t find it.  As Cale said, it’s a type variable.  It’s like
| the “a” in the following definition:
|
| data T a = T a a
|
| I think, Conal Elliott used an operator type variable in order to make his
| code more readable.  The (~>) is a type parameter which stands for an arrow
| type.

I've been thinking for some time that GHC's current lexicographic choice about 
type variables, although consistent, is an mistake. (I say "GHC" because 
Haskell 98 does not have operator symbols in the type namespace at all.)

As of today,
a   is a type variable
T   is a type constructor
~>  is a type variable
:~> is a type constructor

That's consistent with the syntax for data constructors.  But it's a pain. For 
a start (->) is a type constructor not a type variable.  More important, it's 
just so right to declare a sum type like this

data a + b = Left a | Right b
f :: a -> (a+b)
f = ...


But GHC currently makes you say

data a :+: b = Left a | Right b
f :: a -> (a:+:b)

I hate those colons!  The obvious thing is to say that

operator symbols (of all kinds) are type constructors,
and only alphabetic things are type variables.

That's less consistent, but I think it might be more useful.

I was provoked to type this by realising that Conal, at least, is using an 
operator symbol (~>) as a type variable.  I wonder how bad it'd be in this case 
to have to use an alphabetic name (backquotes still work).

Just flying a kite here -- this isn't high on my list.  But the more we do at 
the type level, the more we want type expressions that look sensible.


Simon


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


Re: [Haskell-cafe] Where does ~> come from?

2008-02-20 Thread Stefan O'Rear
On Wed, Feb 20, 2008 at 07:18:42PM -0500, Steve Lihn wrote:
> If ~> does not have any special meaning and it could be ### or xyz,
> then how does GHC know to print
>  a ~> b, but not ~> a b
>  a ### b, but not ### a b
>  xyz a b, but not a `xyz` b
> 
> Simply because xyz is alphanumeric?

Yes.

Stefan


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


Re: [Haskell-cafe] Where does ~> come from?

2008-02-20 Thread Steve Lihn
If ~> does not have any special meaning and it could be ### or xyz,
then how does GHC know to print
 a ~> b, but not ~> a b
 a ### b, but not ### a b
 xyz a b, but not a `xyz` b

Simply because xyz is alphanumeric?


On Wed, Feb 20, 2008 at 12:34 AM, David Menendez <[EMAIL PROTECTED]> wrote:
> On Feb 19, 2008 4:15 PM, Wolfgang Jeltsch <[EMAIL PROTECTED]> wrote:
> > Am Dienstag, 19. Februar 2008 18:26 schrieben Sie:
> > > […]
> >
> > > However, I was told this:  ~> a b is a ~> b, but if I write c a b and
> > > wish the effect of a `c` b. This would not work. ~> as an infix operator
> > > has a special place in GHC. It is not "just a type variable".
> >
> > Sorry, but I don't understand fully what you mean. :-(  But nevertheless,
> > a ~> b is not the same as ~> a b but as (~>) a b.  It's just like with
> > ordinary operators where a + b is the same as (+) a b.
>
> Note that some (all?) versions of GHC will incorrectly print "a ~> b"
> as "~> a b".
>
> 
>
> Prelude> :t undefined :: a + b
> undefined :: a + b :: forall (+ :: * -> * -> *) a b. + a b
>
> It mostly gets infix type constructors right, although there are
> apparently problems with precedence and associativity.
>
> --
> Dave Menendez <[EMAIL PROTECTED]>
> 
>
> ___
> 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] Where does ~> come from?

2008-02-19 Thread David Menendez
On Feb 19, 2008 4:15 PM, Wolfgang Jeltsch <[EMAIL PROTECTED]> wrote:
> Am Dienstag, 19. Februar 2008 18:26 schrieben Sie:
> > […]
>
> > However, I was told this:  ~> a b is a ~> b, but if I write c a b and
> > wish the effect of a `c` b. This would not work. ~> as an infix operator
> > has a special place in GHC. It is not "just a type variable".
>
> Sorry, but I don't understand fully what you mean. :-(  But nevertheless,
> a ~> b is not the same as ~> a b but as (~>) a b.  It's just like with
> ordinary operators where a + b is the same as (+) a b.

Note that some (all?) versions of GHC will incorrectly print "a ~> b"
as "~> a b".



Prelude> :t undefined :: a + b
undefined :: a + b :: forall (+ :: * -> * -> *) a b. + a b

It mostly gets infix type constructors right, although there are
apparently problems with precedence and associativity.

-- 
Dave Menendez <[EMAIL PROTECTED]>

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


Re: [Haskell-cafe] Where does ~> come from?

2008-02-19 Thread Wolfgang Jeltsch
Am Dienstag, 19. Februar 2008 18:26 schrieben Sie:
> […]

> However, I was told this:  ~> a b is a ~> b, but if I write c a b and
> wish the effect of a `c` b. This would not work. ~> as an infix operator
> has a special place in GHC. It is not "just a type variable".

Sorry, but I don’t understand fully what you mean. :-(  But nevertheless,
a ~> b is not the same as ~> a b but as (~>) a b.  It’s just like with 
ordinary operators where a + b is the same as (+) a b.

~> is not special in GHC.  You could use, for example, ### instead of ~> and 
get the same results.  However, GHC accepts type operators only if you tell 
it to do so.  Give GHC the option -XTypeOperators or insert

{-# LANGUAGE TypeOperators #-}

at the beginning of your source file.

> […]

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


Re: [Haskell-cafe] Where does ~> come from?

2008-02-19 Thread Wolfgang Jeltsch
Am Sonntag, 17. Februar 2008 14:41 schrieb Neil Mitchell:
> Hi
>
> > 2) You would hope there is a quick way to search those symbols. But
> > most search engines do not treate symbols friendly, often just ignore
> > them. I typed ~> in Hoogle, it also returned nothing.
> > 3) If the module defining the symbol is not in standard library, it is
> > not possible to look up the symbol in the core library index.
>
> The next version of Hoogle will allow you to search all the modules on
> Hackage, i.e. it will find ~>. A month after I have written my thesis
> this will all be done :-)
>
> Thanks
>
> Neil

I think, it won’t find it.  As Cale said, it’s a type variable.  It’s like 
the “a” in the following definition:

data T a = T a a

I think, Conal Elliott used an operator type variable in order to make his 
code more readable.  The (~>) is a type parameter which stands for an arrow 
type.

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


Re: [Haskell-cafe] Where does ~> come from?

2008-02-17 Thread Neil Mitchell
Hi

> 2) You would hope there is a quick way to search those symbols. But
> most search engines do not treate symbols friendly, often just ignore
> them. I typed ~> in Hoogle, it also returned nothing.
> 3) If the module defining the symbol is not in standard library, it is
> not possible to look up the symbol in the core library index.

The next version of Hoogle will allow you to search all the modules on
Hackage, i.e. it will find ~>. A month after I have written my thesis
this will all be done :-)

Thanks

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


Re: [Haskell-cafe] Where does ~> come from?

2008-02-16 Thread Cale Gibbard
On 17/02/2008, Steve Lihn <[EMAIL PROTECTED]> wrote:
> While I am reading TypeCompose module, I am having trouble finding
> where ~> comes from? (And its son ~~> and grandson ~~~>, etc.)  This
> is my immediate question. Help is appreciated.

(~>) is typically an infix type variable. If it were a constructor, it
would have to start with a colon. So it doesn't have a definition as
such, you can think of it as any type constructor with at least two
type parameters.

I think that would explain why you were having such trouble searching for it!

Generally, though, if you want to know where something is defined, you
can use ghci's :info command, and it should tell you the file and line
in which it's defined, as well as its type (if it's a value) and its
fixity (if it's an infix operator).

You can then load up whatever documentation or source code is
available for that module.  Of course, in this case, it would report
(correctly) that (~>) is not in scope.

Usually, packages on Hackage have whatever documentation is available
linked directly from their pages on Hackage.

hope this helps!
 - Cale
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Where does ~> come from?

2008-02-16 Thread Steve Lihn
While I am reading TypeCompose module, I am having trouble finding
where ~> comes from? (And its son ~~> and grandson ~~~>, etc.)  This
is my immediate question. Help is appreciated.

A bigger (higher-order?) issue I encountered and I think other people
could also have is to look up all these special "symbols" during the
learning curve. As things are getting higher and higher order in
Haskell, more inventive symbols are appearing. It becomes harder to
remember the exact definitions are. The difficulties are:

1) I used to see a page on haskell.org that lists many symbols, but I
could not find that page any more.
2) You would hope there is a quick way to search those symbols. But
most search engines do not treate symbols friendly, often just ignore
them. I typed ~> in Hoogle, it also returned nothing.
3) If the module defining the symbol is not in standard library, it is
not possible to look up the symbol in the core library index.

The only way to find the symbol seems to go to the source code, check
every module being imported and if I am lucky I will find it in the
same package. If  I am not lucky, I will have to search that module on
the Internet, and hunt it down recursively.

I wonder if anybody has the same problem. If enough crowd have the
same problem, maybe there could be a better way to handle this kind of
documentation/learning issue!

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