[Haskell-cafe] snd and tuples of various sizes...

Mattias Bengtsson moonlite at dtek.chalmers.se
Fri Feb 2 07:28:49 EST 2007

On Thu, 2007-02-01 at 21:01 -1000, Tim Newsham wrote:
> instance Second [a] a where
>      snd [] = error "don't got none"
>      snd (x:y:xs) = y 

Would'nt that instance mean this:
  snd [] produces error
  snd [x] gives []

I'd implement it something like this (if this works?):

instance Second [a] (Maybe a) where
     snd [] = Nothing
     snd [x] = Nothing
     snd (x:y:xs) = Just y 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20070202/c1d8a641/attachment.bin

More information about the Haskell-Cafe mailing list