aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md2
-rw-r--r--ch06/6_a_2.txt33
2 files changed, 34 insertions, 1 deletions
diff --git a/README.md b/README.md
index 57f55d0..90614f0 100644
--- a/README.md
+++ b/README.md
@@ -105,7 +105,7 @@ of a group is in bold italics.
| **_5_a_1_** | yes | 130 | 5. Writing a library: working with JSON data |
| 5_a_2 | yes, in 5_a_1 | | |
| **_6_a_1_** | yes | 162 | 6. Using typeclasses |
-| 6_a_2 | | | |
+| 6_a_2 | yes | | |
| **_8_a_1_** | | 205 | 8. Efficient file processing, regular expressions, and file name matching |
| 8_a_2 | | | |
| **_8_b_1_** | | 210 | |
diff --git a/ch06/6_a_2.txt b/ch06/6_a_2.txt
new file mode 100644
index 0000000..8c410c9
--- /dev/null
+++ b/ch06/6_a_2.txt
@@ -0,0 +1,33 @@
+-- What is the type of (,)? When you use it in ghci, what does it do? What about
+-- (,,)?
+
+-- (,) is a 2-tuple data constructor
+
+ghci> :t (,)
+(,) :: a -> b -> (a, b)
+
+ghci> (,) 1 2
+(1,2)
+
+ghci> t = (,) 1
+ghci> :t t
+t :: Num a => b -> (a, b)
+ghci> t 2
+(1,2)
+
+-- (,,) is a 3-tuple data constructor
+
+ghci> :t (,,)
+(,,) :: a -> b -> c -> (a, b, c)
+
+ghci> (,,) 1 2 3
+(1,2,3)
+
+ghci> t = (,,) 1
+ghci> :t t
+t :: Num a => b -> c -> (a, b, c)
+ghci> u = t 2
+ghci> :t u
+u :: (Num a, Num b) => c -> (a, b, c)
+ghci> u 3
+(1,2,3)