[Haskell-cafe] Usage of . and $
David House
dmhouse at gmail.com
Thu Mar 8 12:26:55 EST 2007
On 08/03/07, Simon Peyton-Jones <simonpj at microsoft.com> wrote:
> NB that infix type constructors must start with ":", just like infix data constructors.
Now that's just not true.
> {-# OPTIONS_GHC -fglasgow-exts #-}
>
> type a $ b = a b
>
> data Foo a = Foo a deriving (Show)
> data Bar = Bar (Foo $ Int) deriving (Show)
>
> main = print (Bar (Foo 4))
GHCi session:
Prelude> :load "/home/david/hs/sandbox/infix-tycons.hs"
[1 of 1] Compiling Main (
/home/david/hs/sandbox/infix-tycons.hs, interpreted )
Ok, modules loaded: Main.
*Main> main
Bar (Foo 4)
*Main>
----------------------------
There would be no reason for this restriction. The only reason to
start infix data constructors with ':' would be to seperate them
lexically from infix functions -- just as a leading capital serves to
seperate prefix data constructors from prefix functions. There is no
such clash with type constructors as there are no type functions.
Hence the classic example:
class Arrow (~>) where ...
--
-David House, dmhouse at gmail.com
More information about the Haskell-Cafe
mailing list