From a331c1c03378e9ce24f4c1b5ce4ab9806e4b5d42 Mon Sep 17 00:00:00 2001 From: Matt Renaud Date: Mon, 1 Jun 2020 13:13:27 -0700 Subject: [PATCH] Formatting fixes in tutorial modules. --- Tutorial.hs | 10 +++++----- Tutorial/HashSet.hs | 21 +++++++++++---------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/Tutorial.hs b/Tutorial.hs index ae3cfe46..8dd28edf 100644 --- a/Tutorial.hs +++ b/Tutorial.hs @@ -50,21 +50,21 @@ more examples or tutorials you should check out: -} {- $installing -__Version Requirements__ +==Version Requirements All of the examples here should work for all recent versions of the package. -__Importing modules__ +==Importing modules All of the modules in @unordered-containers@@ should be imported @qualified@ since they use names that conflict with the standard Prelude. @ -import qualified Data.HashSet as HashSet -import qualified Data.HashMap.Strict as HashMap +import qualified 'Data.HashSet' as HashSet +import qualified 'Data.HashMap.Strict' as HashMap @ -__In GHCi__ +==In GHCi Start the GHCi with diff --git a/Tutorial/HashSet.hs b/Tutorial/HashSet.hs index 9b8c8f76..232dab1e 100644 --- a/Tutorial/HashSet.hs +++ b/Tutorial/HashSet.hs @@ -8,7 +8,7 @@ introductory documentation for @containers@ at . @ -data HashSet element = ... +data 'HashSet' element = ... @ @@ -17,8 +17,8 @@ functions do not modify the set that you passed in, they creates a new set. In order to keep the changes you need to assign it to a new variable. For example: @ -let s1 = HashSet.fromList ["a", "b"] -let s2 = HashSet.delete "a" s1 +let s1 = 'HashSet.fromList' ["a", "b"] +let s2 = 'HashSet.delete' "a" s1 print s1 > fromList ["a","b"] print s2 @@ -41,42 +41,43 @@ module Tutorial.HashSet ( ) where +import qualified Data.HashSet as HashSet {- $shortexample The following GHCi session shows some of the basic set functionality: @ -import qualified Data.HashSet as HashSet +import qualified 'Data.HashSet' as HashSet -let dataStructures = HashSet.fromList ["HashSet", "HashMap", "Graph"] +let dataStructures = 'HashSet.fromList' ["HashSet", "HashMap", "Graph"] -- Check if "HashMap" and "Trie" are in the set of data structures. -HashSet.member "HashMap" dataStructures +'HashSet.member' "HashMap" dataStructures > True -HashSet.member "Trie" dataStructures +'HashSet.member' "Trie" dataStructures > False -- Add "Trie" to our original set of data structures. let moreDataStructures = HashSet.insert "Trie" dataStructures -HashSet.member "Trie" moreDataStructures +'HashSet.member' "Trie" moreDataStructures > True -- Remove "Graph" from our original set of data structures. let fewerDataStructures = HashSet.delete "Graph" dataStructures -HashSet.toList fewerDataStructures +'HashSet.toList' fewerDataStructures > ["HashSet", "HashMap"] -- Create a new set and combine it with our original set. let orderedDataStructures = HashSet.fromList ["Set", "Map"] -HashSet.union dataStructures orderedDataStructures +'HashSet.union' dataStructures orderedDataStructures > fromList ["Map", "HashSet", "Graph", "HashMap", "Set"] @