From f4eb1bbc2be8d61c6b3e2896bbea4d079470a54c Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 11 May 2018 16:58:35 -0400 Subject: [PATCH] Define a helper to abstract over operations on SomeTerm. --- src/Parsing/Parser.hs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Parsing/Parser.hs b/src/Parsing/Parser.hs index 63a8356d9..aad13fb52 100644 --- a/src/Parsing/Parser.hs +++ b/src/Parsing/Parser.hs @@ -3,6 +3,7 @@ module Parsing.Parser ( Parser(..) , SomeParser(..) , SomeTerm(..) +, withSomeTerm , SomeAnalysisParser(..) , SomeASTParser(..) , someParser @@ -155,6 +156,9 @@ markdownParser = AssignmentParser MarkdownParser Markdown.assignment data SomeTerm typeclasses ann where SomeTerm :: ApplyAll typeclasses syntax => Term syntax ann -> SomeTerm typeclasses ann +withSomeTerm :: (forall syntax . ApplyAll typeclasses syntax => Term syntax ann -> a) -> SomeTerm typeclasses ann -> a +withSomeTerm with (SomeTerm term) = with term + -- | A parser for producing specialized (tree-sitter) ASTs. data SomeASTParser where