diff options
Diffstat (limited to 'src/Language/Fiddle/Internal/Scopes.hs')
-rw-r--r-- | src/Language/Fiddle/Internal/Scopes.hs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/Language/Fiddle/Internal/Scopes.hs b/src/Language/Fiddle/Internal/Scopes.hs index ac6f7d1..02c9a5a 100644 --- a/src/Language/Fiddle/Internal/Scopes.hs +++ b/src/Language/Fiddle/Internal/Scopes.hs @@ -29,6 +29,20 @@ data ScopePath k = ScopePath } deriving (Eq, Ord, Show, Read) +-- | Qualify a name with the current scope. +qualifyPath :: ScopePath k -> k -> [k] +qualifyPath ScopePath {currentScope = scope} k = scope ++ [k] + +-- | Push a new scope onto the current scope. +pushScope :: k -> ScopePath k -> ScopePath k +pushScope v s@ScopePath {currentScope = scope} = + s {currentScope = scope ++ [v]} + +-- | Adds a path to the "using" paths. +addUsingPath :: [k] -> ScopePath k -> ScopePath k +addUsingPath path s@ScopePath {usingPaths = paths} = + s {usingPaths = path : paths} + -- | The 'Semigroup' instance for 'Scope' allows combining two scopes, -- where sub-scopes and values are merged together. instance (Ord k) => Semigroup (Scope k t) where |