plutils

programming language utilities
git clone git://git.rr3.xyz/plutils | git clone gits://git.rr3.xyz/plutils
Log | Files | Refs | Submodules | LICENSE

commit b9aaf1d9996e85299c40ea0b0352c18a5bc8a7bb
parent 3baa91b7a8cc580469fb6e0c15673ea36998ceb2
Author: Robert Russell <robert@rr3.xyz>
Date:   Thu, 28 May 2026 21:18:28 -0700

Add const version of Env.define

Diffstat:
Msrc/PlUtils/Environment.hs | 8++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/PlUtils/Environment.hs b/src/PlUtils/Environment.hs @@ -47,11 +47,15 @@ lookup :: Level syn -> Environment syn v -> Maybe v lookup l (Environment d s) = assertLvlInBounds d l $ NatMap.lookup (unLevel l) s -- | Bind and a new variable and assign a value to it. -define :: (Level syn -> v) -> Environment syn v -> Environment syn v -define makeVal env = +defines :: (Level syn -> v) -> Environment syn v -> Environment syn v +defines makeVal env = let (l, env') = bind env in assign l (makeVal l) env' +-- | Bind and a new variable and assign a value to it. +define :: v -> Environment syn v -> Environment syn v +define = defines . const + -- | Evaluate an index in an environment, falling back to making a value with -- the given function in case the environment doesn't have a substitution for -- the index.