git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Merge pull request #435 from purescript/docgen-no-prim

Don't show `Prim.` qualification for basic types in docgen

commit598c11380e6d47166a84771f1ee09f9947aaef8f authorPhil Freeman <paf31@cantab.net> dateMon 2 Jun 2014, 08:28 (12 years ago) parentdc0738e341a233
1 file changed+12−4
docgen/Main.hs+12−4
docgen/Main.hs+12−4
@@ -135,20 +135,20 @@ renderTypeclassImage name =
135135
136136renderDeclaration :: Int -> Maybe [P.DeclarationRef] -> P.Declaration -> Docs
137137renderDeclaration n _ (P.TypeDeclaration ident ty) =
138− atIndent n $ show ident ++ " :: " ++ P.prettyPrintType ty
138+ atIndent n $ show ident ++ " :: " ++ prettyPrintType' ty
139139renderDeclaration n _ (P.ExternDeclaration _ ident _ ty) =
140− atIndent n $ show ident ++ " :: " ++ P.prettyPrintType ty
140+ atIndent n $ show ident ++ " :: " ++ prettyPrintType' ty
141141renderDeclaration n exps (P.DataDeclaration name args ctors) = do
142142 let typeName = P.runProperName name ++ (if null args then "" else " " ++ unwords args)
143143 let exported = filter (isDctorExported name exps . fst) ctors
144144 atIndent n $ "data " ++ typeName ++ (if null exported then "" else " where")
145145 forM_ exported $ \(ctor, tys) ->
146− atIndent (n + 2) $ P.runProperName ctor ++ " :: " ++ concatMap (\ty -> P.prettyPrintType ty ++ " -> ") tys ++ typeName
146+ atIndent (n + 2) $ P.runProperName ctor ++ " :: " ++ concatMap (\ty -> prettyPrintType' ty ++ " -> ") tys ++ typeName
147147renderDeclaration n _ (P.ExternDataDeclaration name kind) =
148148 atIndent n $ "data " ++ P.runProperName name ++ " :: " ++ P.prettyPrintKind kind
149149renderDeclaration n _ (P.TypeSynonymDeclaration name args ty) = do
150150 let typeName = P.runProperName name ++ " " ++ unwords args
151− atIndent n $ "type " ++ typeName ++ " = " ++ P.prettyPrintType ty
151+ atIndent n $ "type " ++ typeName ++ " = " ++ prettyPrintType' ty
152152renderDeclaration n exps (P.TypeClassDeclaration name args implies ds) = do
153153 let impliesText = case implies of
154154 [] -> ""
@@ -164,6 +164,14 @@ renderDeclaration n exps (P.PositionedDeclaration _ d) =
164164 renderDeclaration n exps d
165165renderDeclaration _ _ _ = return ()
166166
167+prettyPrintType' :: P.Type -> String
168+prettyPrintType' = P.prettyPrintType . P.everywhereOnTypes dePrim
169+ where
170+ dePrim ty@(P.TypeConstructor (P.Qualified _ name))
171+ | ty == P.tyBoolean || ty == P.tyNumber || ty == P.tyString =
172+ P.TypeConstructor $ P.Qualified Nothing name
173+ dePrim other = other
174+
167175getName :: P.Declaration -> String
168176getName (P.TypeDeclaration ident _) = show ident
169177getName (P.ExternDeclaration _ ident _ _) = show ident