GithubHelp home page GithubHelp logo

Comments (2)

kinto0 avatar kinto0 commented on April 28, 2024 2

Hi! As far as I know, TypeVars must be present in the function's parameters. To work around this, you could use a similar strategy as decorator factories from our documentation for this error. I did it here

from pyre-check.

vthemelis avatar vthemelis commented on April 28, 2024

@kinto0 thank you ver much! Indeed, I should have seen this earlier.

With some modification, it looks like I can type check car and cdr as well:

Pyre playground here

Something that may be of interest is that I need to write car like:

def car(cons: MyCallableProtocol[T, U]) -> T:
    cont: Callable[[T, U], T] = lambda x, _: x
    return cons(cont)

rather than

def car(cons: MyCallableProtocol[T, U]) -> T:
    return cons(lambda x, _: x)

to get full type safety. Without this change, changing the return type of car from T to something else doesn't elicit a type error.

In other words, it doesn't seem like pyre can infer the type of the lambda correctly.

Thanks a lot for the help!

from pyre-check.

Related Issues (20)

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.