2009/7/21 Roel van Dijk <[email protected]>:
I am also wondering what the following would/should mean:

  (1, , ( , 2), ) 'a' 'b' 'c'

I would expect it to be a type error, since I think the following is the
only sane type the tuple can have (assuming numeric literals :: Int):

(1, , ( , 2), ) :: a -> b -> (Int, a, c -> (c, Int), b)

Ganesh

Ah you're completely right! I would be applying a tuple to a Char
which is nonsense.

You can kind of do it if you indicate which 'field' is to be applied:

 import Control.Applicative

 newtype Fst b a = Fst (a,b) deriving (Show)
 newtype Snd a b = Snd (a,b) deriving (Show)

 instance Functor (Fst b) where
        fmap f (Fst (a,b)) = Fst (f a,b)

 instance Functor (Snd a) where
        fmap f (Snd (a,b)) = Snd (a,f b)

 f <$$> x = ($x) <$> f

...

Fst ((,)1,3) <$$> 2 -- no section, don't have the patch ;)
Fst ((1,2),3)

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to