Re: [Haskell-cafe] Usage of . and $

On 07/03/07, Thomas Conway
Of course, what really gets me, is when I start trying to use $ in type signatures and declarations: ... Map ByteString $ foo (bar baz) qux ....
It's almost possible! GHC gives us infix type synonyms: type a $ b = a b (Probably needs -fglasgow-exts.) Sadly we don't have a fixity system for type operators :( -- -David House, dmhouse@gmail.com

| type a $ b = a b | | (Probably needs -fglasgow-exts.) Sadly we don't have a fixity system | for type operators :( Actually GHC lets you give fixity declarations for type operators too. NB that infix type constructors must start with ":", just like infix data constructors. Simon

On 08/03/07, Simon Peyton-Jones
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@gmail.com
participants (2)
-
David House
-
Simon Peyton-Jones