Skip to content

Commit 546804b

Browse files
committed
remove text conversion functions
1 parent 4960ef0 commit 546804b

File tree

10 files changed

+37
-50
lines changed

10 files changed

+37
-50
lines changed

src/Language/PureScript/Ide.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ findPursuitPackages (PursuitQuery q) =
110110
PursuitResult <$> liftIO (findPackagesForModuleIdent q)
111111

112112
printModules :: Ide m => m Success
113-
printModules = ModuleList . map runModuleNameT <$> getLoadedModulenames
113+
printModules = ModuleList . map P.runModuleName <$> getLoadedModulenames
114114

115115
outputDirectory :: Ide m => m FilePath
116116
outputDirectory = do

src/Language/PureScript/Ide/CaseSplit.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@ splitTypeConstructor = go []
8484
go _ _ = throwError (GeneralError "Failed to read TypeConstructor")
8585

8686
prettyCtor :: WildcardAnnotations -> Constructor -> Text
87-
prettyCtor _ (ctorName, []) = runProperNameT ctorName
87+
prettyCtor _ (ctorName, []) = P.runProperName ctorName
8888
prettyCtor wsa (ctorName, ctorArgs) =
89-
"("<> runProperNameT ctorName <> " "
89+
"("<> P.runProperName ctorName <> " "
9090
<> T.unwords (map (prettyPrintWildcard wsa) ctorArgs) <>")"
9191

9292
prettyPrintWildcard :: WildcardAnnotations -> P.Type -> Text
@@ -111,9 +111,9 @@ addClause :: (MonadError PscIdeError m) => Text -> WildcardAnnotations -> m [Tex
111111
addClause s wca = do
112112
(fName, fType) <- parseTypeDeclaration' s
113113
let args = splitFunctionType fType
114-
template = runIdentT fName <> " " <>
114+
template = P.runIdent fName <> " " <>
115115
T.unwords (map (prettyPrintWildcard wca) args) <>
116-
" = ?" <> (T.strip . runIdentT $ fName)
116+
" = ?" <> (T.strip . P.runIdent $ fName)
117117
pure [s, template]
118118

119119
parseType' :: (MonadError PscIdeError m) =>

src/Language/PureScript/Ide/Conversions.hs

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,15 @@
1515
module Language.PureScript.Ide.Conversions where
1616

1717
import Control.Lens.Iso
18-
import Data.Text (lines, strip, unwords)
18+
import Data.Text (lines, strip, unwords, pack)
1919
import qualified Language.PureScript as P
2020
import Protolude
2121

22-
runProperNameT :: P.ProperName a -> Text
23-
runProperNameT = toS . P.runProperName
24-
2522
properNameT :: Iso' (P.ProperName a) Text
26-
properNameT = iso (toS . P.runProperName) (P.ProperName . toS)
27-
28-
runIdentT :: P.Ident -> Text
29-
runIdentT = toS . P.runIdent
23+
properNameT = iso P.runProperName P.ProperName
3024

3125
identT :: Iso' P.Ident Text
32-
identT = iso (toS . P.runIdent) (P.Ident . toS)
33-
34-
runOpNameT :: P.OpName a -> Text
35-
runOpNameT = toS . P.runOpName
36-
37-
runModuleNameT :: P.ModuleName -> Text
38-
runModuleNameT = toS . P.runModuleName
26+
identT = iso P.runIdent P.Ident
3927

4028
prettyTypeT :: P.Type -> Text
41-
prettyTypeT = unwords . map strip . lines . toS . P.prettyPrintType
29+
prettyTypeT = unwords . map strip . lines . pack . P.prettyPrintType

src/Language/PureScript/Ide/Externs.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,13 @@ annotateModule (defs, types) (moduleName, decls) =
133133
IdeDeclDataConstructor dtor ->
134134
annotateValue (dtor ^. ideDtorName . properNameT) (IdeDeclDataConstructor dtor)
135135
IdeDeclTypeClass i ->
136-
annotateType (runProperNameT i) (IdeDeclTypeClass i)
136+
annotateType (i ^. properNameT) (IdeDeclTypeClass i)
137137
IdeDeclValueOperator op ->
138138
annotateValue (op ^. ideValueOpAlias & valueOperatorAliasT) (IdeDeclValueOperator op)
139139
IdeDeclTypeOperator op ->
140140
annotateType (op ^. ideTypeOpAlias & typeOperatorAliasT) (IdeDeclTypeOperator op)
141141
where
142-
annotateFunction x = IdeDeclarationAnn (ann { annLocation = Map.lookup (Left (runIdentT x)) defs
142+
annotateFunction x = IdeDeclarationAnn (ann { annLocation = Map.lookup (Left (P.runIdent x)) defs
143143
, annTypeAnnotation = Map.lookup x types
144144
})
145145
annotateValue x = IdeDeclarationAnn (ann {annLocation = Map.lookup (Left x) defs})

src/Language/PureScript/Ide/Rebuild.hs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import Language.PureScript.Errors.JSON
2020
import Language.PureScript.Ide.Error
2121
import Language.PureScript.Ide.State
2222
import Language.PureScript.Ide.Types
23-
import Language.PureScript.Ide.Util
2423
import System.IO.UTF8 (readUTF8FileT)
2524

2625
-- | Given a filepath performs the following steps:
@@ -96,7 +95,7 @@ rebuildModuleOpen makeEnv externs m = do
9695
throwError (GeneralError "Failed when rebuilding with open exports")
9796
Right result -> do
9897
$(logDebug)
99-
("Setting Rebuild cache: " <> runModuleNameT (P.efModuleName result))
98+
("Setting Rebuild cache: " <> P.runModuleName (P.efModuleName result))
10099
cacheRebuild result
101100

102101
-- | Parameters we can access while building our @MakeActions@

src/Language/PureScript/Ide/Reexports.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ prettyPrintReexportResult f ReexportResult{..}
5353
| otherwise =
5454
"Failed to resolve reexports for "
5555
<> f reResolved
56-
<> foldMap (\(mn, ref) -> runModuleNameT mn <> show ref) reFailed
56+
<> foldMap (\(mn, ref) -> P.runModuleName mn <> show ref) reFailed
5757

5858
-- | Whether any Refs couldn't be resolved
5959
reexportHasFailures :: ReexportResult a -> Bool

src/Language/PureScript/Ide/SourceFile.hs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ getImportsForFile fp = do
6060
where
6161
mkModuleImport (mn, importType', qualifier) =
6262
ModuleImport
63-
(runModuleNameT mn)
63+
(P.runModuleName mn)
6464
importType'
65-
(runModuleNameT <$> qualifier)
65+
(P.runModuleName <$> qualifier)
6666
unwrapPositionedImport (mn, it, q) = (mn, unwrapImportType it, q)
6767
unwrapImportType (P.Explicit decls) = P.Explicit (map unwrapPositionedRef decls)
6868
unwrapImportType (P.Hiding decls) = P.Hiding (map unwrapPositionedRef decls)
@@ -101,18 +101,18 @@ extractSpans ss d = case d of
101101
P.PositionedDeclaration ss' _ d' ->
102102
extractSpans ss' d'
103103
P.ValueDeclaration i _ _ _ ->
104-
[(Left (runIdentT i), ss)]
104+
[(Left (P.runIdent i), ss)]
105105
P.TypeSynonymDeclaration name _ _ ->
106-
[(Right (runProperNameT name), ss)]
106+
[(Right (P.runProperName name), ss)]
107107
P.TypeClassDeclaration name _ _ _ members ->
108-
(Right (runProperNameT name), ss) : concatMap (extractSpans' ss) members
108+
(Right (P.runProperName name), ss) : concatMap (extractSpans' ss) members
109109
P.DataDeclaration _ name _ ctors ->
110-
(Right (runProperNameT name), ss)
111-
: map (\(cname, _) -> (Left (runProperNameT cname), ss)) ctors
110+
(Right (P.runProperName name), ss)
111+
: map (\(cname, _) -> (Left (P.runProperName cname), ss)) ctors
112112
P.ExternDeclaration ident _ ->
113-
[(Left (runIdentT ident), ss)]
113+
[(Left (P.runIdent ident), ss)]
114114
P.ExternDataDeclaration name _ ->
115-
[(Right (runProperNameT name), ss)]
115+
[(Right (P.runProperName name), ss)]
116116
_ -> []
117117
where
118118
-- We need this special case to be able to also get the position info for
@@ -123,5 +123,5 @@ extractSpans ss d = case d of
123123
P.PositionedDeclaration ssP' _ dP' ->
124124
extractSpans' ssP' dP'
125125
P.TypeDeclaration ident _ ->
126-
[(Left (runIdentT ident), ssP)]
126+
[(Left (P.runIdent ident), ssP)]
127127
_ -> []

src/Language/PureScript/Ide/State.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ populateStage3 = do
194194
let message duration = "Finished populating Stage3 in " <> displayTimeSpec duration
195195
results <- logPerf message (liftIO (atomically (populateStage3STM st)))
196196
traverse_
197-
(logWarnN . prettyPrintReexportResult (runModuleNameT . fst))
197+
(logWarnN . prettyPrintReexportResult (P.runModuleName . fst))
198198
(filter reexportHasFailures results)
199199

200200
-- | STM version of populateStage3

src/Language/PureScript/Ide/Types.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,9 @@ instance ToJSON ModuleImport where
212212
] ++ map (\x -> "qualifier" .= x) (maybeToList qualifier)
213213

214214
identifierFromDeclarationRef :: P.DeclarationRef -> Text
215-
identifierFromDeclarationRef (P.TypeRef name _) = runProperNameT name
216-
identifierFromDeclarationRef (P.ValueRef ident) = runIdentT ident
217-
identifierFromDeclarationRef (P.TypeClassRef name) = runProperNameT name
215+
identifierFromDeclarationRef (P.TypeRef name _) = P.runProperName name
216+
identifierFromDeclarationRef (P.ValueRef ident) = P.runIdent ident
217+
identifierFromDeclarationRef (P.TypeClassRef name) = P.runProperName name
218218
identifierFromDeclarationRef _ = ""
219219

220220
data Success =

src/Language/PureScript/Ide/Util.hs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ identifierFromIdeDeclaration d = case d of
4848
IdeDeclType t -> t ^. ideTypeName . properNameT
4949
IdeDeclTypeSynonym s -> s ^. ideSynonymName . properNameT
5050
IdeDeclDataConstructor dtor -> dtor ^. ideDtorName . properNameT
51-
IdeDeclTypeClass name -> runProperNameT name
52-
IdeDeclValueOperator op -> op ^. ideValueOpName & runOpNameT
53-
IdeDeclTypeOperator op -> op ^. ideTypeOpName & runOpNameT
51+
IdeDeclTypeClass name -> P.runProperName name
52+
IdeDeclValueOperator op -> op ^. ideValueOpName & P.runOpName
53+
IdeDeclTypeOperator op -> op ^. ideTypeOpName & P.runOpName
5454

5555
discardAnn :: IdeDeclarationAnn -> IdeDeclaration
5656
discardAnn (IdeDeclarationAnn _ d) = d
@@ -70,13 +70,13 @@ completionFromMatch (Match (m, IdeDeclarationAnn ann decl)) =
7070
IdeDeclType t -> (t ^. ideTypeName . properNameT, t ^. ideTypeKind & P.prettyPrintKind & toS )
7171
IdeDeclTypeSynonym s -> (s ^. ideSynonymName . properNameT, s ^. ideSynonymType & prettyTypeT)
7272
IdeDeclDataConstructor d -> (d ^. ideDtorName . properNameT, d ^. ideDtorType & prettyTypeT)
73-
IdeDeclTypeClass name -> (runProperNameT name, "class")
73+
IdeDeclTypeClass name -> (P.runProperName name, "class")
7474
IdeDeclValueOperator (IdeValueOperator op ref precedence associativity typeP) ->
75-
(runOpNameT op, maybe (showFixity precedence associativity (valueOperatorAliasT ref) op) prettyTypeT typeP)
75+
(P.runOpName op, maybe (showFixity precedence associativity (valueOperatorAliasT ref) op) prettyTypeT typeP)
7676
IdeDeclTypeOperator (IdeTypeOperator op ref precedence associativity kind) ->
77-
(runOpNameT op, maybe (showFixity precedence associativity (typeOperatorAliasT ref) op) (toS . P.prettyPrintKind) kind)
77+
(P.runOpName op, maybe (showFixity precedence associativity (typeOperatorAliasT ref) op) (toS . P.prettyPrintKind) kind)
7878

79-
complModule = runModuleNameT m
79+
complModule = P.runModuleName m
8080

8181
complType = maybe complExpandedType prettyTypeT (annTypeAnnotation ann)
8282

@@ -89,17 +89,17 @@ completionFromMatch (Match (m, IdeDeclarationAnn ann decl)) =
8989
P.Infix -> "infix"
9090
P.Infixl -> "infixl"
9191
P.Infixr -> "infixr"
92-
in T.unwords [asso, show p, r, "as", runOpNameT o]
92+
in T.unwords [asso, show p, r, "as", P.runOpName o]
9393

9494
valueOperatorAliasT
9595
:: P.Qualified (Either P.Ident (P.ProperName 'P.ConstructorName)) -> Text
9696
valueOperatorAliasT i =
97-
toS (P.showQualified (either P.runIdent P.runProperName) i)
97+
P.showQualified (either P.runIdent P.runProperName) i
9898

9999
typeOperatorAliasT
100100
:: P.Qualified (P.ProperName 'P.TypeName) -> Text
101101
typeOperatorAliasT i =
102-
toS (P.showQualified P.runProperName i)
102+
P.showQualified P.runProperName i
103103

104104
encodeT :: (ToJSON a) => a -> Text
105105
encodeT = toS . decodeUtf8 . encode

0 commit comments

Comments
 (0)