git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Don't show `Prim.` qualification for basic types in docgen
commit341a2333696cddb9d7eabc517088365aa11b8e07 authorGary Burgess <gary.burgess@gmail.com> dateMon 2 Jun 2014, 11:22 (12 years ago) parent36dae61
1 file changed+12−4
docgen/Main.hs+12−4
docgen/Main.hs+12−4
@@ -133,20 +133,20 @@ renderTypeclassImage name =
133133
134134renderDeclaration :: Int -> Maybe [P.DeclarationRef] -> P.Declaration -> Docs
135135renderDeclaration n _ (P.TypeDeclaration ident ty) =
136− atIndent n $ show ident ++ " :: " ++ P.prettyPrintType ty
136+ atIndent n $ show ident ++ " :: " ++ prettyPrintType' ty
137137renderDeclaration n _ (P.ExternDeclaration _ ident _ ty) =
138− atIndent n $ show ident ++ " :: " ++ P.prettyPrintType ty
138+ atIndent n $ show ident ++ " :: " ++ prettyPrintType' ty
139139renderDeclaration n exps (P.DataDeclaration name args ctors) = do
140140 let typeName = P.runProperName name ++ " " ++ unwords args
141141 atIndent n $ "data " ++ typeName ++ " where"
142142 let exported = filter (isDctorExported name exps . fst) ctors
143143 forM_ exported $ \(ctor, tys) ->
144− atIndent (n + 2) $ P.runProperName ctor ++ " :: " ++ concatMap (\ty -> P.prettyPrintType ty ++ " -> ") tys ++ typeName
144+ atIndent (n + 2) $ P.runProperName ctor ++ " :: " ++ concatMap (\ty -> prettyPrintType' ty ++ " -> ") tys ++ typeName
145145renderDeclaration n _ (P.ExternDataDeclaration name kind) =
146146 atIndent n $ "data " ++ P.runProperName name ++ " :: " ++ P.prettyPrintKind kind
147147renderDeclaration n _ (P.TypeSynonymDeclaration name args ty) = do
148148 let typeName = P.runProperName name ++ " " ++ unwords args
149− atIndent n $ "type " ++ typeName ++ " = " ++ P.prettyPrintType ty
149+ atIndent n $ "type " ++ typeName ++ " = " ++ prettyPrintType' ty
150150renderDeclaration n exps (P.TypeClassDeclaration name args implies ds) = do
151151 let impliesText = case implies of
152152 [] -> ""
@@ -162,6 +162,14 @@ renderDeclaration n exps (P.PositionedDeclaration _ d) =
162162 renderDeclaration n exps d
163163renderDeclaration _ _ _ = return ()
164164
165+prettyPrintType' :: P.Type -> String
166+prettyPrintType' = P.prettyPrintType . P.everywhereOnTypes dePrim
167+ where
168+ dePrim ty@(P.TypeConstructor (P.Qualified _ name))
169+ | ty == P.tyBoolean || ty == P.tyNumber || ty == P.tyString =
170+ P.TypeConstructor $ P.Qualified Nothing name
171+ dePrim other = other
172+
165173getName :: P.Declaration -> String
166174getName (P.TypeDeclaration ident _) = show ident
167175getName (P.ExternDeclaration _ ident _ _) = show ident