Skip to content

Commit

Permalink
Simplified field2*record
Browse files Browse the repository at this point in the history
  • Loading branch information
adept committed Aug 22, 2009
1 parent d9caf95 commit 0f15264
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/GraphType.hs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ addLinks links@((DL target mkLink):rest) clusters types =
(danglingLinks, clusters') <- addDecl target clusters types
addLinks (links++danglingLinks) clusters' types

-- | Record Field
-- | Field of the record in dot file
data Field = F { fieldName::Maybe Name
, typeName::DeclName
, createFieldLink::(Maybe (NodeId -> DanglingLink)) -- substitude record NodeId here and get a dangling link
Expand Down Expand Up @@ -104,18 +104,16 @@ addDecl root clusters decls = do
where
-- TODO: add InfixConDecl
-- FIXME: remove duplication
fields2horizRecord fs = do
let label = block $ toLabel $ map typeName fs
rId <- record label
let links = [ mkLink rId | (F _ _ (Just mkLink)) <- fs ]
return (rId, links)
fields2horizRecord fs = mkRecord ( mkLabel fs ) fs
fields2vertRecord header fs = mkRecord ( header <//> mkLabel fs ) fs

fields2vertRecord header fs = do
let label = header <//> ( block $ toLabel $ map typeName fs )
mkRecord label fs = do
rId <- record label
let links = [ mkLink rId | (F _ _ (Just mkLink)) <- fs ]
return (rId, links)


mkLabel fs = block $ toLabel $ map typeName fs

addConstructor (ConDecl nm types) = do
let fs = concatMap type2fields types
fields2vertRecord ("ConDecl " ++ fromName nm) fs
Expand Down

0 comments on commit 0f15264

Please sign in to comment.