1
1
mirror of https://github.com/github/semantic.git synced 2024-11-24 17:04:47 +03:00

Use the Applicative instance to generate BranchElements.

This commit is contained in:
Rob Rix 2016-05-20 22:41:48 -04:00
parent ea79ce4f04
commit 5d9de67ecc

View File

@ -206,7 +206,7 @@ instance Arbitrary BranchElement where
arbitrary = oneof [ Child <$> key <*> joinTheseOf contents
, Margin <$> joinTheseOf margin ]
where key = listOf1 (elements (['a'..'z'] ++ ['A'..'Z'] ++ ['0'..'9']))
contents = key >>= \ key -> wrap key <$> listOf (padding '*')
contents = wrap <$> key <*> listOf (padding '*')
wrap key contents = "(" ++ key ++ contents ++ ")" :: String
margin = listOf (padding '-')
padding char = frequency [ (10, pure char)