This is an alternative site for discovering Elm packages. You may be looking for the official Elm package site instead.
A saner elm-check DSL
version 1.0.0
license MPL2
native-modules False
elm-version 0.17.0 <= v < 0.18.0
Tag 1.0.0
Committed At 2016-05-25 10:20:10 UTC
elm-lang/core 4.0.1 <= v < 5.0.0 4.0.5
elm-community/elm-check 1.0.0 <= v < 2.0.0 1.0.2



This module provides a saner DSL for Elm Check.

Property testing is great, there's no arguing against it. With Elm Check's DSL we can write claims about our code like this:

import Check exposing (..)
import Check.Producer exposing (list, int)

listSortIsIdempotent =
        "List.sort is idempotent"
        (List.sort >> List.sort)
          (list int)

That looks pretty nice. However, the documentation of the Check module itself says:

Warning: The DSL follows a very strict format. Deviating from this format will yield potentially unintelligible type errors. The following functions have horrendous type signatures and you are better off ignoring them.

Now, Elm Check was made by smart people. The error messages can be as bad as they say they can be.

That's where Laws comes in. What it tries to do is:

  • reuse the machinery of Elm Check -- it's great, and there's no point to reinvent it
  • provide an API that gives better type errors
  • provide an API that has more comprehensible types (so you can easily see how different things fit together)

So how does that previous claim look with Laws? See for yourself:

import Laws exposing (claim, equivalent)

listSortIsIdempotent =
    claim "List.sort is idempotent"
        (List.sort `equivalent` (List.sort >> List.sort))
        (list int)

Have any thought about this? Think it's a bad idea? You know how to improve it? Feel free to chat me up at the Elm Slack!


elm-laws is distributed under the Mozilla Public License 2.0 (see LICENSE).