-
Notifications
You must be signed in to change notification settings - Fork 102
Create ReadTheDocs project for unordered-containers. #249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 8 commits
48767f7
c93a798
361fbf5
dc030aa
fe4ffde
9e3ccdd
522fc41
a331c1c
5e43fc1
858da6a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "docs/_extensions/haddock-autolink"] | ||
path = docs/_extensions/haddock-autolink | ||
url = https://github.com/m-renaud/haddock-autolink |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
version: 2 | ||
|
||
sphinx: | ||
configuration: docs/conf.py | ||
|
||
submodules: | ||
include: | ||
- docs/_extensions/haddock-autolink | ||
|
||
python: | ||
version: 2.7 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
{-# OPTIONS_GHC -fno-warn-unused-imports #-} | ||
|
||
{-| | ||
The @unordered-containers@ package provides implementations of various | ||
hash-based immutable data structures. | ||
|
||
Some of the data structures provided by this package have a very large API | ||
surface (for better or worse). The docs here focus on the most common functions | ||
which should be more than enough to get you started. Once you know the basics, | ||
or if you're looking for a specific function, you can head over to the | ||
full API documentation! | ||
-} | ||
|
||
|
||
module Tutorial ( | ||
-- * Provided Data Structures | ||
-- $provideddatastructures | ||
|
||
-- * Related Packages | ||
-- $relatedpackages | ||
|
||
-- * Looking for more resources? | ||
-- $moreresources | ||
|
||
-- * Installing and using the @unordered-containers@ packages | ||
-- $installing | ||
|
||
-- * HashSet and HashMap tutorial | ||
-- $tutorials | ||
|
||
) where | ||
|
||
{- $provideddatastructures | ||
* 'Data.HashSet' - unordered, non-duplicated elements | ||
* 'Data.HashMap' - unordered map from keys to values (aka. dictionaries) | ||
-} | ||
|
||
{- $relatedpackages | ||
* <https://hackage.haskell.org/packages/containers containers> - ordered containers using trees instead of hashing. | ||
* <https://hackage.haskell.org/packages/hashable containers> - types that can be converted to a hash value. | ||
-} | ||
|
||
{- $moreresources | ||
If you've worked your way through the documentation here and you're looking for | ||
more examples or tutorials you should check out: | ||
|
||
* <https://haskell-lang.org/library/containers haskell-lang.org's containers tutorial>, its focused on the ordered | ||
<https://hackage.haskell.org/packages/containers containers> library but provides some useful examples. | ||
* <http://learnyouahaskell.com/modules Learn You a Haskell "Modules" chapter> | ||
-} | ||
|
||
{- $installing | ||
==Version Requirements | ||
|
||
All of the examples here should work for all recent versions of the package. | ||
|
||
==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 | ||
@ | ||
|
||
==In GHCi | ||
|
||
Start the GHCi | ||
<https://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop REPL> with | ||
@ghci@, @cabal repl@, or @stack ghci@. Once the REPL is loaded, import the | ||
modules you want using the @import@ statements above and you're good to go! | ||
-} | ||
|
||
|
||
{- $tutorials | ||
|
||
See "Tutorial.HashSet" and "Tutorial.HashMap". | ||
|
||
-} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,93 @@ | ||||||
{-# OPTIONS_GHC -fno-warn-unused-imports #-} | ||||||
|
||||||
{-| | ||||||
Sets allow you to store *unique* elements, providing efficient insertion, | ||||||
lookups, and deletions. If you are storing sets of @Int@ s consider using | ||||||
'Data.IntSet' from the <https://hackage.haskell.org/packages/containers containers> package. You can find the | ||||||
introductory documentation for @containers@ at | ||||||
<https://haskell-containers.readthedocs.io>. | ||||||
|
||||||
@ | ||||||
data 'HashSet' element = ... | ||||||
@ | ||||||
|
||||||
|
||||||
All of these implementations are *immutable* which means that any update | ||||||
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"] | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The easiest way to get qualified names is probably this:
Suggested change
I think this will only work with the full module name though. There are also haddock options for this, but I'm not sure how reliable they are: https://haskell-haddock.readthedocs.io/en/latest/invoking.html#cmdoption-qual There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, that's a little ugly, but it works. |
||||||
let s2 = 'HashSet.delete' "a" s1 | ||||||
print s1 | ||||||
> fromList ["a","b"] | ||||||
print s2 | ||||||
> fromList ["b"] | ||||||
@ | ||||||
|
||||||
__IMPORTANT:__ @HashSet@ relies on the @element@ type having instances of the @Eq@ and | ||||||
@Hashable@ typeclasses for its internal representation. These are already | ||||||
defined for builtin types, and if you are using your own data type you can | ||||||
use the | ||||||
<https://en.wikibooks.org/wiki/Haskell/Classes_and_types#Deriving deriving> | ||||||
mechanism. | ||||||
|
||||||
|
||||||
-} | ||||||
|
||||||
module Tutorial.HashSet ( | ||||||
-- * Short Example | ||||||
-- $shortexample | ||||||
|
||||||
) 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 | ||||||
|
||||||
let dataStructures = 'HashSet.fromList' ["HashSet", "HashMap", "Graph"] | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since this is in a
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||||||
|
||||||
-- Check if "HashMap" and "Trie" are in the set of data structures. | ||||||
'HashSet.member' "HashMap" dataStructures | ||||||
> True | ||||||
|
||||||
'HashSet.member' "Trie" dataStructures | ||||||
> False | ||||||
|
||||||
|
||||||
-- Add "Trie" to our original set of data structures. | ||||||
let moreDataStructures = HashSet.insert "Trie" dataStructures | ||||||
|
||||||
'HashSet.member' "Trie" moreDataStructures | ||||||
> True | ||||||
|
||||||
|
||||||
-- Remove "Graph" from our original set of data structures. | ||||||
let fewerDataStructures = HashSet.delete "Graph" dataStructures | ||||||
|
||||||
'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 | ||||||
> fromList ["Map", "HashSet", "Graph", "HashMap", "Set"] | ||||||
@ | ||||||
|
||||||
|
||||||
__TIP__: You can use the `OverloadedLists | ||||||
<https://ghc.haskell.org/trac/ghc/wiki/OverloadedLists>`_ extension so | ||||||
you don't need to write ``fromList [1, 2, 3]`` everywhere. Instead you | ||||||
can just write ``[1, 2, 3]`` and if the function is expecting a set it | ||||||
will be converted automatically! The code here will continue to use | ||||||
``fromList`` for clarity though. | ||||||
|
||||||
|
||||||
-} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Minimal makefile for Sphinx documentation | ||
# | ||
|
||
# You can set these variables from the command line. | ||
SPHINXOPTS = -a -E | ||
SPHINXBUILD = sphinx-build | ||
SPHINXPROJ = unordered-containers | ||
SOURCEDIR = . | ||
BUILDDIR = _build | ||
|
||
# Put it first so that "make" without argument is like "make help". | ||
help: | ||
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) | ||
|
||
.PHONY: help Makefile | ||
|
||
# Catch-all target: route all unknown targets to Sphinx using the new | ||
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). | ||
%: Makefile | ||
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
def setup(app): | ||
app.add_stylesheet('css/hs-theme.css') |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
.wy-side-nav-search { | ||
background-color: #222 !important; | ||
} | ||
|
||
.wy-nav-top { | ||
background-color: #333 !important; | ||
} | ||
|
||
.wy-nav-top i { | ||
color: #282 !important; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<urlset | ||
xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 | ||
http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"> | ||
|
||
<url> | ||
<loc>https://haskell-unordered-containers.readthedocs.io/en/latest/</loc> | ||
<lastmod>2020-03-24T19:12:16+00:00</lastmod> | ||
<priority>1.00</priority> | ||
</url> | ||
<url> | ||
<loc>https://haskell-unordered-containers.readthedocs.io/en/latest/intro.html</loc> | ||
<lastmod>2020-03-24T19:12:16+00:00</lastmod> | ||
<priority>0.80</priority> | ||
</url> | ||
<url> | ||
<loc>https://haskell-unordered-containers.readthedocs.io/en/latest/hash-set.html</loc> | ||
<lastmod>2020-03-24T19:12:17+00:00</lastmod> | ||
<priority>0.80</priority> | ||
</url> | ||
<url> | ||
<loc>https://haskell-unordered-containers.readthedocs.io/en/latest/hash-map.html</loc> | ||
<lastmod>2020-03-24T19:12:16+00:00</lastmod> | ||
<priority>0.80</priority> | ||
</url> | ||
<url> | ||
<loc>https://haskell-unordered-containers.readthedocs.io/en/stable/</loc> | ||
<lastmod>2020-03-24T18:24:14+00:00</lastmod> | ||
<priority>0.80</priority> | ||
</url> | ||
<url> | ||
<loc>https://haskell-unordered-containers.readthedocs.io/en/latest/index.html</loc> | ||
<lastmod>2020-03-24T19:12:16+00:00</lastmod> | ||
<priority>0.64</priority> | ||
</url> | ||
|
||
</urlset> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{% extends "!layout.html" %} | ||
|
||
{%- block extrahead %} | ||
<meta name="google-site-verification" content="boeOM2WSruQOlY6qXpjFvi9gZglAGs-bgkiDvcsvf4Y" /> | ||
<link rel="shortcut icon" type="image/png" href="_static/images/favicon-green-16x16.png"/> | ||
<meta name="theme-color" content="#222" /> | ||
{% endblock %} |
Uh oh!
There was an error while loading. Please reload this page.