From 0b376f7eb33a16976822462fbfb4e41128786c03 Mon Sep 17 00:00:00 2001 From: Peter Tseng Date: Thu, 7 Apr 2016 02:16:58 -0700 Subject: [PATCH 1/3] binary-search-tree: rm example redundant constraints MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Note that this only affects the example, not the tests. GHC 8.0.1 will give the error: ``` BST.hs:15:1: warning: [-Wredundant-constraints] • Redundant constraint: Ord a • In the type signature for: singleton :: Ord a => a -> BST a ``` That makes sense, since you can make any value a singleton tree; it doesn't necessarily have to be Ord. Of course, you'll find yourself unable to add other values to the tree if it's not Ord, but that's not `singleton`'s problem. --- exercises/binary-search-tree/example.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/binary-search-tree/example.hs b/exercises/binary-search-tree/example.hs index d98d55afd..acd643e12 100644 --- a/exercises/binary-search-tree/example.hs +++ b/exercises/binary-search-tree/example.hs @@ -38,7 +38,7 @@ bstRight (Node _ _ r) = Just r empty :: BST a empty = Tip -singleton :: Ord a => a -> BST a +singleton :: a -> BST a singleton x = Node empty x empty insert :: Ord a => a -> BST a -> BST a From c96994a8e0e58debccffadc9293f24167b718d5a Mon Sep 17 00:00:00 2001 From: Peter Tseng Date: Thu, 7 Apr 2016 02:19:21 -0700 Subject: [PATCH 2/3] custom-set: rm example redundant constraints MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Note that this only affects the example, not the tests. GHC 8.0.1 will give the error: ``` CustomSet.hs:30:10: warning: [-Wredundant-constraints] • Redundant constraint: Eq a • In the instance declaration for ‘Eq (CustomSet a)’ CustomSet.hs:50:1: warning: [-Wredundant-constraints] • Redundant constraint: Ord a • In the type signature for: singleton :: Ord a => a -> CustomSet a CustomSet.hs:56:1: warning: [-Wredundant-constraints] • Redundant constraint: Ord a • In the type signature for: empty :: Ord a => CustomSet a ``` The singleton redundancy makes sense, since you can make any value a singleton set; it doesn't necessarily have to be Ord. Of course, you'll find yourself unable to add other values to the set if it's not Ord, but that's not `singleton`'s problem. The empty redundancy makes sense as well, since an empty set can be a set for any type, not necessarily ordered types. Ordering is only required if the set may contain elements. The `Eq` reduncancy is simply because `Ord` has already a constraint of `Eq a => Ord a`. This is true as of the current version: https://hackage.haskell.org/package/base-4.8.2.0/docs/Data-Ord.html and has been true since at least 4.0.0.0: https://hackage.haskell.org/package/base-4.0.0.0/docs/Data-Ord.html --- exercises/custom-set/example.hs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/exercises/custom-set/example.hs b/exercises/custom-set/example.hs index b64714347..09c868d0b 100644 --- a/exercises/custom-set/example.hs +++ b/exercises/custom-set/example.hs @@ -27,7 +27,7 @@ data CustomSet a = Tip | Bin {-# UNPACK #-} !Int !a !(CustomSet a) !(CustomSet a) -instance (Ord a, Eq a) => Eq (CustomSet a) where +instance (Ord a) => Eq (CustomSet a) where a == b = size a == size b && a `isSubsetOf` b instance Show a => Show (CustomSet a) where @@ -47,13 +47,13 @@ size :: CustomSet a -> Int size Tip = 0 size (Bin s _a _l _r) = s -singleton :: Ord a => a -> CustomSet a +singleton :: a -> CustomSet a singleton x = Bin 1 x Tip Tip toList :: CustomSet a -> [a] toList = F.toList -empty :: Ord a => CustomSet a +empty :: CustomSet a empty = Tip fromList :: Ord a => [a] -> CustomSet a From 034b624d64046dbe817fd8345476a6f44a44723e Mon Sep 17 00:00:00 2001 From: Peter Tseng Date: Fri, 17 Jun 2016 22:06:50 -0700 Subject: [PATCH 3/3] travis: Test ghc 8.0.1 It was released about a month ago so it is prudent to start testing code with it. Blog post: https://ghc.haskell.org/trac/ghc/blog/ghc-8.0.1-released Migration: https://ghc.haskell.org/trac/ghc/wiki/Migration/8.0 Release notes: https://downloads.haskell.org/~ghc/8.0.1/docs/html/users_guide/8.0.1-notes.html --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 59c824898..9bc7a9747 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,6 +13,7 @@ addons: - ghc-7.6.3 - ghc-7.8.4 - ghc-7.10.3 + - ghc-8.0.1 - cabal-install-1.22 env: global: @@ -21,6 +22,7 @@ env: - GHCVER=7.6.3 - GHCVER=7.8.4 - GHCVER=7.10.3 + - GHCVER=8.0.1 cache: directories: - '$HOME/.ghc'