diff options
| author | Jan Sucan <jan@jansucan.com> | 2023-04-16 08:24:35 +0200 |
|---|---|---|
| committer | Jan Sucan <jan@jansucan.com> | 2023-04-16 08:24:35 +0200 |
| commit | 7b6a8bf1ba4c24fe212ddae6c9202a6a3513c6ba (patch) | |
| tree | b05f31c9f5ad688731460ab92d03cca46af2c2b1 /ch06 | |
| parent | a4d44a9b0867b9f7b0ce97d4c2d9078a726885a5 (diff) | |
6_a_2: Add solution
Diffstat (limited to 'ch06')
| -rw-r--r-- | ch06/6_a_2.txt | 33 |
1 files changed, 33 insertions, 0 deletions
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) |
