@@ -84,7 +84,7 @@ data Declaration = Declaration
84 , declComments :: Maybe String
84 , declComments :: Maybe String
85 , declSourceSpan :: Maybe P.SourceSpan
85 , declSourceSpan :: Maybe P.SourceSpan
86 , declChildren :: [ChildDeclaration]
86 , declChildren :: [ChildDeclaration]
87− , declFixity :: Maybe (P.Fixity, Maybe String)
87+ , declFixity :: Maybe P.Fixity -- TODO: remove in 0.9
88 , declInfo :: DeclarationInfo
88 , declInfo :: DeclarationInfo
90 deriving (Show, Eq, Ord)
90 deriving (Show, Eq, Ord)
@@ -126,6 +126,12 @@ data DeclarationInfo
126 -- members are represented as child declarations.
126 -- members are represented as child declarations.
128 | TypeClassDeclaration [(String, Maybe P.Kind)] [P.Constraint]
128 | TypeClassDeclaration [(String, Maybe P.Kind)] [P.Constraint]
131+ -- An operator alias declaration, with the member the alias is for and the
132+ -- operator's fixity.
134+ | AliasDeclaration (P.Qualified P.Ident) P.Fixity
129 deriving (Show, Eq, Ord)
135 deriving (Show, Eq, Ord)
131declInfoToString :: DeclarationInfo -> String
137declInfoToString :: DeclarationInfo -> String
@@ -134,6 +140,7 @@ declInfoToString (DataDeclaration _ _) = "data"
134declInfoToString (ExternDataDeclaration _) = "externData"
140declInfoToString (ExternDataDeclaration _) = "externData"
135declInfoToString (TypeSynonymDeclaration _ _) = "typeSynonym"
141declInfoToString (TypeSynonymDeclaration _ _) = "typeSynonym"
136declInfoToString (TypeClassDeclaration _ _) = "typeClass"
142declInfoToString (TypeClassDeclaration _ _) = "typeClass"
143+declInfoToString (AliasDeclaration _ _) = "alias"
138data ChildDeclaration = ChildDeclaration
145data ChildDeclaration = ChildDeclaration
139 { cdeclTitle :: String
146 { cdeclTitle :: String
@@ -307,12 +314,10 @@ asDeclaration =
307 <*> key "fixity" (perhaps asFixity)
314 <*> key "fixity" (perhaps asFixity)
308 <*> key "info" asDeclarationInfo
315 <*> key "info" asDeclarationInfo
310−asFixity :: Parse PackageError (P.Fixity, Maybe String)
317+asFixity :: Parse PackageError P.Fixity
311−asFixity = do
318+asFixity =
312− fixity <- P.Fixity <$> key "associativity" asAssociativity
319+ P.Fixity <$> key "associativity" asAssociativity
313− <*> key "precedence" asIntegral
320+ <*> key "precedence" asIntegral
314− alias <- keyMay "alias" asString
315− return (fixity, alias)
317parseAssociativity :: String -> Maybe P.Associativity
322parseAssociativity :: String -> Maybe P.Associativity
318parseAssociativity str = case str of
323parseAssociativity str = case str of
@@ -341,6 +346,9 @@ asDeclarationInfo = do
341 "typeClass" ->
346 "typeClass" ->
342 TypeClassDeclaration <$> key "arguments" asTypeArguments
347 TypeClassDeclaration <$> key "arguments" asTypeArguments
343 <*> key "superclasses" (eachInArray asConstraint)
348 <*> key "superclasses" (eachInArray asConstraint)
350+ AliasDeclaration <$> key "for" asQualifiedIdent
351+ <*> key "fixity" asFixity
345 throwCustomError (InvalidDeclarationType other)
353 throwCustomError (InvalidDeclarationType other)
@@ -394,6 +402,9 @@ asConstraint = (,) <$> nth 0 asQualifiedProperName
394asQualifiedProperName :: Parse e (P.Qualified P.ProperName)
402asQualifiedProperName :: Parse e (P.Qualified P.ProperName)
395asQualifiedProperName = fromAesonParser
403asQualifiedProperName = fromAesonParser
405+asQualifiedIdent :: Parse e (P.Qualified P.Ident)
406+asQualifiedIdent = fromAesonParser
397asBookmarks :: Parse BowerError [Bookmark]
408asBookmarks :: Parse BowerError [Bookmark]
398asBookmarks = eachInArray asBookmark
409asBookmarks = eachInArray asBookmark
@@ -478,6 +489,7 @@ instance A.ToJSON DeclarationInfo where
478 ExternDataDeclaration kind -> ["kind" .= kind]
489 ExternDataDeclaration kind -> ["kind" .= kind]
479 TypeSynonymDeclaration args ty -> ["arguments" .= args, "type" .= ty]
490 TypeSynonymDeclaration args ty -> ["arguments" .= args, "type" .= ty]
480 TypeClassDeclaration args super -> ["arguments" .= args, "superclasses" .= super]
491 TypeClassDeclaration args super -> ["arguments" .= args, "superclasses" .= super]
492+ AliasDeclaration for fixity -> ["for" .= for, "fixity" .= fixity]
482instance A.ToJSON ChildDeclarationInfo where
494instance A.ToJSON ChildDeclarationInfo where
483 toJSON info = A.object $ "declType" .= childDeclInfoToString info : props
495 toJSON info = A.object $ "declType" .= childDeclInfoToString info : props