1-----------------------------------------------------------------------------
3-- Module : Language.PureScript.BindingGroups
4-- Copyright : (c) Phil Freeman 2013
7-- Maintainer : Phil Freeman <paf31@cantab.net>
8-- Stability : experimental
13-----------------------------------------------------------------------------
15module Language.PureScript.BindingGroups (
20import Data.List (intersect)
22import Language.PureScript.Declarations
23import Language.PureScript.Names
24import Language.PureScript.Values
25import Language.PureScript.Scope (usedNames)
27createBindingGroups :: [Declaration] -> [Declaration]
28createBindingGroups ds =
30 values = filter isValueDecl ds
31 nonValues = filter (not . isValueDecl) ds
32 allIdents = map getIdent values
33 verts = map (\d -> (d, getIdent d, usedNames d `intersect` allIdents)) values
34 sorted = map toBindingGroup $ stronglyConnComp verts
36 map handleModuleDeclaration nonValues ++ sorted
38isValueDecl :: Declaration -> Bool
39isValueDecl (ValueDeclaration _ _ _ _) = True
42getIdent :: Declaration -> Ident
43getIdent (ValueDeclaration ident _ _ _) = ident
44getIdent _ = error "Expected ValueDeclaration"
46toBindingGroup :: SCC Declaration -> Declaration
47toBindingGroup (AcyclicSCC d) = d
48toBindingGroup (CyclicSCC [d]) = d
49toBindingGroup (CyclicSCC ds') = BindingGroupDeclaration (map fromValueDecl ds')
51fromValueDecl :: Declaration -> (Ident, Value)
52fromValueDecl (ValueDeclaration ident [] Nothing val) = (ident, val)
53fromValueDecl (ValueDeclaration _ _ _ _) = error "Binders should have been desugared"
54fromValueDecl _ = error "Expected ValueDeclaration"
56handleModuleDeclaration :: Declaration -> Declaration
57handleModuleDeclaration (ModuleDeclaration name ds') = ModuleDeclaration name $ createBindingGroups ds'
58handleModuleDeclaration other = other
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list