Skip to content

Commit

Permalink
Rename lens scopedIdenName to scopedIdenSrcName
Browse files Browse the repository at this point in the history
scopedIdenSrcName refers to the name of an identifier from the source
code. The name `scopedIdenName` is confusing because users of
`ScopedIden` may think that this lens refers to the only name associated
with ScopedIden, they may want scopedIdenNameFinal instead.
  • Loading branch information
paulcadman committed Feb 23, 2024
1 parent a0ed4c4 commit b41ccfd
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 25 deletions.
4 changes: 2 additions & 2 deletions src/Juvix/Compiler/Concrete/Data/InfoTableBuilder.hs
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ anameFromScopedIden s =
{ _anameLoc = getLoc s,
_anameKind = getNameKind s,
_anameDocId = s ^. scopedIdenFinal . nameId,
_anameDefinedLoc = s ^. scopedIdenName . nameDefined,
_anameVerbatim = s ^. scopedIdenName . nameVerbatim
_anameDefinedLoc = s ^. scopedIdenSrcName . nameDefined,
_anameVerbatim = s ^. scopedIdenSrcName . nameVerbatim
}

lookupInfo :: (Members '[InfoTableBuilder, Reader InfoTable] r) => (InfoTable -> Maybe a) -> Sem r a
Expand Down
4 changes: 2 additions & 2 deletions src/Juvix/Compiler/Concrete/Extra.hs
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,13 @@ recordNameSignatureByIndex = IntMap.fromList . (^.. recordNames . each . to mkAs

getExpressionAtomIden :: ExpressionAtom 'Scoped -> Maybe S.Name
getExpressionAtomIden = \case
AtomIdentifier nm -> Just (nm ^. scopedIdenName)
AtomIdentifier nm -> Just (nm ^. scopedIdenSrcName)
_ -> Nothing

getPatternAtomIden :: PatternAtom 'Scoped -> Maybe S.Name
getPatternAtomIden = \case
PatternAtomIden i -> case i of
PatternScopedConstructor c -> Just (c ^. scopedIdenName)
PatternScopedConstructor c -> Just (c ^. scopedIdenSrcName)
_ -> Nothing
_ -> Nothing

Expand Down
20 changes: 10 additions & 10 deletions src/Juvix/Compiler/Concrete/Language.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2285,10 +2285,10 @@ instance (SingI s) => HasAtomicity (FunctionParameters s) where
SScoped -> atomicity (p ^. paramType)

instance Pretty ScopedIden where
pretty = pretty . (^. scopedIdenName)
pretty = pretty . (^. scopedIdenSrcName)

instance HasLoc ScopedIden where
getLoc = getLoc . (^. scopedIdenName)
getLoc = getLoc . (^. scopedIdenSrcName)

instance (SingI s) => HasLoc (InductiveParameters s) where
getLoc i = getLocSymbolType (i ^. inductiveParametersNames . _head1) <>? (getLocExpressionType <$> (i ^? inductiveParametersRhs . _Just . inductiveParametersType))
Expand Down Expand Up @@ -2668,7 +2668,7 @@ instance IsApe PatternInfixApp ApeLeaf where
{ _infixFixity = getFixity i,
_infixLeft = toApe l,
_infixRight = toApe r,
_infixIsDelimiter = isDelimiterStr (prettyText (op ^. scopedIdenName . S.nameConcrete)),
_infixIsDelimiter = isDelimiterStr (prettyText (op ^. scopedIdenSrcName . S.nameConcrete)),
_infixOp = ApeLeafPattern (PatternConstructor op)
}

Expand Down Expand Up @@ -2732,7 +2732,7 @@ instance IsApe InfixApplication ApeLeaf where
{ _infixFixity = getFixity i,
_infixLeft = toApe l,
_infixRight = toApe r,
_infixIsDelimiter = isDelimiterStr (prettyText (op ^. scopedIdenName . S.nameConcrete)),
_infixIsDelimiter = isDelimiterStr (prettyText (op ^. scopedIdenSrcName . S.nameConcrete)),
_infixOp = ApeLeafExpression (ExpressionIdentifier op)
}

Expand Down Expand Up @@ -2856,8 +2856,8 @@ _RecordStatementField f x = case x of
RecordStatementField p -> RecordStatementField <$> f p
_ -> pure x

scopedIdenName :: Lens' ScopedIden S.Name
scopedIdenName f n = case n ^. scopedIdenAlias of
scopedIdenSrcName :: Lens' ScopedIden S.Name
scopedIdenSrcName f n = case n ^. scopedIdenAlias of
Nothing -> scopedIdenFinal f n
Just a -> do
a' <- f a
Expand All @@ -2871,16 +2871,16 @@ fromParsedIteratorInfo ParsedIteratorInfo {..} =
}

instance HasFixity PostfixApplication where
getFixity (PostfixApplication _ op) = fromMaybe impossible (op ^. scopedIdenName . S.nameFixity)
getFixity (PostfixApplication _ op) = fromMaybe impossible (op ^. scopedIdenSrcName . S.nameFixity)

instance HasFixity InfixApplication where
getFixity (InfixApplication _ op _) = fromMaybe impossible (op ^. scopedIdenName . S.nameFixity)
getFixity (InfixApplication _ op _) = fromMaybe impossible (op ^. scopedIdenSrcName . S.nameFixity)

instance HasFixity PatternInfixApp where
getFixity (PatternInfixApp _ op _) = fromMaybe impossible (op ^. scopedIdenName . S.nameFixity)
getFixity (PatternInfixApp _ op _) = fromMaybe impossible (op ^. scopedIdenSrcName . S.nameFixity)

instance HasFixity PatternPostfixApp where
getFixity (PatternPostfixApp _ op) = fromMaybe impossible (op ^. scopedIdenName . S.nameFixity)
getFixity (PatternPostfixApp _ op) = fromMaybe impossible (op ^. scopedIdenSrcName . S.nameFixity)

instance HasAtomicity (ListPattern s) where
atomicity = const Atom
Expand Down
2 changes: 1 addition & 1 deletion src/Juvix/Compiler/Concrete/Print/Base.hs
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ instance PrettyPrint ScopedModule where
ppCode m = ppCode (m ^. scopedModuleName)

instance PrettyPrint ScopedIden where
ppCode = ppCode . (^. scopedIdenName)
ppCode = ppCode . (^. scopedIdenSrcName)

instance (SingI s) => PrettyPrint (AliasDef s) where
ppCode AliasDef {..} =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1820,7 +1820,7 @@ checkRecordPattern ::
Sem r (RecordPattern 'Scoped)
checkRecordPattern r = do
c' <- getNameOfKind KNameConstructor (r ^. recordPatternConstructor)
fields <- fromMaybeM (return (RecordNameSignature mempty)) (gets (^. scoperConstructorFields . at (c' ^. scopedIdenName . S.nameId)))
fields <- fromMaybeM (return (RecordNameSignature mempty)) (gets (^. scoperConstructorFields . at (c' ^. scopedIdenFinal . S.nameId)))
l' <-
if
| null (r ^. recordPatternItems) -> return []
Expand Down Expand Up @@ -2339,7 +2339,7 @@ checkIterator ::
Sem r (Iterator 'Scoped)
checkIterator iter = do
_iteratorName <- checkScopedIden (iter ^. iteratorName)
case _iteratorName ^. scopedIdenName . S.nameIterator of
case _iteratorName ^. scopedIdenFinal . S.nameIterator of
Just IteratorInfo {..} -> do
case _iteratorInfoInitNum of
Just n
Expand Down Expand Up @@ -2422,7 +2422,7 @@ checkParens e@(ExpressionAtoms as _) = case as of
p :| [] -> case p of
AtomIdentifier s -> do
scopedId <- checkScopedIden s
let scopedIdenNoFix = over scopedIdenName (set S.nameFixity Nothing) scopedId
let scopedIdenNoFix = over scopedIdenSrcName (set S.nameFixity Nothing) scopedId
return (ExpressionParensIdentifier scopedIdenNoFix)
AtomIterator i -> ExpressionIterator . set iteratorParens True <$> checkIterator i
AtomCase c -> ExpressionCase . set caseParens True <$> checkCase c
Expand Down Expand Up @@ -2617,15 +2617,15 @@ makeExpressionTable (ExpressionAtoms atoms _) = [recordUpdate] : [appOpExplicit]
OpNone -> Nothing
| otherwise = Nothing
where
S.Name' {..} = iden ^. scopedIdenName
S.Name' {..} = iden ^. scopedIdenSrcName

parseSymbolId :: S.NameId -> Parse ScopedIden
parseSymbolId uid = P.token getIdentifierWithId mempty
where
getIdentifierWithId :: ExpressionAtom 'Scoped -> Maybe ScopedIden
getIdentifierWithId s = case s of
AtomIdentifier iden
| uid == iden ^. scopedIdenName . S.nameId -> Just iden
| uid == iden ^. scopedIdenSrcName . S.nameId -> Just iden
_ -> Nothing

recordUpdate :: P.Operator Parse Expression
Expand Down Expand Up @@ -2843,7 +2843,7 @@ parseTerm =
identifierNoFixity :: ExpressionAtom 'Scoped -> Maybe ScopedIden
identifierNoFixity s = case s of
AtomIdentifier iden
| not (S.hasFixity (iden ^. scopedIdenName)) -> Just iden
| not (S.hasFixity (iden ^. scopedIdenSrcName)) -> Just iden
_ -> Nothing

parseDoubleBraces :: Parse Expression
Expand Down Expand Up @@ -2892,8 +2892,8 @@ makePatternTable (PatternAtoms latoms _) = [appOp] : operators
where
unqualifiedSymbolOp :: ScopedIden -> Maybe (Precedence, P.Operator ParsePat PatternArg)
unqualifiedSymbolOp constr = run . runFail $ do
Fixity {..} <- failMaybe (constr ^. scopedIdenName . S.nameFixity)
let _nameId = constr ^. scopedIdenName . S.nameId
Fixity {..} <- failMaybe (constr ^. scopedIdenSrcName . S.nameFixity)
let _nameId = constr ^. scopedIdenSrcName . S.nameId
case _fixityArity of
OpUnary u -> return (_fixityPrecedence, P.Postfix (unaryApp <$> parseSymbolId _nameId))
where
Expand All @@ -2916,7 +2916,7 @@ makePatternTable (PatternAtoms latoms _) = [appOp] : operators
getConstructorRefWithId :: PatternAtom 'Scoped -> Maybe ScopedIden
getConstructorRefWithId s = do
ref <- getConstructorRef s
guard (ref ^. scopedIdenName . S.nameId == uid)
guard (ref ^. scopedIdenSrcName . S.nameId == uid)
return ref

-- Application by juxtaposition.
Expand Down Expand Up @@ -2965,7 +2965,7 @@ parsePatternTerm = do
constructorNoFixity :: PatternAtom 'Scoped -> Maybe ScopedIden
constructorNoFixity s = case s of
PatternAtomIden (PatternScopedConstructor ref)
| not (S.hasFixity (n ^. scopedIdenName)) -> Just ref
| not (S.hasFixity (n ^. scopedIdenSrcName)) -> Just ref
where
n = ref
_ -> Nothing
Expand Down

0 comments on commit b41ccfd

Please sign in to comment.