summaryrefslogtreecommitdiff
path: root/src/Fragment.hs
diff options
context:
space:
mode:
authorGravatar Benjamin Barenblat <bbaren@mit.edu>2015-02-11 20:39:21 -0500
committerGravatar Benjamin Barenblat <bbaren@mit.edu>2015-02-11 20:39:21 -0500
commitb020a5f7783294770b3ead5b969f108733be7711 (patch)
tree49b46658139f6538d7d12f762550022f604208f0 /src/Fragment.hs
parent0c384514d88e58eeac0c62e5ec370ffbdc5ae202 (diff)
Write tangle
Diffstat (limited to 'src/Fragment.hs')
-rw-r--r--src/Fragment.hs16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/Fragment.hs b/src/Fragment.hs
index 4a12d5c..14172da 100644
--- a/src/Fragment.hs
+++ b/src/Fragment.hs
@@ -12,7 +12,11 @@ PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>. -}
+{-# LANGUAGE RecordWildCards #-}
module Fragment ( Fragment
+ , CodeOrReference(..)
+ , isBlockCode
+ , blockName, blockContents
, parseStdin
, parseFile) where
@@ -30,6 +34,18 @@ data Fragment = Documentation String
| BlockCode String [CodeOrReference]
deriving (Eq, Show, Data, Typeable, Generic)
+isBlockCode :: Fragment -> Bool
+isBlockCode (Documentation {..}) = False
+isBlockCode (BlockCode {..}) = True
+
+blockName :: Fragment -> String
+blockName (Documentation {..}) = error "Documentation fragments are unnamed"
+blockName (BlockCode name _) = name
+
+blockContents :: Fragment -> [CodeOrReference]
+blockContents (Documentation {..}) = error "Documentation fragments have no code"
+blockContents (BlockCode _ body) = body
+
data CodeOrReference = Code String
| Reference String
deriving (Eq, Show, Data, Typeable, Generic)