Skip to content

Instantly share code, notes, and snippets.

@jwoudenberg
Created July 1, 2017 08:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jwoudenberg/23de9d44d072a693238c655434ac6527 to your computer and use it in GitHub Desktop.
Save jwoudenberg/23de9d44d072a693238c655434ac6527 to your computer and use it in GitHub Desktop.
Controlled recursion for fuzzers
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