git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
remove text conversion functions
commit546804b6c5e87643f0fb77c9840aef46be801bae authorChristoph Hegemann <christoph.hegemann1337@gmail.com> dateThu 8 Dec 2016, 08:27 (10 years ago) parent4960ef0
10 files changed+37−50
src/Language/PureScript/Ide.hs+1−1 src/Language/PureScript/Ide/CaseSplit.hs+4−4 src/Language/PureScript/Ide/Conversions.hs+4−16 src/Language/PureScript/Ide/Externs.hs+2−2 src/Language/PureScript/Ide/Rebuild.hs+1−2 src/Language/PureScript/Ide/Reexports.hs+1−1 src/Language/PureScript/Ide/SourceFile.hs+10−10 src/Language/PureScript/Ide/State.hs+1−1 src/Language/PureScript/Ide/Types.hs+3−3 src/Language/PureScript/Ide/Util.hs+10−10
src/Language/PureScript/Ide.hs+1−1
@@ -110,7 +110,7 @@ findPursuitPackages (PursuitQuery q) =
110110 PursuitResult <$> liftIO (findPackagesForModuleIdent q)
111111
112112printModules :: Ide m => m Success
113−printModules = ModuleList . map runModuleNameT <$> getLoadedModulenames
113+printModules = ModuleList . map P.runModuleName <$> getLoadedModulenames
114114
115115outputDirectory :: Ide m => m FilePath
116116outputDirectory = do
src/Language/PureScript/Ide/CaseSplit.hs+4−4
@@ -84,9 +84,9 @@ splitTypeConstructor = go []
8484 go _ _ = throwError (GeneralError "Failed to read TypeConstructor")
8585
8686prettyCtor :: WildcardAnnotations -> Constructor -> Text
87−prettyCtor _ (ctorName, []) = runProperNameT ctorName
87+prettyCtor _ (ctorName, []) = P.runProperName ctorName
8888prettyCtor wsa (ctorName, ctorArgs) =
89− "("<> runProperNameT ctorName <> " "
89+ "("<> P.runProperName ctorName <> " "
9090 <> T.unwords (map (prettyPrintWildcard wsa) ctorArgs) <>")"
9191
9292prettyPrintWildcard :: WildcardAnnotations -> P.Type -> Text
@@ -111,9 +111,9 @@ addClause :: (MonadError PscIdeError m) => Text -> WildcardAnnotations -> m [Tex
111111addClause 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
119119parseType' :: (MonadError PscIdeError m) =>
src/Language/PureScript/Ide/Conversions.hs+4−16
@@ -15,27 +15,15 @@
1515module Language.PureScript.Ide.Conversions where
1616
1717import Control.Lens.Iso
18−import Data.Text (lines, strip, unwords)
18+import Data.Text (lines, strip, unwords, pack)
1919import qualified Language.PureScript as P
2020import Protolude
2121
22−runProperNameT :: P.ProperName a -> Text
23−runProperNameT = toS . P.runProperName
24−
2522properNameT :: 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
3125identT :: 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
4028prettyTypeT :: 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+2−2
@@ -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+1−2
@@ -20,7 +20,6 @@ import Language.PureScript.Errors.JSON
2020import Language.PureScript.Ide.Error
2121import Language.PureScript.Ide.State
2222import Language.PureScript.Ide.Types
23−import Language.PureScript.Ide.Util
2423import 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+1−1
@@ -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
5959reexportHasFailures :: ReexportResult a -> Bool
src/Language/PureScript/Ide/SourceFile.hs+10−10
@@ -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+1−1
@@ -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+3−3
@@ -212,9 +212,9 @@ instance ToJSON ModuleImport where
212212 ] ++ map (\x -> "qualifier" .= x) (maybeToList qualifier)
213213
214214identifierFromDeclarationRef :: 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
218218identifierFromDeclarationRef _ = ""
219219
220220data Success =
src/Language/PureScript/Ide/Util.hs+10−10
@@ -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
5555discardAnn :: IdeDeclarationAnn -> IdeDeclaration
5656discardAnn (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
9494valueOperatorAliasT
9595 :: P.Qualified (Either P.Ident (P.ProperName 'P.ConstructorName)) -> Text
9696valueOperatorAliasT i =
97− toS (P.showQualified (either P.runIdent P.runProperName) i)
97+ P.showQualified (either P.runIdent P.runProperName) i
9898
9999typeOperatorAliasT
100100 :: P.Qualified (P.ProperName 'P.TypeName) -> Text
101101typeOperatorAliasT i =
102− toS (P.showQualified P.runProperName i)
102+ P.showQualified P.runProperName i
103103
104104encodeT :: (ToJSON a) => a -> Text
105105encodeT = toS . decodeUtf8 . encode