Created
July 1, 2017 08:28
-
-
Save jwoudenberg/23de9d44d072a693238c655434ac6527 to your computer and use it in GitHub Desktop.
Controlled recursion for fuzzers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Recurse exposing (..) | |
{-| -} | |
{-| Function for creating controller recursive values. | |
-} | |
recurse : (a -> a) -> a -> a | |
recurse next done = | |
-- This example recurses two levels down. | |
-- In a fuzzer setting we could let this number vary. | |
next (next done) | |
{-| Function for creating controller recursive values. | |
-} | |
recurse2 : (a -> a -> a) -> a -> a | |
recurse2 next done = | |
next (next done done) (next done done) | |
{- EXAMPLE -} | |
type Chain | |
= Link | |
{ strength : Int | |
, next : Chain | |
} | |
| End | |
chain : Chain | |
chain = | |
let | |
next : Chain -> Chain | |
next chain = | |
Link | |
{ strength = 42 | |
, next = chain | |
} | |
in | |
recurse next End |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment