Skip to content

Commit

Permalink
Merge branch 'cp/batched-diffs' into syncv2/experiments
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisPenner committed Dec 13, 2024
2 parents e5c175b + 40eac6a commit a4f1bba
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 24 deletions.
5 changes: 2 additions & 3 deletions lib/unison-pretty-printer/src/Unison/Util/AnnotatedText.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ import Unison.Util.Monoid (intercalateMap)
import Unison.Util.Range (Range (..), inRange)

data Segment a = Segment {segment :: String, annotation :: Maybe a}
deriving (Eq, Show, Functor, Foldable, Generic)
deriving (Eq, Show, Ord, Functor, Foldable, Generic)

toPair :: Segment a -> (String, Maybe a)
toPair (Segment s a) = (s, a)

newtype AnnotatedText a = AnnotatedText (Seq (Segment a))
deriving (Eq, Functor, Foldable, Show, Generic)
deriving (Eq, Functor, Foldable, Show, Ord, Generic)

instance Semigroup (AnnotatedText a) where
AnnotatedText (as :|> Segment "" _) <> bs = AnnotatedText as <> bs
Expand Down Expand Up @@ -204,7 +204,6 @@ snipWithContext margin source =
-- if all annotations so far can be joined without .. separations
if null rest
then -- if this one can be joined to the new region without .. separation

if withinMargin r0 r1
then -- add it to the first set and grow the compare region
(Just $ r0 <> r1, Map.insert r1 a1 taken, mempty)
Expand Down
20 changes: 10 additions & 10 deletions unison-share-api/src/Unison/Server/Doc.hs
Original file line number Diff line number Diff line change
Expand Up @@ -90,21 +90,21 @@ data DocG specialForm
| UntitledSection [(DocG specialForm)]
| Column [(DocG specialForm)]
| Group (DocG specialForm)
deriving stock (Eq, Show, Generic, Functor, Foldable, Traversable)
deriving stock (Eq, Ord, Show, Generic, Functor, Foldable, Traversable)
deriving anyclass (ToJSON)

deriving instance (ToSchema specialForm) => ToSchema (DocG specialForm)

type UnisonHash = Text

data Ref a = Term a | Type a
deriving stock (Eq, Show, Generic, Functor, Foldable, Traversable)
deriving stock (Eq, Ord, Show, Generic, Functor, Foldable, Traversable)
deriving anyclass (ToJSON)

instance (ToSchema a) => ToSchema (Ref a)

data MediaSource = MediaSource {mediaSourceUrl :: Text, mediaSourceMimeType :: Maybe Text}
deriving stock (Eq, Show, Generic)
deriving stock (Eq, Ord, Show, Generic)
deriving anyclass (ToJSON, ToSchema)

data RenderedSpecialForm
Expand All @@ -124,7 +124,7 @@ data RenderedSpecialForm
| LaTeXInline Text
| Svg Text
| RenderError (RenderError SyntaxText)
deriving stock (Eq, Show, Generic)
deriving stock (Eq, Ord, Show, Generic)
deriving anyclass (ToJSON, ToSchema)

data EvaluatedSpecialForm v
Expand All @@ -146,11 +146,11 @@ data EvaluatedSpecialForm v
| ELaTeXInline Text
| ESvg Text
| ERenderError (RenderError (Term v ()))
deriving stock (Eq, Show, Generic)
deriving stock (Eq, Ord, Show, Generic)

-- `Src folded unfolded`
data Src = Src SyntaxText SyntaxText
deriving stock (Eq, Show, Generic)
deriving stock (Eq, Ord, Show, Generic)
deriving anyclass (ToJSON, ToSchema)

-- | Evaluate the doc, then render it.
Expand Down Expand Up @@ -447,28 +447,28 @@ evalDoc terms typeOf eval types tm =

data RenderError trm
= InvalidTerm trm
deriving stock (Eq, Show, Generic)
deriving stock (Eq, Ord, Show, Generic)
deriving anyclass (ToJSON)

deriving anyclass instance (ToSchema trm) => ToSchema (RenderError trm)

data EvaluatedSrc v
= EvaluatedSrcDecl (EvaluatedDecl v)
| EvaluatedSrcTerm (EvaluatedTerm v)
deriving stock (Show, Eq, Generic)
deriving stock (Show, Ord, Eq, Generic)

data EvaluatedDecl v
= MissingDecl Reference
| BuiltinDecl Reference
| FoundDecl Reference (DD.Decl v ())
deriving stock (Show, Eq, Generic)
deriving stock (Show, Ord, Eq, Generic)

data EvaluatedTerm v
= MissingTerm Reference
| BuiltinTypeSig Reference (Type v ())
| MissingBuiltinTypeSig Reference
| FoundTerm Reference (Type v ()) (Term v ())
deriving stock (Show, Eq, Generic)
deriving stock (Show, Eq, Ord, Generic)

-- Determines all dependencies which will be required to render a doc.
dependencies :: (Ord v) => EvaluatedDoc v -> Set LD.LabeledDependency
Expand Down
22 changes: 11 additions & 11 deletions unison-share-api/src/Unison/Server/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -198,14 +198,14 @@ data TermDefinitionDiff = TermDefinitionDiff
right :: TermDefinition,
diff :: DisplayObjectDiff
}
deriving (Eq, Show, Generic)
deriving (Eq, Ord, Show, Generic)

data TypeDefinitionDiff = TypeDefinitionDiff
{ left :: TypeDefinition,
right :: TypeDefinition,
diff :: DisplayObjectDiff
}
deriving (Eq, Show, Generic)
deriving (Eq, Ord, Show, Generic)

newtype Suffixify = Suffixify {suffixified :: Bool}
deriving (Eq, Ord, Show, Generic)
Expand All @@ -218,7 +218,7 @@ data TermDefinition = TermDefinition
signature :: Syntax.SyntaxText,
termDocs :: [(HashQualifiedName, UnisonHash, Doc)]
}
deriving (Eq, Show, Generic)
deriving (Eq, Show, Ord, Generic)

data TypeDefinition = TypeDefinition
{ typeNames :: [HashQualifiedName],
Expand All @@ -227,14 +227,14 @@ data TypeDefinition = TypeDefinition
typeDefinition :: DisplayObject Syntax.SyntaxText Syntax.SyntaxText,
typeDocs :: [(HashQualifiedName, UnisonHash, Doc)]
}
deriving (Eq, Show, Generic)
deriving (Eq, Show, Ord, Generic)

data DefinitionDisplayResults = DefinitionDisplayResults
{ termDefinitions :: Map UnisonHash TermDefinition,
typeDefinitions :: Map UnisonHash TypeDefinition,
missingDefinitions :: [HashQualifiedName]
}
deriving (Eq, Show, Generic)
deriving (Eq, Show, Ord, Generic)

instance Semigroup DefinitionDisplayResults where
DefinitionDisplayResults terms1 types1 missing1 <> DefinitionDisplayResults terms2 types2 missing2 =
Expand All @@ -260,7 +260,7 @@ data SemanticSyntaxDiff
SegmentChange (String, String) (Maybe Syntax.Element)
| -- (shared segment) (fromAnnotation, toAnnotation)
AnnotationChange String (Maybe Syntax.Element, Maybe Syntax.Element)
deriving (Eq, Show, Generic)
deriving (Eq, Show, Ord, Generic)

deriving instance ToSchema SemanticSyntaxDiff

Expand Down Expand Up @@ -303,7 +303,7 @@ instance ToJSON SemanticSyntaxDiff where
data DisplayObjectDiff
= DisplayObjectDiff (DisplayObject [SemanticSyntaxDiff] [SemanticSyntaxDiff])
| MismatchedDisplayObjects (DisplayObject Syntax.SyntaxText Syntax.SyntaxText) (DisplayObject Syntax.SyntaxText Syntax.SyntaxText)
deriving stock (Show, Eq, Generic)
deriving stock (Show, Eq, Ord, Generic)

deriving instance ToSchema DisplayObjectDiff

Expand All @@ -324,7 +324,7 @@ data NamedTerm = NamedTerm
termType :: Maybe Syntax.SyntaxText,
termTag :: TermTag
}
deriving (Eq, Generic, Show)
deriving (Eq, Ord, Generic, Show)

instance ToJSON NamedTerm where
toJSON (NamedTerm n h typ tag) =
Expand All @@ -350,7 +350,7 @@ data NamedType = NamedType
typeHash :: ShortHash,
typeTag :: TypeTag
}
deriving (Eq, Generic, Show)
deriving (Eq, Ord, Generic, Show)

instance ToJSON NamedType where
toJSON (NamedType n h tag) =
Expand Down Expand Up @@ -474,7 +474,7 @@ data TermDiffResponse = TermDiffResponse
newTerm :: TermDefinition,
diff :: DisplayObjectDiff
}
deriving (Eq, Show, Generic)
deriving (Eq, Ord, Show, Generic)

deriving instance ToSchema TermDiffResponse

Expand Down Expand Up @@ -512,7 +512,7 @@ data TypeDiffResponse = TypeDiffResponse
newType :: TypeDefinition,
diff :: DisplayObjectDiff
}
deriving (Eq, Show, Generic)
deriving (Eq, Ord, Show, Generic)

deriving instance ToSchema TypeDiffResponse

Expand Down

0 comments on commit a4f1bba

Please sign in to comment.