pbackus / expectations Goto Github PK
View Code? Open in Web Editor NEWMonadic error handling for the D programming language
License: MIT License
Monadic error handling for the D programming language
License: MIT License
Hi!
Can you provide more examples about the usage of the whole library?
For example it is not obvious when to prefer Expected!int to Expected!(int, string) or what is the proper usage of andThen and map.
in the dependencies the sumtype library is set to <1.0.0, so the latest releases can't be used with this library.
Dub can't build a project that includes expectations and another library that uses an updated version of sumtype (example below). Do you think you can upgrade expectations to use a newer version of sumtype?
dub.json
{
"authors": [
"user"
],
"copyright": "Copyright © 2019, user",
"dependencies": {
"ddash": "~>0.11.1",
"expectations": "~>0.2.0"
},
"description": "A minimal D application.",
"license": "proprietary",
"name": "name"
}
dub build
Unresolvable dependencies to package sumtype:
ddash:common 0.11.1 depends on sumtype ~>0.8.0
expectations 0.2.0 depends on sumtype ~>0.6.2
Hi! I have this code:
import expectations;
final class A : Exception
{
import std.exception : basicExceptionCtors;
mixin basicExceptionCtors;
}
alias EA = Expected!(string, A);
void main()
{}
When compiling it under dmd v2.084.0, I get this rather cryptic error at compile time:
sumtype.d(1018,4): Error: static assert: "handler `__lambda1` of type `inout(A) function(inout(A) err) pure nothrow @nogc @safe` never matches"
sumtype.d(838,14): instantiated from here: `matchImpl!(inout(SumType!(string, A)))`
expectations.d(206,14): instantiated from here: `tryMatch!(inout(SumType!(string, A)))`
asd.d(9,12): instantiated from here: `Expected!(string, A)`
The error only seems to happen if the error type is derived from Exception
. Replacing mixin basicExceptionCtors;
with the exact same constructors as Exception
still causes the error.
Is this a bug or am I doing something wrong? Thanks!
Currently it is not possible to use Expected
with void
:
struct Expected(T, E = Exception)
if (!is(T == E) && !is(T == void))
/* ... */
This limits the usage of Expected
to functions which actually return something. Is there a particular reason for this limitation?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.