diff options
author | Josh Rahm <joshuarahm@gmail.com> | 2024-10-03 17:14:46 -0600 |
---|---|---|
committer | Josh Rahm <joshuarahm@gmail.com> | 2024-10-03 17:14:46 -0600 |
commit | 72eeba5fd6178409b4aab5eb8dbfaf4460f6841c (patch) | |
tree | abbadf258331b38a9d7c4e04b925cef4e3f94a1d /src/Language/Fiddle/Internal/Scopes.hs | |
parent | 5d0b8e6371d1e365ff9b10e0160a39f0f1d9f359 (diff) | |
download | fiddle-72eeba5fd6178409b4aab5eb8dbfaf4460f6841c.tar.gz fiddle-72eeba5fd6178409b4aab5eb8dbfaf4460f6841c.tar.bz2 fiddle-72eeba5fd6178409b4aab5eb8dbfaf4460f6841c.zip |
Wip: added -Wall
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 |