Skip to content

Commit 808e692

Browse files
committed
Add haddock
1 parent a652b39 commit 808e692

File tree

4 files changed

+54
-18
lines changed

4 files changed

+54
-18
lines changed

src/Lsystem/Generator.hs

+12-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
{-|
2+
Module : Lsystem.Generator
3+
Description : Generate the L-system
4+
Copyright : (c) Zebulun Arendsee, 2018
5+
License : MIT
6+
Maintainer : [email protected]
7+
Stability : experimental
8+
-}
9+
110
module Lsystem.Generator
211
(
312
step
@@ -40,9 +49,9 @@ applyRules g lc rc rs n = fromMaybe [n] . firstSuccess (applyRule p) $ rs
4049
applyRule :: Chance -> Rule -> Maybe [Node]
4150
applyRule _ (DeterministicRule cont cond match repl) =
4251
return (repl lc rc n) -- replace node if:
43-
>>= match n -- * the node is of the correct form
44-
>>= cont lc rc -- * it is in the required context
45-
>>= cond lc rc n -- * all parametric restrictions are met
52+
>>= match n -- the node is of the correct form
53+
>>= cont lc rc -- it is in the required context
54+
>>= cond lc rc n -- all parametric restrictions are met
4655
applyRule p (StochasticRule rs') = case (choose p rs') of
4756
-- p is rescaled by dividing by the selected rule's probability
4857
Just (cp', r) -> applyRule (p / cp') r

src/Lsystem/Grammar.hs

+15-6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
{-|
2+
Module : Lsystem.Grammar
3+
Description : Core types
4+
Copyright : (c) Zebulun Arendsee, 2018
5+
License : MIT
6+
Maintainer : [email protected]
7+
Stability : experimental
8+
-}
9+
110
module Lsystem.Grammar
211
(
312
System(..)
@@ -13,17 +22,17 @@ module Lsystem.Grammar
1322
, Chance
1423
) where
1524

16-
-- context-sensitive stochastic parameterized L-systems
25+
--
1726

18-
type Distance = Double -- x > 0
19-
type Yaw = Double -- -180 < x < 180
20-
type Pitch = Double -- -180 < x < 180
21-
type Roll = Double -- -180 < x < 180
27+
type Distance = Double -- ^ x > 0
28+
type Yaw = Double -- ^ -180 < x < 180
29+
type Pitch = Double -- ^ -180 < x < 180
30+
type Roll = Double -- ^ -180 < x < 180
2231

2332
type LeftContext = [Node]
2433
type RightContext = [Node]
2534

26-
type Chance = Double -- 0 <= x <= 1
35+
type Chance = Double -- ^ 0 <= x <= 1
2736

2837
data System = System {
2938
systemBasis :: [Node]

src/Lsystem/Render.hs

+9
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22
{-# LANGUAGE FlexibleContexts #-}
33
{-# LANGUAGE TypeFamilies #-}
44

5+
{-|
6+
Module : Lsystem.Render
7+
Description : Render a generated L-system
8+
Copyright : (c) Zebulun Arendsee, 2018
9+
License : MIT
10+
Maintainer : [email protected]
11+
Stability : experimental
12+
-}
13+
514
module Lsystem.Render
615
(
716
renderSystem

src/Lsystem/Sugar.hs

+18-9
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
{-|
2+
Module : Lsystem.Sugar
3+
Description : Functions for simplifying L-system specification
4+
Copyright : (c) Zebulun Arendsee, 2018
5+
License : MIT
6+
Maintainer : [email protected]
7+
Stability : experimental
8+
-}
9+
110
module Lsystem.Sugar
211
(
312
transDol
@@ -68,11 +77,11 @@ matchWidth _ _ = Nothing
6877
unconditional :: LeftContext -> RightContext -> Node -> a -> Maybe a
6978
unconditional _ _ _ x = Just x
7079

71-
-- Check is A is a similar to B. For branches, A must be a subtree of B.
80+
-- | Check is A is a similar to B. For branches, A must be a subtree of B.
7281
similar
73-
:: Node -- A
74-
-> Node -- B
75-
-> Bool -- True is A is in B (where `in` is weirdly defined ...)
82+
:: Node -- ^ A
83+
-> Node -- ^ B
84+
-> Bool -- ^ True if A is in B (where `in` is weirdly defined ...)
7685
similar (NodeDummy _ s) (NodeDummy _ t) = s == t
7786
similar (NodeDraw _ _ ) (NodeDraw _ _) = True
7887
similar (NodeRotate _ _ _ _) (NodeRotate _ _ _ _) = True
@@ -92,11 +101,11 @@ similar (NodeBranch mss) (NodeBranch nss) = any id $ map (anyBranch nss) mss
92101
similar _ _ = False
93102

94103
contextMatch
95-
:: [Node] -- elements to ignore
96-
-> [Node] -- left contextual pattern
97-
-> [Node] -- right contextual pattern
98-
-> [Node] -- left context
99-
-> [Node] -- right context
104+
:: [Node] -- ^ elements to ignore
105+
-> [Node] -- ^ left contextual pattern
106+
-> [Node] -- ^ right contextual pattern
107+
-> [Node] -- ^ left context
108+
-> [Node] -- ^ right context
100109
-> a -> Maybe a -- combinator kludge (I really should go to Bool)
101110
contextMatch ss lpat rpat lc rc x =
102111
return x

0 commit comments

Comments
 (0)