1
1
mirror of https://github.com/github/semantic.git synced 2024-12-24 23:42:31 +03:00

Generate records.

This commit is contained in:
Rob Rix 2019-07-22 15:26:02 -04:00
parent 52da8b764c
commit 043d3083fa
No known key found for this signature in database
GPG Key ID: F188A01508EA1CF7

View File

@ -6,6 +6,7 @@ module Generators
, variable
, boolean
, lambda
, record
, apply
, ifthenelse
) where
@ -50,8 +51,11 @@ lambda bod = do
arg <- name
Gen.subterm bod (Core.lam arg)
record :: MonadGen m => m (Term Core.Core User) -> m (Term Core.Core User)
record bod = Core.record <$> Gen.list (Range.linear 0 5) ((,) . namedValue <$> name <*> bod)
atoms :: MonadGen m => [m (Term Core.Core User)]
atoms = [boolean, variable, pure Core.unit]
literal :: MonadGen m => m (Term Core.Core User)
literal = Gen.recursive Gen.choice atoms [lambda literal]
literal = Gen.recursive Gen.choice atoms [lambda literal, record literal]