Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kaiepi/p6-failable
Failure sum type
https://github.com/kaiepi/p6-failable
Last synced: 1 day ago
JSON representation
Failure sum type
- Host: GitHub
- URL: https://github.com/kaiepi/p6-failable
- Owner: Kaiepi
- License: artistic-2.0
- Created: 2019-07-12T03:11:09.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2022-01-08T11:37:35.000Z (almost 3 years ago)
- Last Synced: 2024-10-10T20:56:54.733Z (28 days ago)
- Language: Perl 6
- Size: 15.6 KB
- Stars: 1
- Watchers: 1
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG
- License: LICENSE
Awesome Lists containing this project
README
[![Build Status](https://travis-ci.org/Kaiepi/p6-Failable.svg?branch=master)](https://travis-ci.org/Kaiepi/p6-Failable)
NAME
====Failable - Failure sum type
SYNOPSIS
========```perl6
use Failable;sub cat(*@params --> Str:D) {
my Proc:D $proc = run "cat", |@params, :out, :err;
my Str:D $out = $proc.out.slurp(:close);
my Str:D $err = $proc.err.slurp(:close);
fail $err if $err;
$out
}my Failable[Str:D] $output = cat "/etc/hosts";
say $output.WHAT; # OUTPUT: (Str)my Failable[Str:D] $error = cat '.';
say $error.WHAT; # OUTPUT: (Failure)
```DESCRIPTION
===========Failable is a class for creating Failure sum types. Parameterizing Failable creates a new subset of Failure and the parameter passed. This allows you to type variables that are declared using the return values of routines that can fail.
AUTHOR
======Ben Davies (Kaiepi)
COPYRIGHT AND LICENSE
=====================Copyright 2019 Ben Davies
This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.