1-----------------------------------------------------------------------------
3-- Module : Language.PureScript.Scope
4-- Copyright : (c) Phil Freeman 2013
7-- Maintainer : Phil Freeman <paf31@cantab.net>
8-- Stability : experimental
12-- Utility functions for working with names in scope
14-----------------------------------------------------------------------------
16module Language.PureScript.Scope (
20 usedNamesCaseAlternative,
21 usedNamesDoNotationElement,
25import Data.List ((\\), nub)
27import Language.PureScript.Declarations
28import Language.PureScript.Names
30usedNames :: (Declaration -> [Ident], Value -> [Ident], Binder -> [Ident], CaseAlternative -> [Ident], DoNotationElement -> [Ident])
31usedNames = everythingOnValues (++) f g h (const []) (const [])
33 f :: Declaration -> [Ident]
34 f (ValueDeclaration name _ _ _ _) = [name]
38 g (Abs (Left arg) _) = [arg]
39 g (Var (Qualified Nothing name)) = [name]
42 h :: Binder -> [Ident]
43 h (VarBinder name) = [name]
47-- Gather all used names appearing inside a declaration
49usedNamesDecl :: Declaration -> [Ident]
50usedNamesDecl = let (f, _, _, _, _) = usedNames in nub . f
53-- Gather all used names appearing inside a value
55usedNamesValue :: Value -> [Ident]
56usedNamesValue = let (_, f, _, _, _) = usedNames in nub . f
59-- Gather all used names appearing inside a binder
61usedNamesBinder :: Binder -> [Ident]
62usedNamesBinder = let (_, _, f, _, _) = usedNames in nub . f
65-- Gather all used names appearing inside a case alternative
67usedNamesCaseAlternative :: CaseAlternative -> [Ident]
68usedNamesCaseAlternative = let (_, _, _, f, _) = usedNames in nub . f
71-- Gather all used names appearing inside a do notation element
73usedNamesDoNotationElement :: DoNotationElement -> [Ident]
74usedNamesDoNotationElement = let (_, _, _, _, f) = usedNames in nub . f
77-- Generate a set of names which are unused inside a value, of the form @_{n}@ for an integer @n@
79unusedNames :: [Ident] -> [Ident]
82 varNames = map (Ident . ('_' :) . show) ([1..] :: [Int])
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