From 4d810c347c1b6a4d7ef8bd5d48b82c8c7e5fe561 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Thu, 5 Oct 2017 12:25:36 -0400 Subject: [PATCH] Define an algebra using toDeclaration. --- src/Renderer/TOC.hs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Renderer/TOC.hs b/src/Renderer/TOC.hs index e3b7f2177..6bc37c1a1 100644 --- a/src/Renderer/TOC.hs +++ b/src/Renderer/TOC.hs @@ -10,6 +10,7 @@ module Renderer.TOC , declaration , declarationAlgebra , markupSectionAlgebra +, toDeclarationAlgebra , syntaxDeclarationAlgebra , Entry(..) , tableOfContentsBy @@ -95,6 +96,10 @@ data Declaration class HasDeclaration whole part where toDeclaration :: (HasField fields Range, HasField fields Span) => Blob -> Record fields -> RAlgebra part (Term whole (Record fields)) (Maybe Declaration) +toDeclarationAlgebra :: (HasField fields Range, HasField fields Span, HasDeclaration syntax syntax) => Blob -> RAlgebra (TermF syntax (Record fields)) (Term syntax (Record fields)) (Maybe Declaration) +toDeclarationAlgebra blob (In ann syntax) = toDeclaration blob ann syntax + + instance (DeclarationStrategy part ~ strategy, HasDeclarationWithStrategy strategy whole part) => HasDeclaration whole part where toDeclaration = toDeclarationWithStrategy (undefined :: proxy strategy)