Repository F# setup
open Reified
open Reified.Refinements
open Reified.Result
open Reified.Schema.JsonFsToolkit.ErrorHandling
FsToolkit.ErrorHandling provides a broad set of combinators and computation expressions for Result, asynchronous
results, validation, and related standard F# types.
Reified separates four roles, each installable on its own:
Reified.Resultsupplies a smallerResultsurface,result { }, and the accumulating builders that collect every error rather than stopping at the first.Reified.Constraintdescribes which values are acceptable, and derives the failure from that description.Reified.Refinementsconstructs values whose types record successful checks.Reified.Schemadeclares structured boundaries and accumulates path-aware failures.
None of these depends on Reified.Result; every one of them returns the standard F# Result, so they compose
with Reified.Result, with FsToolkit.ErrorHandling, or with your own helpers.
Existing FsToolkit Result helpers can remain in an application. Both libraries use the standard F# Result type.
| FsToolkit pattern | Reified equivalent |
|---|---|
Result.requireTrue |
Result.require, then Result.orError |
Result.requireSome |
Result.fromOption, then Result.orError |
result { } |
result { } |
asyncResult { }, taskResult { } |
no equivalent; Reified does not model effects |
List.traverseResultA, List.sequenceResultA |
Result.traverseAll, Result.sequenceAll |
| accumulating validation over boundary fields | a record schema<'model> { } interpreted by Schema.parse or Schema.check |
Result.requireTrue and Result.requireSome are two-argument functions in FsToolkit: the error comes first, the
value second. Reified splits that in two, so the error is always attached last with orError:
open Reified.Result
type SignupError =
| TermsNotAccepted
| NameMissing
let acceptedTerms = true
let submittedName = Some "Ada"
// Reified
acceptedTerms |> Result.require |> Result.orError TermsNotAccepted
submittedName |> Result.fromOption |> Result.orError NameMissing
ReifiedResult90-comparisons_90-fstoolkit-comparison.md_page.SignupErrorTermsNotAcceptedNameMissingacceptedTerms: boolsubmittedName: string optionSomeThe representation of "Value of type 'T" The input value. An option representing the value.
(|>): 'T1 -> ('T1 -> 'U) -> 'UApply a function to a value, the value being on the left, the function on the right The argument. The function. The function result. let doubleIt x = x * 2 3 |> doubleIt // Evaluates to 6
Reified.Result.ResultModuleFail-fast helpers over the standard F# Result type.
require: bool -> Result<unit,unit>Requires an already-computed condition where there is no subject value to preserve. The condition is already computed and stands alone, so success produces Ok (). Use okIf/failIf instead when the value under test should flow through. request.AcceptedTerms |> Result.require |> Result.orError TermsNotAccepted
orError: 'error -> Result<'value,'discardedError> -> Result<'value,'error>Replaces whatever error a result carries with the supplied typed error. Ok passes through unchanged. The natural follow-up to okIf/failIf, which fail with unit precisely so the reason is chosen here: value |> Result.okIf isValid |> Result.orError MyError. Use Result.mapError instead when the existing error carries something worth keeping, as a Violation does.
fromOption: 'value option -> Result<'value,unit>Converts an option into a unit-error result. The inverse of toOption.
The FsToolkit equivalents read as acceptedTerms |> Result.requireTrue TermsNotAccepted and
submittedName |> Result.requireSome NameMissing.
With open Reified.ResultDSL, the Result. prefix on require and orError drops — fromOption stays qualified,
since ResultDSL exports only the CE and the local admission functions (okIf, failIf, require, orError,
mapError), not the whole Result module:
open Reified.ResultDSL
acceptedTerms |> require |> orError TermsNotAccepted
submittedName |> Result.fromOption |> orError NameMissing
ReifiedReified.ResultDSLThe concise result vocabulary: the result { } computation expression, its accumulating result.list { } / result.array { } variants, and the lightweight admission functions (okIf, failIf, require, orError, mapError). Optional and opt-in, in the same shape as Reified.DataDSL, Reified.ConstraintDSL, and Reified.SchemaDSL: open Reified.Result for Result, then open Reified.ResultDSL for this vocabulary. Deliberately small: generic combinators such as map, bind, orElse, tap, and the traversal helpers stay qualified as Result.map, Result.bind, and so on.
acceptedTerms: bool(|>): 'T1 -> ('T1 -> 'U) -> 'UApply a function to a value, the value being on the left, the function on the right The argument. The function. The function result. let doubleIt x = x * 2 3 |> doubleIt // Evaluates to 6
require: bool -> Result<unit,unit>Alias for .
orError: 'a -> Result<'b,'c> -> Result<'b,'a>Alias for .
TermsNotAcceptedsubmittedName: string optionReified.Result.ResultModuleFail-fast helpers over the standard F# Result type.
fromOption: 'value option -> Result<'value,unit>Converts an option into a unit-error result. The inverse of toOption.
NameMissingSchema adds one property that Result combinators do not provide: the declaration is inspectable. The same field and constraint metadata can parse input, return complete paths, emit JSON Schema/OpenAPI, compile a JSON codec, and drive forms or documentation.