Code Monkey home page Code Monkey logo

Comments (2)

takikawa avatar takikawa commented on June 18, 2024
On Thu, 22 Jan 2015 18:02:32 -0500, asumu at ccs dot neu dot edu wrote:

On 2015-01-22 17:40:02 -0500, [email protected] wrote:

*** Description:
(unless l
(error 'f ""))
(define &^%$ l) ;; comment this line out and it type-checks
l)

I don't have a fix for this, but I do have an explanation for why it
doesn't work.

Without the extra definition, the expansion looks something like this:

  (define-values:4
   (f)
   (lambda:7
    (l)
    (if:8 l (#%app:8 void:8) (let-values:8 () (#%app:9 error 'f (quote ""))))
    l))

which TR can deal with fine because the if expression and l come right
after each other in the function body.

With the extra definition, the expansion looks different:

  (define-values:4
   (f)
   (lambda:7
    (l)
    (letrec-values
     ((()
       (begin:13
        (if:8
         l
         (#%app:8 void:8)
         (let-values:8 () (#%app:14 error 'f (quote ""))))
        (#%app:13 values:13)))
      ((&^%$) l))
     l)))

In this case, the if expression got stuck in a letrec-values RHS.
The problem is that TR currently does not propagate the refinements from
the RHS to the point where the body is typechecked.

Cheers,
Asumu

from typed-racket.

mfelleisen avatar mfelleisen commented on June 18, 2024
On Thu, 22 Jan 2015 18:15:12 -0500, matthias at ccs dot neu dot edu wrote:

The workaround is this:

#lang typed/racket

(: f (-> (U False [Listof String]) [Listof String]))
(define (f l)
  (unless l
    (error 'f ""))
  (g l))
(: g (-> [Listof String] [Listof String]))
(define (g l)
  (define &^%$ l) 
  l)

On Jan 22, 2015, at 6:02 PM, Asumu Takikawa [email protected] wrote:

>> *** Description:
>>  (unless l
>>    (error 'f ""))
>>  (define &^%$ l) ;; comment this line out and it type-checks 
>>  l)
>  (define-values:4
>   (f)
>   (lambda:7
>    (l)
>    (if:8 l (#%app:8 void:8) (let-values:8 () (#%app:9 error 'f (quote ""))))
>    l))
>  (define-values:4
>   (f)
>   (lambda:7
>    (l)
>    (letrec-values
>     ((()
>       (begin:13
>        (if:8
>         l
>         (#%app:8 void:8)
>         (let-values:8 () (#%app:14 error 'f (quote ""))))
>        (#%app:13 values:13)))
>      ((&^%$) l))
>     l)))

from typed-racket.

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.