Skip to main content
A very-simple-subset-of-haskell fuzzer. With the ability to generate lexical tokens as well as plain code.

```
module Generated (function0,function1,function2) where

function0 :: Int -> Bool -> Bool -> Bool -> Bool -> Int -> Int
function0 a b c d e f = (function1 (2 /= 7) False False)

function1 :: Bool -> Bool -> Bool -> Int
function1 a b c = (8 * 0)

function2 :: Bool -> Int
function2 a = 1
```

it's available on pip by `pip install huzzer` (python3+ only)

## Using `huzzer`

The easiest way to use `huzzer` is from the command line:

```
>>>>> huzz
module Generated (function0,function1,function2) where

function0 :: Bool -> Bool
function0 a = ((function2 4 (0 >= 5)) <= ((mod 8 9) + (1 - (function2 0 a))))

function1 :: Bool -> Int -> Int -> Bool -> Bool
function1 a b c d = ((a && a) && (function0 (function1 True b c d)))

function2 :: Int -> Bool -> Int
function2 a b = (div (function2 (max a a) b) 3)
```

There are some options to vary the complexity of programs:
```bash
>>>>> huzz -h
Huzz.

Usage:
huzz [--seed=<randomseed>] [--max-args=<maxarglen>] [--expr-depth=<exprdepth>]
huzz -h | --help

Options:
-h --help Show this screen.
-s --seed=<randomseed> Use <randomseed> to initialise RNG.
-a --max-args=<maxarglen> Maximum number of arguments a function can have [default: 8].
-e --expr-depth=<exprdepth> Maximum expression depth [default: 6].
```

### Using From Inside Python

```python
from huzzer.huzz import huzzer
from huzzer.tokenizing import tokenize

seed = 1337

random_haskell_code = huzzer(
seed,
max_expression_depth=4,
max_type_signiature_length=5,
max_number_of_functions=3,
)


tokens = tokenize(random_haskell_code)

non_whitespace_token_ids = [x.type for x in tokens if x.channel == 0]

print(random_haskell_code)
print('======================')
print(non_whitespace_token_ids)

```
```sh
module Generated (function0,function1,function2) where

function0 :: Bool -> Int -> Bool -> Bool -> Bool
function0 a b c d = ((function1 9) && (function0 d 1 d (function0 c b d d)))

function1 :: Int -> Bool
function1 a = (False || True)

function2 :: Bool -> Int -> Bool -> Bool -> Bool
function2 a b c d = (function2 True 9 False c)
======================
[1, 2, 51, 16, 4, 17, 4, 18, 52, 3, 53, 16, 5, 37, 6, 38, 6, 37, 6, 37, 6, 37, 53, 16, 8, 9, 10, 11, 7, 51, 51, 17, 48, 52, 36, 51, 16, 11, 40, 11, 51, 16, 10, 9, 11, 11, 52, 52, 52, 53, 17, 5, 38, 6, 37, 53, 17, 8, 7, 51, 50, 35, 49, 52, 53, 18, 5, 37, 6, 38, 6, 37, 6, 37, 6, 37, 53, 18, 8, 9, 10, 11, 7, 51, 18, 49, 48, 50, 10, 52]

```



## Setup
Make sure you have python3 on your machine (`which python3` should print a path to it).

Set up a `virtualenv` with `virtualenv -p \`which python3\` env`

Activate the environment with `source env/bin/activate`

Install requirements `pip install -r requirements.txt`

Then you should be good to go. To leave the virtualenv, type `deactivate`


## Testing
To run all of the tests, run `nosetests`.

To run larger acceptance tests (against the ghc compiler), you will need `ghc` and `parallel` installed.
run `./large_acceptance_test.sh <number of tests>`

## TODOs
* multiple definitions for functions

### Distribution
```
python setup.py sdist bdist_wheel
twine upload dist/*
```


Metadata

Release files for huzzer 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for huzzer 0.1.2
File Size Uploaded Provenance Actions
huzzer-0.1.2.tar.gz 17.8 kB Without provenance Details for huzzer-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for huzzer 0.1.2
File Interpreter ABI Platform Actions
huzzer-0.1.2-py3-none-any.whl Python 3 none any Details for huzzer-0.1.2-py3-none-any.whl

Total release size: 40.2 kB

Release files / huzzer-0.1.2.tar.gz

Download URL huzzer-0.1.2.tar.gz
Size 17.8 kB
Tags Source
SHA-256 checksum
How to use checksums
2f4f7912263f66ac6f5b9b641f105e69d4f41da8684e90a728ce4c2b5ed9178e
BLAKE2b-256 checksum
How to use checksums
f9c6655336e5e9b92d09ac1a18f535b9c406c4b16d764cdb459ef0ce9f1a38ef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / huzzer-0.1.2-py3-none-any.whl

Download URL huzzer-0.1.2-py3-none-any.whl
Size 22.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
54a0ecfd1c08d7c280cc752d0a4a4cff73bf2928c42f2620c64a7ecf3c0da033
BLAKE2b-256 checksum
How to use checksums
dc6d45f411c332ed0a6fbb8ee9d3a015618b4fb512bad238e9c160c35834414b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for huzzer 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page