Skip to content
This repository was archived by the owner on Apr 1, 2025. It is now read-only.

Commit b10912b

Browse files
authored
Merge branch 'master' into break-hearts-not-builds
2 parents 0408cfc + 8f15669 commit b10912b

File tree

7 files changed

+54
-64
lines changed

7 files changed

+54
-64
lines changed

.ghci

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,9 @@
22
:set -package pretty-show -package hscolour
33

44
-- See docs/💡ProTip!.md
5-
:undef pretty
6-
:def pretty \ _ -> return ":set -interactive-print Semantic.Util.Pretty.prettyShow"
7-
8-
-- See docs/💡ProTip!.md
9-
:undef no-pretty
10-
:def no-pretty \_ -> return ":set -interactive-print System.IO.print"
11-
12-
-- See docs/💡ProTip!.md
13-
:undef r
14-
:def r \_ -> return (unlines [":reload", ":pretty"])
5+
:def! pretty \ _ -> return ":set -interactive-print Semantic.Util.Pretty.prettyShow"
6+
:def! no-pretty \_ -> return ":set -interactive-print System.IO.print"
7+
:def! r \_ -> return (unlines [":reload", ":pretty"])
158

169
-- See docs/💡ProTip!.md for documentation & examples.
1710
:{
@@ -29,8 +22,7 @@ assignmentExample lang = case lang of
2922
_ -> mk "" ""
3023
where mk fileExtension parser = putStrLn ("example: fmap (() <$) . runTask . parse " ++ parser ++ "Parser =<< Semantic.Util.blob \"example." ++ fileExtension ++ "\"") >> return ("import Parsing.Parser\nimport Semantic.Task\nimport Semantic.Util")
3124
:}
32-
:undef assignment
33-
:def assignment assignmentExample
25+
:def! assignment assignmentExample
3426

3527
-- Enable breaking on errors for code written in the repl.
3628
:seti -fbreak-on-error

src/Data/Abstract/Address/Monovariant.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import Data.Abstract.Name
99
import qualified Data.Set as Set
1010
import Prologue
1111

12-
-- | 'Monovariant' models using one address for a particular name. It trackes the set of values that a particular address takes and uses it's name to lookup in the store and only allocation if new.
12+
-- | 'Monovariant' models using one address for a particular name. It tracks the set of values that a particular address takes and uses it's name to lookup in the store and only allocation if new.
1313
newtype Monovariant = Monovariant { unMonovariant :: Name }
1414
deriving (Eq, Ord)
1515

src/Data/Abstract/ScopeGraph.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ instance Ord AccessControl where
7676
(<=) Private _ = True
7777
(<=) _ Private = False
7878

79-
-- | Protected AccessControl is inbetween Private and Public in the order specification.
79+
-- | Protected AccessControl is in between Private and Public in the order specification.
8080
-- Protected AccessControl "on the left" has access to Protected or Public AccessControls "on the right".
8181
(<=) Protected Public = True
8282
(<=) Protected Protected = True

src/Language/Go/Assignment.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,6 +661,6 @@ manyTermsTill step end = manyTill (step <|> comment) end
661661
manyTerm :: Assignment Term -> Assignment [Term]
662662
manyTerm = many . term
663663

664-
-- | Match a term and contextualize any comments preceeding or proceeding the term.
664+
-- | Match a term and contextualize any comments preceding or proceeding the term.
665665
term :: Assignment Term -> Assignment Term
666666
term term' = contextualize comment term' <|> makeTerm1 <$> (Syntax.Context <$> some1 comment <*> emptyTerm)

src/Rendering/Graph.hs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ diffStyle name = (defaultStyle (fromString . show . diffVertexId))
5151
{ graphName = fromString (quote name)
5252
, vertexAttributes = vertexAttributes }
5353
where quote a = "\"" <> a <> "\""
54-
vertexAttributes (DiffTreeVertex _ (Just (Deleted DeletedTerm{..}))) = [ "label" := fromString (T.unpack term), "color" := "red" ]
55-
vertexAttributes (DiffTreeVertex _ (Just (Inserted InsertedTerm{..}))) = [ "label" := fromString (T.unpack term), "color" := "green" ]
56-
vertexAttributes (DiffTreeVertex _ (Just (Replaced ReplacedTerm{..}))) = [ "label" := "Replacement", "color" := "orange", "style" := "dashed" ]
57-
vertexAttributes (DiffTreeVertex _ (Just (Merged MergedTerm{..}))) = [ "label" := fromString (T.unpack term) ]
54+
vertexAttributes (DiffTreeVertex _ (Just (Deleted (Just DeletedTerm{..})))) = [ "label" := fromString (T.unpack term), "color" := "red" ]
55+
vertexAttributes (DiffTreeVertex _ (Just (Inserted (Just InsertedTerm{..})))) = [ "label" := fromString (T.unpack term), "color" := "green" ]
56+
vertexAttributes (DiffTreeVertex _ (Just (Replaced (Just ReplacedTerm{..})))) = [ "label" := "Replacement", "color" := "orange", "style" := "dashed" ]
57+
vertexAttributes (DiffTreeVertex _ (Just (Merged (Just MergedTerm{..})))) = [ "label" := fromString (T.unpack term) ]
5858
vertexAttributes _ = []
5959

6060
class ToTreeGraph vertex t | t -> vertex where
@@ -82,16 +82,16 @@ instance (ConstructorName syntax, Foldable syntax) =>
8282
instance (ConstructorName syntax, Foldable syntax) =>
8383
ToTreeGraph DiffTreeVertex (DiffF syntax Location Location) where
8484
toTreeGraph d = case d of
85-
Merge t@(In (a1, a2) syntax) -> diffAlgebra t (Merged (MergedTerm (T.pack (constructorName syntax)) (ann a1) (ann a2)))
86-
Patch (Delete t1@(In a1 syntax)) -> diffAlgebra t1 (Deleted (DeletedTerm (T.pack (constructorName syntax)) (ann a1)))
87-
Patch (Insert t2@(In a2 syntax)) -> diffAlgebra t2 (Inserted (InsertedTerm (T.pack (constructorName syntax)) (ann a2)))
85+
Merge t@(In (a1, a2) syntax) -> diffAlgebra t (Merged (Just (MergedTerm (T.pack (constructorName syntax)) (ann a1) (ann a2))))
86+
Patch (Delete t1@(In a1 syntax)) -> diffAlgebra t1 (Deleted (Just (DeletedTerm (T.pack (constructorName syntax)) (ann a1))))
87+
Patch (Insert t2@(In a2 syntax)) -> diffAlgebra t2 (Inserted (Just (InsertedTerm (T.pack (constructorName syntax)) (ann a2))))
8888
Patch (Replace t1@(In a1 syntax1) t2@(In a2 syntax2)) -> do
8989
i <- fresh
9090
parent <- ask
9191
let (beforeName, beforeSpan) = (T.pack (constructorName syntax1), ann a1)
9292
let (afterName, afterSpan) = (T.pack (constructorName syntax2), ann a2)
93-
let replace = vertex (DiffTreeVertex (fromIntegral i) (Just (Replaced (ReplacedTerm beforeName beforeSpan afterName afterSpan))))
94-
graph <- local (const replace) (overlay <$> diffAlgebra t1 (Deleted (DeletedTerm beforeName beforeSpan))) <*> diffAlgebra t2 (Inserted (InsertedTerm afterName afterSpan))
93+
let replace = vertex (DiffTreeVertex (fromIntegral i) (Just (Replaced (Just (ReplacedTerm beforeName beforeSpan afterName afterSpan)))))
94+
graph <- local (const replace) (overlay <$> diffAlgebra t1 (Deleted (Just (DeletedTerm beforeName beforeSpan))) <*> diffAlgebra t2 (Inserted (Just (InsertedTerm afterName afterSpan))))
9595
pure (parent `connect` replace `overlay` graph)
9696
where
9797
ann a = converting #? locationSpan a

src/Rendering/TOC.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ newtype DedupeKey = DedupeKey (T.Text, T.Text) deriving (Eq, Ord)
9696
-- different behaviors:
9797
-- 1. Identical entries are in the list.
9898
-- Action: take the first one, drop all subsequent.
99-
-- 2. Two similar entries (defined by a case insensitive comparision of their
99+
-- 2. Two similar entries (defined by a case insensitive comparison of their
100100
-- identifiers) are in the list.
101101
-- Action: Combine them into a single Replaced entry.
102102
dedupe :: [Entry Declaration] -> [Entry Declaration]

src/Semantic/Proto/SemanticPB.hs

Lines changed: 37 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
-- Code generated by protoc-gen-haskell 0.1.0, DO NOT EDIT.
2-
{-# LANGUAGE DerivingVia, DeriveAnyClass, DuplicateRecordFields, PatternSynonyms #-}
2+
{-# LANGUAGE DerivingVia, DeriveAnyClass, DuplicateRecordFields #-}
33
{-# OPTIONS_GHC -Wno-unused-imports -Wno-missing-export-lists #-}
44
module Semantic.Proto.SemanticPB where
55

@@ -746,46 +746,32 @@ instance Proto3.Message DiffTreeEdge where
746746
<*> at decodeMessageField 2
747747
dotProto = undefined
748748

749-
data DiffTreeVertexDiffTerm = DiffTreeVertexDiffTerm
750-
{ deleted :: Maybe DeletedTerm
751-
, inserted :: Maybe InsertedTerm
752-
, replaced :: Maybe ReplacedTerm
753-
, merged :: Maybe MergedTerm
754-
} deriving stock (Eq, Ord, Show, Generic)
755-
deriving anyclass (Proto3.Message, Proto3.Named, NFData)
756-
757-
pattern Deleted :: DeletedTerm -> DiffTreeVertexDiffTerm
758-
pattern Deleted a = DiffTreeVertexDiffTerm (Just a) Nothing Nothing Nothing
759-
760-
pattern Inserted :: InsertedTerm -> DiffTreeVertexDiffTerm
761-
pattern Inserted a = DiffTreeVertexDiffTerm Nothing (Just a) Nothing Nothing
762-
763-
pattern Replaced :: ReplacedTerm -> DiffTreeVertexDiffTerm
764-
pattern Replaced a = DiffTreeVertexDiffTerm Nothing Nothing (Just a) Nothing
765-
766-
pattern Merged :: MergedTerm -> DiffTreeVertexDiffTerm
767-
pattern Merged a = DiffTreeVertexDiffTerm Nothing Nothing Nothing (Just a)
749+
data DiffTreeVertexDiffTerm
750+
= Deleted (Maybe DeletedTerm)
751+
| Inserted (Maybe InsertedTerm)
752+
| Replaced (Maybe ReplacedTerm)
753+
| Merged (Maybe MergedTerm)
754+
deriving stock (Eq, Ord, Show, Generic)
755+
deriving anyclass (Proto3.Message, Proto3.Named, NFData)
768756

769757
instance FromJSONPB DiffTreeVertexDiffTerm where
770-
parseJSONPB = A.withObject "DiffTreeVertexDiffTerm" $ \obj -> DiffTreeVertexDiffTerm
771-
<$> obj .: "deleted"
772-
<*> obj .: "inserted"
773-
<*> obj .: "replaced"
774-
<*> obj .: "merged"
758+
parseJSONPB = A.withObject "DiffTreeVertexDiffTerm" $ \obj -> msum
759+
[
760+
Deleted <$> parseField obj "deleted"
761+
, Inserted <$> parseField obj "inserted"
762+
, Replaced <$> parseField obj "replaced"
763+
, Merged <$> parseField obj "merged"
764+
]
775765

776766
instance ToJSONPB DiffTreeVertexDiffTerm where
777-
toJSONPB DiffTreeVertexDiffTerm{..} = object
778-
[ "deleted" .= deleted
779-
, "inserted" .= inserted
780-
, "replaced" .= replaced
781-
, "merged" .= merged
782-
]
783-
toEncodingPB DiffTreeVertexDiffTerm{..} = pairs
784-
[ "deleted" .= deleted
785-
, "inserted" .= inserted
786-
, "replaced" .= replaced
787-
, "merged" .= merged
788-
]
767+
toJSONPB (Deleted x) = object [ "deleted" .= x ]
768+
toJSONPB (Inserted x) = object [ "inserted" .= x ]
769+
toJSONPB (Replaced x) = object [ "replaced" .= x ]
770+
toJSONPB (Merged x) = object [ "merged" .= x ]
771+
toEncodingPB (Deleted x) = pairs [ "deleted" .= x ]
772+
toEncodingPB (Inserted x) = pairs [ "inserted" .= x ]
773+
toEncodingPB (Replaced x) = pairs [ "replaced" .= x ]
774+
toEncodingPB (Merged x) = pairs [ "merged" .= x ]
789775

790776
instance FromJSON DiffTreeVertexDiffTerm where
791777
parseJSON = parseJSONPB
@@ -828,11 +814,23 @@ instance Proto3.Message DiffTreeVertex where
828814
encodeMessage _ DiffTreeVertex{..} = mconcat
829815
[
830816
encodeMessageField 1 diffVertexId
831-
, encodeMessageField 2 (Proto3.Nested diffTerm)
817+
, case diffTerm of
818+
Nothing -> mempty
819+
Just (Deleted deleted) -> encodeMessageField 2 deleted
820+
Just (Inserted inserted) -> encodeMessageField 3 inserted
821+
Just (Replaced replaced) -> encodeMessageField 4 replaced
822+
Just (Merged merged) -> encodeMessageField 5 merged
832823
]
833824
decodeMessage _ = DiffTreeVertex
834825
<$> at decodeMessageField 1
835-
<*> at decodeMessageField 2
826+
<*> oneof
827+
Nothing
828+
[
829+
(2, Just . Deleted <$> decodeMessageField)
830+
, (3, Just . Inserted <$> decodeMessageField)
831+
, (4, Just . Replaced <$> decodeMessageField)
832+
, (5, Just . Merged <$> decodeMessageField)
833+
]
836834
dotProto = undefined
837835

838836
data DeletedTerm = DeletedTerm

0 commit comments

Comments
 (0)