Skip to content

Commit 5f7f5d6

Browse files
committed
Choice-splitting versions of mapVariants and mapConstVs
1 parent dbfa9e4 commit 5f7f5d6

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/compiler/api/GF/Compile/Compute/Concrete2.hs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
module GF.Compile.Compute.Concrete2
44
(Env, Scope, Value(..), Variants(..), Constraint, OptionInfo(..), ChoiceMap, cleanOptions,
55
ConstValue(..), ConstVariants(..), Globals(..), PredefTable, EvalM,
6-
mapVariants, unvariants, variants2consts, consts2variants,
6+
mapVariants, mapVariantsC, unvariants, variants2consts,
7+
mapConstVs, mapConstVsC, unconstVs, consts2variants,
78
runEvalM, runEvalMWithOpts, stdPredef, globals,
89
PredefImpl, Predef(..), ($\),
910
pdCanonicalArgs, pdArity,
@@ -102,6 +103,10 @@ mapVariants :: (Value -> Value) -> Variants -> Variants
102103
mapVariants f (VarFree vs) = VarFree (f <$> vs)
103104
mapVariants f (VarOpts n cs) = VarOpts n (second f <$> cs)
104105

106+
mapVariantsC :: (Choice -> Value -> Value) -> Choice -> Variants -> Variants
107+
mapVariantsC f c (VarFree vs) = VarFree (mapC f c vs)
108+
mapVariantsC f c (VarOpts n cs) = VarOpts n (mapC (second . f) c cs)
109+
105110
unvariants :: Variants -> [Value]
106111
unvariants (VarFree vs) = vs
107112
unvariants (VarOpts n cs) = snd <$> cs
@@ -142,6 +147,10 @@ mapConstVs :: (ConstValue a -> ConstValue b) -> ConstVariants a -> ConstVariants
142147
mapConstVs f (ConstFree vs) = ConstFree (f <$> vs)
143148
mapConstVs f (ConstOpts n cs) = ConstOpts n (second f <$> cs)
144149

150+
mapConstVsC :: (Choice -> ConstValue a -> ConstValue b) -> Choice -> ConstVariants a -> ConstVariants b
151+
mapConstVsC f c (ConstFree vs) = ConstFree (mapC f c vs)
152+
mapConstVsC f c (ConstOpts n cs) = ConstOpts n (mapC (second . f) c cs)
153+
145154
unconstVs :: ConstVariants a -> [ConstValue a]
146155
unconstVs (ConstFree vs) = vs
147156
unconstVs (ConstOpts n cs) = snd <$> cs

0 commit comments

Comments
 (0)