Paste number 27806: Yet Another Haskell Tutorial Exercise 4.6

Paste number 27806: | Yet Another Haskell Tutorial Exercise 4.6 |

Pasted by: | llimllib |

When: | 9 years, 7 months ago |

Share: | Tweet this! | http://paste.lisp.org/+LGE |

Channel: | None |

Paste contents: |

```
data Tuple a b c d = SingleTuple a
| DoubleTuple a b
| TripleTuple a b c
| QuadrupleTuple a b c d
tuple1 :: Tuple a b c d -> Maybe a
tuple1 (SingleTuple a) = Just a
tuple1 (DoubleTuple a b) = Just a
tuple1 (TripleTuple a b c) = Just a
tuple1 (QuadrupleTuple a b c d) = Just a
tuple2 :: Tuple a b c d -> Maybe b
tuple2 (SingleTuple a) = Nothing
tuple2 (DoubleTuple a b) = Just b
tuple2 (TripleTuple a b c) = Just b
tuple2 (QuadrupleTuple a b c d) = Just b
tuple3 :: Tuple a b c d -> Maybe c
tuple3 (SingleTuple a) = Nothing
tuple3 (DoubleTuple a b) = Nothing
tuple3 (TripleTuple a b c) = Just c
tuple3 (QuadrupleTuple a b c d) = Just c
tuple4 :: Tuple a b c d -> Maybe d
tuple4 (SingleTuple a) = Nothing
tuple4 (DoubleTuple a b) = Nothing
tuple4 (TripleTuple a b c) = Nothing
tuple4 (QuadrupleTuple a b c d) = Just d
```

This paste has no annotations.