From 7b6a8bf1ba4c24fe212ddae6c9202a6a3513c6ba Mon Sep 17 00:00:00 2001 From: Jan Sucan Date: Sun, 16 Apr 2023 08:24:35 +0200 Subject: 6_a_2: Add solution --- ch06/6_a_2.txt | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 ch06/6_a_2.txt (limited to 'ch06') 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) -- cgit v1.2.3