git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
remove text conversion functions
546804bChristoph Hegemann
src/Language/PureScript/Ide.hs+1−1
@@ -110,7 +110,7 @@ findPursuitPackages (PursuitQuery q) =
110 PursuitResult <$> liftIO (findPackagesForModuleIdent q)
110 PursuitResult <$> liftIO (findPackagesForModuleIdent q)
111
111
112printModules :: Ide m => m Success
112printModules :: Ide m => m Success
113−printModules = ModuleList . map runModuleNameT <$> getLoadedModulenames
113+printModules = ModuleList . map P.runModuleName <$> getLoadedModulenames
114
114
115outputDirectory :: Ide m => m FilePath
115outputDirectory :: Ide m => m FilePath
116outputDirectory = do
116outputDirectory = do
src/Language/PureScript/Ide/CaseSplit.hs+4−4
@@ -84,9 +84,9 @@ splitTypeConstructor = go []
84 go _ _ = throwError (GeneralError "Failed to read TypeConstructor")
84 go _ _ = throwError (GeneralError "Failed to read TypeConstructor")
85
85
86prettyCtor :: WildcardAnnotations -> Constructor -> Text
86prettyCtor :: WildcardAnnotations -> Constructor -> Text
87−prettyCtor _ (ctorName, []) = runProperNameT ctorName
87+prettyCtor _ (ctorName, []) = P.runProperName ctorName
88prettyCtor wsa (ctorName, ctorArgs) =
88prettyCtor wsa (ctorName, ctorArgs) =
89− "("<> runProperNameT ctorName <> " "
89+ "("<> P.runProperName ctorName <> " "
90 <> T.unwords (map (prettyPrintWildcard wsa) ctorArgs) <>")"
90 <> T.unwords (map (prettyPrintWildcard wsa) ctorArgs) <>")"
91
91
92prettyPrintWildcard :: WildcardAnnotations -> P.Type -> Text
92prettyPrintWildcard :: WildcardAnnotations -> P.Type -> Text
@@ -111,9 +111,9 @@ addClause :: (MonadError PscIdeError m) => Text -> WildcardAnnotations -> m [Tex
111addClause s wca = do
111addClause s wca = do
112 (fName, fType) <- parseTypeDeclaration' s
112 (fName, fType) <- parseTypeDeclaration' s
113 let args = splitFunctionType fType
113 let args = splitFunctionType fType
114− template = runIdentT fName <> " " <>
114+ template = P.runIdent fName <> " " <>
115 T.unwords (map (prettyPrintWildcard wca) args) <>
115 T.unwords (map (prettyPrintWildcard wca) args) <>
116− " = ?" <> (T.strip . runIdentT $ fName)
116+ " = ?" <> (T.strip . P.runIdent $ fName)
117 pure [s, template]
117 pure [s, template]
118
118
119parseType' :: (MonadError PscIdeError m) =>
119parseType' :: (MonadError PscIdeError m) =>
src/Language/PureScript/Ide/Conversions.hs+4−16
@@ -15,27 +15,15 @@
15module Language.PureScript.Ide.Conversions where
15module Language.PureScript.Ide.Conversions where
16
16
17import Control.Lens.Iso
17import Control.Lens.Iso
18−import Data.Text (lines, strip, unwords)
18+import Data.Text (lines, strip, unwords, pack)
19import qualified Language.PureScript as P
19import qualified Language.PureScript as P
20import Protolude
20import Protolude
21
21
22−runProperNameT :: P.ProperName a -> Text
23−runProperNameT = toS . P.runProperName
24−
25properNameT :: Iso' (P.ProperName a) Text
22properNameT :: Iso' (P.ProperName a) Text
26−properNameT = iso (toS . P.runProperName) (P.ProperName . toS)
23+properNameT = iso P.runProperName P.ProperName
27−
28−runIdentT :: P.Ident -> Text
29−runIdentT = toS . P.runIdent
30
24
31identT :: Iso' P.Ident Text
25identT :: Iso' P.Ident Text
32−identT = iso (toS . P.runIdent) (P.Ident . toS)
26+identT = iso P.runIdent P.Ident
33−
34−runOpNameT :: P.OpName a -> Text
35−runOpNameT = toS . P.runOpName
36−
37−runModuleNameT :: P.ModuleName -> Text
38−runModuleNameT = toS . P.runModuleName
39
27
40prettyTypeT :: P.Type -> Text
28prettyTypeT :: 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) =
133 IdeDeclDataConstructor dtor ->
133 IdeDeclDataConstructor dtor ->
134 annotateValue (dtor ^. ideDtorName . properNameT) (IdeDeclDataConstructor dtor)
134 annotateValue (dtor ^. ideDtorName . properNameT) (IdeDeclDataConstructor dtor)
135 IdeDeclTypeClass i ->
135 IdeDeclTypeClass i ->
136− annotateType (runProperNameT i) (IdeDeclTypeClass i)
136+ annotateType (i ^. properNameT) (IdeDeclTypeClass i)
137 IdeDeclValueOperator op ->
137 IdeDeclValueOperator op ->
138 annotateValue (op ^. ideValueOpAlias & valueOperatorAliasT) (IdeDeclValueOperator op)
138 annotateValue (op ^. ideValueOpAlias & valueOperatorAliasT) (IdeDeclValueOperator op)
139 IdeDeclTypeOperator op ->
139 IdeDeclTypeOperator op ->
140 annotateType (op ^. ideTypeOpAlias & typeOperatorAliasT) (IdeDeclTypeOperator op)
140 annotateType (op ^. ideTypeOpAlias & typeOperatorAliasT) (IdeDeclTypeOperator op)
141 where
141 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
143 , annTypeAnnotation = Map.lookup x types
143 , annTypeAnnotation = Map.lookup x types
144 })
144 })
145 annotateValue x = IdeDeclarationAnn (ann {annLocation = Map.lookup (Left x) defs})
145 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
20import Language.PureScript.Ide.Error
20import Language.PureScript.Ide.Error
21import Language.PureScript.Ide.State
21import Language.PureScript.Ide.State
22import Language.PureScript.Ide.Types
22import Language.PureScript.Ide.Types
23−import Language.PureScript.Ide.Util
24import System.IO.UTF8 (readUTF8FileT)
23import System.IO.UTF8 (readUTF8FileT)
25
24
26-- | Given a filepath performs the following steps:
25-- | Given a filepath performs the following steps:
@@ -96,7 +95,7 @@ rebuildModuleOpen makeEnv externs m = do
96 throwError (GeneralError "Failed when rebuilding with open exports")
95 throwError (GeneralError "Failed when rebuilding with open exports")
97 Right result -> do
96 Right result -> do
98 $(logDebug)
97 $(logDebug)
99− ("Setting Rebuild cache: " <> runModuleNameT (P.efModuleName result))
98+ ("Setting Rebuild cache: " <> P.runModuleName (P.efModuleName result))
100 cacheRebuild result
99 cacheRebuild result
101
100
102-- | Parameters we can access while building our @MakeActions@
101-- | Parameters we can access while building our @MakeActions@
src/Language/PureScript/Ide/Reexports.hs+1−1
@@ -53,7 +53,7 @@ prettyPrintReexportResult f ReexportResult{..}
53 | otherwise =
53 | otherwise =
54 "Failed to resolve reexports for "
54 "Failed to resolve reexports for "
55 <> f reResolved
55 <> f reResolved
56− <> foldMap (\(mn, ref) -> runModuleNameT mn <> show ref) reFailed
56+ <> foldMap (\(mn, ref) -> P.runModuleName mn <> show ref) reFailed
57
57
58-- | Whether any Refs couldn't be resolved
58-- | Whether any Refs couldn't be resolved
59reexportHasFailures :: ReexportResult a -> Bool
59reexportHasFailures :: ReexportResult a -> Bool
src/Language/PureScript/Ide/SourceFile.hs+10−10
@@ -60,9 +60,9 @@ getImportsForFile fp = do
60 where
60 where
61 mkModuleImport (mn, importType', qualifier) =
61 mkModuleImport (mn, importType', qualifier) =
62 ModuleImport
62 ModuleImport
63− (runModuleNameT mn)
63+ (P.runModuleName mn)
64 importType'
64 importType'
65− (runModuleNameT <$> qualifier)
65+ (P.runModuleName <$> qualifier)
66 unwrapPositionedImport (mn, it, q) = (mn, unwrapImportType it, q)
66 unwrapPositionedImport (mn, it, q) = (mn, unwrapImportType it, q)
67 unwrapImportType (P.Explicit decls) = P.Explicit (map unwrapPositionedRef decls)
67 unwrapImportType (P.Explicit decls) = P.Explicit (map unwrapPositionedRef decls)
68 unwrapImportType (P.Hiding decls) = P.Hiding (map unwrapPositionedRef decls)
68 unwrapImportType (P.Hiding decls) = P.Hiding (map unwrapPositionedRef decls)
@@ -101,18 +101,18 @@ extractSpans ss d = case d of
101 P.PositionedDeclaration ss' _ d' ->
101 P.PositionedDeclaration ss' _ d' ->
102 extractSpans ss' d'
102 extractSpans ss' d'
103 P.ValueDeclaration i _ _ _ ->
103 P.ValueDeclaration i _ _ _ ->
104− [(Left (runIdentT i), ss)]
104+ [(Left (P.runIdent i), ss)]
105 P.TypeSynonymDeclaration name _ _ ->
105 P.TypeSynonymDeclaration name _ _ ->
106− [(Right (runProperNameT name), ss)]
106+ [(Right (P.runProperName name), ss)]
107 P.TypeClassDeclaration name _ _ _ members ->
107 P.TypeClassDeclaration name _ _ _ members ->
108− (Right (runProperNameT name), ss) : concatMap (extractSpans' ss) members
108+ (Right (P.runProperName name), ss) : concatMap (extractSpans' ss) members
109 P.DataDeclaration _ name _ ctors ->
109 P.DataDeclaration _ name _ ctors ->
110− (Right (runProperNameT name), ss)
110+ (Right (P.runProperName name), ss)
111− : map (\(cname, _) -> (Left (runProperNameT cname), ss)) ctors
111+ : map (\(cname, _) -> (Left (P.runProperName cname), ss)) ctors
112 P.ExternDeclaration ident _ ->
112 P.ExternDeclaration ident _ ->
113− [(Left (runIdentT ident), ss)]
113+ [(Left (P.runIdent ident), ss)]
114 P.ExternDataDeclaration name _ ->
114 P.ExternDataDeclaration name _ ->
115− [(Right (runProperNameT name), ss)]
115+ [(Right (P.runProperName name), ss)]
116 _ -> []
116 _ -> []
117 where
117 where
118 -- We need this special case to be able to also get the position info for
118 -- 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
123 P.PositionedDeclaration ssP' _ dP' ->
123 P.PositionedDeclaration ssP' _ dP' ->
124 extractSpans' ssP' dP'
124 extractSpans' ssP' dP'
125 P.TypeDeclaration ident _ ->
125 P.TypeDeclaration ident _ ->
126− [(Left (runIdentT ident), ssP)]
126+ [(Left (P.runIdent ident), ssP)]
127 _ -> []
127 _ -> []
src/Language/PureScript/Ide/State.hs+1−1
@@ -194,7 +194,7 @@ populateStage3 = do
194 let message duration = "Finished populating Stage3 in " <> displayTimeSpec duration
194 let message duration = "Finished populating Stage3 in " <> displayTimeSpec duration
195 results <- logPerf message (liftIO (atomically (populateStage3STM st)))
195 results <- logPerf message (liftIO (atomically (populateStage3STM st)))
196 traverse_
196 traverse_
197− (logWarnN . prettyPrintReexportResult (runModuleNameT . fst))
197+ (logWarnN . prettyPrintReexportResult (P.runModuleName . fst))
198 (filter reexportHasFailures results)
198 (filter reexportHasFailures results)
199
199
200-- | STM version of populateStage3
200-- | STM version of populateStage3
src/Language/PureScript/Ide/Types.hs+3−3
@@ -212,9 +212,9 @@ instance ToJSON ModuleImport where
212 ] ++ map (\x -> "qualifier" .= x) (maybeToList qualifier)
212 ] ++ map (\x -> "qualifier" .= x) (maybeToList qualifier)
213
213
214identifierFromDeclarationRef :: P.DeclarationRef -> Text
214identifierFromDeclarationRef :: P.DeclarationRef -> Text
215−identifierFromDeclarationRef (P.TypeRef name _) = runProperNameT name
215+identifierFromDeclarationRef (P.TypeRef name _) = P.runProperName name
216−identifierFromDeclarationRef (P.ValueRef ident) = runIdentT ident
216+identifierFromDeclarationRef (P.ValueRef ident) = P.runIdent ident
217−identifierFromDeclarationRef (P.TypeClassRef name) = runProperNameT name
217+identifierFromDeclarationRef (P.TypeClassRef name) = P.runProperName name
218identifierFromDeclarationRef _ = ""
218identifierFromDeclarationRef _ = ""
219
219
220data Success =
220data Success =
src/Language/PureScript/Ide/Util.hs+10−10
@@ -48,9 +48,9 @@ identifierFromIdeDeclaration d = case d of
48 IdeDeclType t -> t ^. ideTypeName . properNameT
48 IdeDeclType t -> t ^. ideTypeName . properNameT
49 IdeDeclTypeSynonym s -> s ^. ideSynonymName . properNameT
49 IdeDeclTypeSynonym s -> s ^. ideSynonymName . properNameT
50 IdeDeclDataConstructor dtor -> dtor ^. ideDtorName . properNameT
50 IdeDeclDataConstructor dtor -> dtor ^. ideDtorName . properNameT
51− IdeDeclTypeClass name -> runProperNameT name
51+ IdeDeclTypeClass name -> P.runProperName name
52− IdeDeclValueOperator op -> op ^. ideValueOpName & runOpNameT
52+ IdeDeclValueOperator op -> op ^. ideValueOpName & P.runOpName
53− IdeDeclTypeOperator op -> op ^. ideTypeOpName & runOpNameT
53+ IdeDeclTypeOperator op -> op ^. ideTypeOpName & P.runOpName
54
54
55discardAnn :: IdeDeclarationAnn -> IdeDeclaration
55discardAnn :: IdeDeclarationAnn -> IdeDeclaration
56discardAnn (IdeDeclarationAnn _ d) = d
56discardAnn (IdeDeclarationAnn _ d) = d
@@ -70,13 +70,13 @@ completionFromMatch (Match (m, IdeDeclarationAnn ann decl)) =
70 IdeDeclType t -> (t ^. ideTypeName . properNameT, t ^. ideTypeKind & P.prettyPrintKind & toS )
70 IdeDeclType t -> (t ^. ideTypeName . properNameT, t ^. ideTypeKind & P.prettyPrintKind & toS )
71 IdeDeclTypeSynonym s -> (s ^. ideSynonymName . properNameT, s ^. ideSynonymType & prettyTypeT)
71 IdeDeclTypeSynonym s -> (s ^. ideSynonymName . properNameT, s ^. ideSynonymType & prettyTypeT)
72 IdeDeclDataConstructor d -> (d ^. ideDtorName . properNameT, d ^. ideDtorType & prettyTypeT)
72 IdeDeclDataConstructor d -> (d ^. ideDtorName . properNameT, d ^. ideDtorType & prettyTypeT)
73− IdeDeclTypeClass name -> (runProperNameT name, "class")
73+ IdeDeclTypeClass name -> (P.runProperName name, "class")
74 IdeDeclValueOperator (IdeValueOperator op ref precedence associativity typeP) ->
74 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)
76 IdeDeclTypeOperator (IdeTypeOperator op ref precedence associativity kind) ->
76 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)
78
78
79− complModule = runModuleNameT m
79+ complModule = P.runModuleName m
80
80
81 complType = maybe complExpandedType prettyTypeT (annTypeAnnotation ann)
81 complType = maybe complExpandedType prettyTypeT (annTypeAnnotation ann)
82
82
@@ -89,17 +89,17 @@ completionFromMatch (Match (m, IdeDeclarationAnn ann decl)) =
89 P.Infix -> "infix"
89 P.Infix -> "infix"
90 P.Infixl -> "infixl"
90 P.Infixl -> "infixl"
91 P.Infixr -> "infixr"
91 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]
93
93
94valueOperatorAliasT
94valueOperatorAliasT
95 :: P.Qualified (Either P.Ident (P.ProperName 'P.ConstructorName)) -> Text
95 :: P.Qualified (Either P.Ident (P.ProperName 'P.ConstructorName)) -> Text
96valueOperatorAliasT i =
96valueOperatorAliasT i =
97− toS (P.showQualified (either P.runIdent P.runProperName) i)
97+ P.showQualified (either P.runIdent P.runProperName) i
98
98
99typeOperatorAliasT
99typeOperatorAliasT
100 :: P.Qualified (P.ProperName 'P.TypeName) -> Text
100 :: P.Qualified (P.ProperName 'P.TypeName) -> Text
101typeOperatorAliasT i =
101typeOperatorAliasT i =
102− toS (P.showQualified P.runProperName i)
102+ P.showQualified P.runProperName i
103
103
104encodeT :: (ToJSON a) => a -> Text
104encodeT :: (ToJSON a) => a -> Text
105encodeT = toS . decodeUtf8 . encode
105encodeT = toS . decodeUtf8 . encode