Skip to content

Commit

Permalink
Formatting fixes in tutorial modules.
Browse files Browse the repository at this point in the history
  • Loading branch information
m-renaud committed Jun 1, 2020
1 parent 522fc41 commit a331c1c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
10 changes: 5 additions & 5 deletions Tutorial.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
<https://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop REPL> with
Expand Down
21 changes: 11 additions & 10 deletions Tutorial/HashSet.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ introductory documentation for @containers@ at
<https://haskell-containers.readthedocs.io>.
@
data HashSet element = ...
data 'HashSet' element = ...
@
Expand All @@ -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
Expand All @@ -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"]
@
Expand Down

0 comments on commit a331c1c

Please sign in to comment.