[Haskell-cafe] Implicit concatenation in list comprehensions
porges at porg.es
porges at porg.es
Mon Jul 20 21:36:04 EDT 2009
2009/7/21 Roel van Dijk <vandijk.roel at gmail.com>:
>>> 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)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 908 bytes
Desc: OpenPGP digital signature
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090720/914e9c57/signature.bin
More information about the Haskell-Cafe
mailing list