1
1
mirror of https://github.com/github/semantic.git synced 2024-12-01 09:15:01 +03:00

Use Go Assignment

This commit is contained in:
Rick Winfrey 2017-10-24 16:14:35 -07:00
parent 96213206a0
commit 0a6d48174f
2 changed files with 4 additions and 3 deletions

View File

@ -70,7 +70,8 @@ data SomeParser typeclasses where
-- This can be used to perform operations uniformly over terms produced by blobs with different 'Language's, and which therefore have different types in general. For example, given some 'Blob', we can parse and 'show' the parsed & assigned 'Term' like so:
--
-- > case someParser (Proxy :: Proxy '[Show1]) (blobLanguage language) of { Just (SomeParser parser) -> runTask (parse parser blob) >>= putStrLn . show ; _ -> return () }
someParser :: ( ApplyAll typeclasses JSON.Syntax
someParser :: ( ApplyAll typeclasses Go.Syntax
, ApplyAll typeclasses JSON.Syntax
, ApplyAll typeclasses Markdown.Syntax
, ApplyAll typeclasses Python.Syntax
, ApplyAll typeclasses Ruby.Syntax
@ -79,7 +80,7 @@ someParser :: ( ApplyAll typeclasses JSON.Syntax
=> proxy typeclasses -- ^ A proxy for the list of typeclasses required, e.g. @(Proxy :: Proxy '[Show1])@.
-> Language -- ^ The 'Language' to select.
-> Maybe (SomeParser typeclasses) -- ^ 'Maybe' a 'SomeParser' abstracting the syntax type to be produced.
someParser _ Go = Nothing
someParser _ Go = Just (SomeParser goParser)
someParser _ JavaScript = Just (SomeParser typescriptParser)
someParser _ JSON = Just (SomeParser jsonParser)
someParser _ JSX = Just (SomeParser typescriptParser)

View File

@ -77,7 +77,7 @@ diffBlobPairs renderer = fmap toOutput . distributeFoldMap (diffBlobPair rendere
diffBlobPair :: DiffRenderer output -> Both Blob -> Task output
diffBlobPair renderer blobs = case (renderer, effectiveLanguage) of
(OldToCDiffRenderer, lang)
| lang `elem` [ Just Language.Markdown, Just Language.Python, Just Language.Ruby ]
| lang `elem` [ Just Language.Go, Just Language.Markdown, Just Language.Python, Just Language.Ruby ]
, Just (SomeParser parser) <- lang >>= someParser (Proxy :: Proxy '[Diffable, Eq1, Foldable, Functor, GAlign, HasDeclaration, Show1, Traversable]) ->
run (\ blob -> parse parser blob >>= decorate (declarationAlgebra blob)) diffTerms (renderToCDiff blobs)
| Just syntaxParser <- lang >>= syntaxParserForLanguage ->