WIP fix recursive default args

This commit is contained in:
Georges Dubus 2018-01-28 16:54:59 +01:00
parent ad18c62566
commit 7b651303e2
2 changed files with 9 additions and 4 deletions

View file

@ -27,7 +27,7 @@ data NValueF m r
| NVStr Text
| NVList [r]
| NVSet (Map.Map Text r)
| NVFunction (Params r) (ValueSet m -> m r)
| NVFunction (Params (ValueSet m -> m r)) (ValueSet m -> m r)
| NVLiteralPath FilePath
| NVEnvPath FilePath
deriving (Generic, Typeable, Functor)
@ -38,7 +38,7 @@ instance Show f => Show (NValueF m f) where
go (NVStr text) = showsCon1 "NVStr" text
go (NVList list) = showsCon1 "NVList" list
go (NVSet attrs) = showsCon1 "NVSet" attrs
go (NVFunction r _) = showsCon1 "NVFunction" r
go (NVFunction r _) = showsCon1 "NVFunction" (() <$ r)
go (NVLiteralPath p) = showsCon1 "NVLiteralPath" p
go (NVEnvPath p) = showsCon1 "NVEnvPath" p

View file

@ -30,8 +30,13 @@ case_function_set_arg = constantEqualStr "2" "({ a }: 2) { a = 1; }"
case_function_set_two_arg :: Assertion
case_function_set_two_arg = constantEqualStr "2" "({ a, b ? 3 }: b - a) { a = 1; }"
-- case_function_set_two_arg_default_scope :: Assertion
-- case_function_set_two_arg_default_scope = constantEqualStr "2" "({ a, b ? a * 3 }: b - a) { a = 1; }"
case_function_set_two_arg_default_scope :: Assertion
case_function_set_two_arg_default_scope = constantEqualStr "2" "({ a ? 1, b ? a * 3 }: b - a) {}"
case_function_default_env :: Assertion
case_function_default_env = constantEqualStr "2" "let default = 2; in ({ a ? default }: a) {}"
tests :: TestTree
tests = $testGroupGenerator