Skip to content

Commit

Permalink
Add Ord to *DefinitionDiffs
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisPenner committed Nov 19, 2024
1 parent 17cfc91 commit 7f96a4d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 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
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 7f96a4d

Please sign in to comment.