From 72eeba5fd6178409b4aab5eb8dbfaf4460f6841c Mon Sep 17 00:00:00 2001 From: Josh Rahm Date: Thu, 3 Oct 2024 17:14:46 -0600 Subject: Wip: added -Wall --- src/Language/Fiddle/Internal/Scopes.hs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/Language/Fiddle/Internal/Scopes.hs') 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 -- cgit