Code Monkey home page Code Monkey logo

expectations's People

Contributors

pbackus avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

aminya

expectations's Issues

More example

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.

does not build if another project uses sumtype

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

Using a child of Exception as the error type causes compilation failure

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!

Why is Expected!(void) not allowed?

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?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.