From 6a0d7f5c434c3564d0119befb6799fd77581050a Mon Sep 17 00:00:00 2001 From: Paul Oliver Date: Fri, 3 Jan 2025 11:01:20 -0800 Subject: Initial --- ch07_07.1-ii.hs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 ch07_07.1-ii.hs (limited to 'ch07_07.1-ii.hs') diff --git a/ch07_07.1-ii.hs b/ch07_07.1-ii.hs new file mode 100644 index 0000000..91abc8d --- /dev/null +++ b/ch07_07.1-ii.hs @@ -0,0 +1,14 @@ +-- Exercise 7.1-ii +-- What happens to this instance if you remove the `Show t =>` constraint from +-- `HasShow`. + +-- Removing `Show t =>` below makes GHC angry: +-- +-- • No instance for ‘Show t’ arising from a use of ‘show’ +-- Possible fix: +-- add (Show t) to the context of the data constructor ‘HasShow’ +data HasShow where + HasShow :: Show t => t -> HasShow + +instance Show HasShow where + show (HasShow t) = "HasShow " <> show t -- cgit v1.2.1