fsprojects / fsprojects/FSharpPlus

Validation shouldn't have Empty

Open
#267 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug F#+ v2.0
Dominant language
F#
Stars
941
Forks
106
PR merge metrics
No merged PRs in 30d

Description

The type Validation belongs to the Alt abstraction (operation <|>) but not to the Alternative abstraction (operation <|> and empty element).

Why?

Because it doesn't obey the Alternative rule empty <*> f = empty

Here's a repro:

> let (e: Validation<string list,int>) = empty
val e : Validation<string list,int> = Failure []

// but

> let (x: Validation<string list,int>) = empty <*> Failure [""] ;;
val x : Validation<string list,int> = Failure [""]

> e = x ;;
val it : bool = false

I can't see the Alternative instance in the Haskell implementation, if it ever was there now they removed it.

What to do?

We can't remove it now, because of backwards compatibility issues. We'll have to wait until v2.0

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the Validation type and its Alternative operations, especially empty and <*>; compare the reported behavior with the Haskell implementation mentioned in the issue. The work is complete when the v2.0 compatibility plan resolves the invalid Alternative behavior without leaving the documented law violation.

Written by the indexing model from the issue text.

Assessment

Tech stack
fsharp
Domain
tooling
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.