| Copyright | Copyright (c) 2015, Peter Harpending. |
|---|---|
| License | GPL-3 |
| Maintainer | Peter Harpending <peter@harpending.org> |
| Stability | experimental |
| Portability | UNIX/GHC |
| Safe Haskell | Safe |
| Language | Haskell2010 |
Development.Louse
Contents
Description
This is the top-level module for the louse library. You only need to import this module, everything else will automatically be re-exported.
Since: 0.1.0.0
- module Control.Exceptional
- data Bug = Bug {}
- data Title
- mkTitle :: Text -> Exceptional Title
- unTitle :: Title -> Text
- data Description
- mkDescription :: Text -> Exceptional Description
- unDescription :: Description -> Text
- data Person = Person {
- personName :: Text
- personEmail :: Text
- type Author = Person
- type Reporter = Person
- data Comment = Comment {}
- type CommentText = Description
- mkCommentText :: Text -> Exceptional CommentText
- unCommentText :: CommentText -> Text
- data CommentTree
- unCommentTree :: CommentTree -> HashMap ByteString Comment
- class ToBug a where
- class FromBug a where
- class ToTree foo bar where
- class FromTree bar foo where
- class ToForest foo bar where
- class FromForest bar foo where
- fromForest :: Forest bar -> foo
Convenience re-exports
module Control.Exceptional
Creating pure-ish bugs
The type for a bug
Since: 0.1.0.0
Constructors
| Bug | |
Fields
| |
Bug titles
A newtype over Text. Haskell doesn't have dependent types, so I
have to use a hack called "smart constructors" to make sure
0 < title_length <= 64
Use mkTitle to make a title. Alternatively, you could turn on
OverloadedStrings, and use Title's IsString instance:
>>>:set -XOverloadedStrings>>>"hello" :: TitleTitle {unTitle = "hello"} it :: Title
Note that if you give invalid input, then there will be an error:
>>>"" :: Title*** Exception: Title mustn't be empty.>>>fromString (mconcat (replicate 50 "foo")) :: Title*** Exception: Title mustn't be >64 characters long.
Since: 0.1.0.0
mkTitle :: Text -> Exceptional Title Source
Attempt to make a title, returning an error message if the length is longer than 64 characters, or if the title is empty.
Since: 0.1.0.0
Bug descriptions
data Description Source
Yet another newtype over Text. This is to make sure the
description is less than (or equal to) 8192 characters.
Use mkDescription to make a description. This is an instance of
IsString, too, so, in pure code, you can just write plain strings,
and turn on the OverloadedStrings extension.
>>>:set -XOverloadedStrings>>>"hello" :: DescriptionDescription {unDescription = "hello"} it :: Description
If you give invalid input, then there will be an error:
>>>"" :: Description*** Exception: Description mustn't be empty.
Since: 0.1.0.0
Instances
| Eq Description Source | |
| Ord Description Source | Compares by the value of Since: 0.1.0.0 |
| Show Description Source | Since: 0.1.0.0 |
| IsString Description Source | Note that this will throw an error if given invalid input. Since: 0.1.0.0 |
| ToForest CommentTree (Author, CommentText) Source | Since: 0.1.0.0 |
mkDescription :: Text -> Exceptional Description Source
Attempt to make a description from a pure Text value. This returns
an error if the description is empty.
Since: 0.1.0.0
unDescription :: Description -> Text Source
People
Type for a person. Just has email and name
Since: 0.1.0.0
Constructors
| Person | |
Fields
| |
Comments
The type for a comment
Since: 0.1.0.0
Constructors
| Comment | |
Fields | |
Comment text
type CommentText = Description Source
Comment text has the same requirements as a Description, so alias
the two
Since: 0.1.0.0
mkCommentText :: Text -> Exceptional CommentText Source
Alias for mkDescription
Since: 0.1.0.0
unCommentText :: CommentText -> Text Source
Alias for unDescription
Since: 0.1.0.0
Comment trees
data CommentTree Source
This is similar to a Tree from containers, except it's implemented
using lazy HashMaps.
Specifically, this is a newtype over HashMap ByteString Comment. The idea being that the key
Since: 0.1.0.0
Instances
| Eq CommentTree Source | |
| Show CommentTree Source | |
| ToForest CommentTree (Author, CommentText) Source | Since: 0.1.0.0 |
Converting to & from bugs
Typeclass to convert something to a Bug
Convert something from a Bug
Since: 0.1.0.0
Converting to & from trees
class FromTree bar foo where Source
Convert a Tree of type bars to something of type foo.
Since: 0.1.0.0
Forests are just lists of trees
class ToForest foo bar where Source
Convert something of type foo to a Forest of bars.
Since: 0.1.0.0
Instances
| ToForest CommentTree (Author, CommentText) Source | Since: 0.1.0.0 |
| (ToTree foo bar, Foldable t) => ToForest (t foo) bar Source | Since: 0.1.0.0 |
class FromForest bar foo where Source
Convert a Forest of type bar to something of type foo.
Since: 0.1.0.0
Methods
fromForest :: Forest bar -> foo Source
Instances
| FromTree bar foo => FromForest bar [foo] Source | Since: 0.1.0.0 |