[racket-users] Re: racket-poppler dumping core & failing contract checks

2020-02-20 Thread 'John Clements' via users-redirect
Forwarding this with permission to the kind folks on racket-users…

I’m having a strange problem with raco test; specifically, performing raco test 
on a file in a collection from the racket-poppler collection generates error 
text very fast… about 3 megabytes per second… with this text (apparently) 
repeated ad infinitum:

> > internal error: attempt to deschedule the current thread in atomic mode
> > exception raised by exception handler: abort-current-continuation: contract 
> > violation
> >   expected: continuation-prompt-tag?
> >   given: [?error-value->string-handler not ready?]; original exception 
> > raised: internal error: attempt to deschedule the current thread in atomic 
> > mode
> >   context...:
> >proc
> >loop
> >call-in-empty-metacontinuation-frame
> >abort-current-continuation
> >loop
> >call-in-empty-metacontinuation-frame
> >l
> >loop
> >dynamic-wind
> >temp52_0
> >.../ffi/unsafe.rkt:2117:27: loop
> >.../private/more-scheme.rkt:265:2: call-with-exception-handler
> >call-in-empty-metacontinuation-frame
> >.../ffi/unsafe.rkt:2104:19: retry-loop
> >call-in-empty-metacontinuation-frame
> >call-with-empty-metacontinuation-frame-for-swap

(a longer prefix appears below)

However, copying the same file to /tmp/ and running raco test on that file 
produces much saner output (included below). 

The bad news: this package uses ffi, so in some sense all bets are off.

The important question: is this difference likely to be the result of a “real" 
internal error in racket, and it would be a good idea to try and track it down, 
or is this a known problem with raco test, or something else entirely?

FWIW, this is stock 7.6, running on macOS 10.15.2.

Any thoughts welcome!

John

> On Feb 20, 2020, at 4:02 PM, Jens Axel Søgaard  wrote:
> 
> > BTW, is it okay with you if I forward this to racket-users? I feel like 
> > people there might be better able to answer some of these questions.
> 
> Of course. 
> 
> I might have forgotten to try the examples when I updated racket-poppler to 
> work with latex-pict.
> 
> And I just notices that the docs of latex-pict is missing on 
> docs.racket-lang.org.
> You hopefully found them in the source, but if not the beginning of 
> 
> https://github.com/soegaard/latex-pict/blob/master/latex-pict/tex.rkt
> 
> contains an explanation.
> 
> /Jens Axel
> 
> 
> 
> Den fre. 21. feb. 2020 kl. 00.56 skrev John Clements 
> :
> Okay, that worked! Good to see.
> 
> On the topic of the output explosion … I’m not sure exactly what’s going on. 
> The problem appears to be related to the “test-pdf-functions.rkt” file, but 
> when I run it directly, I get a different and more sensible error
> 
> hardy:/tmp clements> /Applications/Racket\ v7.6/bin/racket 
> /Users/clements/Library/Racket/7.6/pkgs/racket-poppler/racket-poppler/examples/test-pdf-functions.rkt
> #f
> #f
> pdf-title: contract violation
>   expected: pdf?
>   given: #f
>   in: the 1st argument of
>   (-> pdf? (or/c false? string?))
>   contract from: 
>   /racket-poppler/racket-poppler/main.rkt
>   blaming: 
> /racket-poppler/racket-poppler/examples/test-pdf-functions.rkt
>(assuming the contract is correct)
>   at: /racket-poppler/racket-poppler/main.rkt:42.2
>   context...:
>.../private/blame.rkt:347:0: raise-blame-error
>.../private/arrow-val-first.rkt:486:18
>call-with-values
>call-in-empty-metacontinuation-frame
>body of 
> "/Users/clements/Library/Racket/7.6/pkgs/racket-poppler/racket-poppler/examples/test-pdf-functions.rkt"
>temp35_0
>for-loop
>run-module-instance!
>perform-require!
>namespace-require+
>#%for-each
>call-in-empty-metacontinuation-frame
>[repeats 1 more time]
>call-with-empty-metacontinuation-frame-for-swap
> 
> I’m not sure why calling it with raco test causes the explosion, especially 
> since I don’t see any use of test-specific functions in this file.
> 
> BTW, is it okay with you if I forward this to racket-users? I feel like 
> people there might be better able to answer some of these questions.
> 
> John
> 
> 
> > On Feb 20, 2020, at 3:41 PM, Jens Axel Søgaard  
> > wrote:
> > 
> > 
> > Den fre. 21. feb. 2020 kl. 00.35 skrev John Clements 
> > :
> > Whoa! 
> > 
> > I just tried installing racket-poppler on my 7.6 installation, and tried 
> > running 
> > 
> > raco test -p racket-poppler
> > 
> > and generated a LOT of error text very quickly. I redirected it to a file 
> > and it generated 95 Megabytes quite quickly. After the first few pages, 
> > though, you see a pattern. 
> > 
> > FWIW, this is on macOS 10.15.2.
> > 
> > I see the same as you - but I don't know what that command is running.
> > I don't made any tests for racket-poppler?
> > 
> > I just tried this program in DrRacket 7.6 CS
> > 
> > #lang racket
> > (require racket-poppler latex-pict pict)
> > (pict->bitmap (tex-math "1+x"))
> > 
> > and that worked fine.
> > 
> > By the way - you might need t

[racket-users] Creating Living Builds in Racket

2020-02-20 Thread Sage Gerard
I'm excited about this one: I put out an experimental release of 
unlike-assets/reactive and would love some feedback/shares.

https://sagegerard.com/unlike-assets-reactive-demo.html

TL;DR: That article is about making living builds in Racket, meaning an 
expression like (u/a "file.txt" number?) will always equal the current number 
of lines in file.txt.

But it's more than that: one living build can depend on others in arbitrary 
ways. For example, I can update a Racket file that provides CSS, and the href 
attribute for the associated  element in each of my HTML pages changes to 
.css to match.

I think this makes it easier to write alternatives to Frog, Pollen and 
Polyglot. A hard part in each of those projects is deciding how to handle some 
soup of incompatible assets, and I've been focused on a more general solution 
to that problem.

Follow-up articles will clarify how to make dependent living builds, and build 
servers. I'll probably do both by publishing the source code of my website.

~slg

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/jimzYUJVzP71Z5cqKer1NQUg2CU1qSU5mb9fSbjBlCVqQLaWGRdz4zLwXmTL1qYMZI_Hw4z806kXmj5AcQ6NnLDzOANxb4gfm64q8BCsN7M%3D%40sagegerard.com.


[racket-users] racket-poppler dumping core & failing contract checks

2020-02-20 Thread 'John Clements' via users-redirect
I’m interested in converting TeX to picts. It looks like racket-poppler might 
be the way to do that. 

Unfortunately, I’m having trouble running racket-poppler. I ran into several 
problems, but fortunately, all of the problems that I saw were also observed by 
the test suite. Running 

raco test -p racket-poppler

on my machine (macOS 10.15.2, racket built from git source this morning) 
produces both a contract failure and a core dump. (Transcript below.)

One obvious problem is that it looks like the latex->pict function now requires 
a #:preamble keyword, which apparently the tests don’t expect? Also, I’m 
dumping core in the ffi calls. What’s the right way to fix this?

Thanks!

John Clements



ardy:/tmp clements> raco test -p racket-poppler
raco test: "/Users/clements/racket/racket/share/pkgs/racket-poppler/info.rkt"
raco test: 
"/Users/clements/racket/racket/share/pkgs/racket-poppler/racket-poppler/examples/test-pdf-functions.rkt"
#t
#
""
'((title "") (author "") (aubject "") (keywords "") (creator "LaTeX with 
hyperref package") (producer "pdfTeX-1.40.3") (page-count 364))
#
'(612.0 792.0)
'(0.0 0.0 612.0 792.0)
"The Racket Guide\nVersion 5.3.4.11\nMatthew Flatt,\nRobert Bruce Findler,\nand 
PLT\nJune 9, 2013\nThis guide is intended for programmers who are new to Racket 
or new to some part of\nRacket. It assumes programming experience, so if you 
are new to programming, consider\ninstead reading How to Design Programs. If 
you want an especially quick introduction to\nRacket, start with Quick: An 
Introduction to Racket with Pictures.\nChapter 2 provides a brief introduction 
to Racket. From Chapter 3 on, this guide dives into\ndetails—covering much of 
the Racket toolbox, but leaving precise details to The Racket\nReference and 
other reference manuals."
"The Racket Guide\nVersion 5.3.4.11\nMatthew Flatt,\nRobert Bruce Findler,\nand 
PLT\nJune 9, 2013\nThis guide is intended for programmers who are new to Racket 
or new to some part of\nRacket. It assumes programming experience, so if you 
are new to programming, consider\ninstead reading How to Design Programs. If 
you want an especially quick introduction to\nRacket, start with Quick: An 
Introduction to Racket with Pictures.\nChapter 2 provides a brief introduction 
to Racket. From Chapter 3 on, this guide dives into\ndetails—covering much of 
the Racket toolbox, but leaving precise details to The Racket\nReference and 
other reference manuals.\n1"
'()
'((238.76 164.7293740006 250.2426717998 180.2060186005) 
(250.2426717998 164.7293740006 259.8144342 180.2060186005) 
(259.8144342 164.7293740006 267.4580717997 180.2060186005) 
(267.4580717997 164.7293740006 271.7619218 180.2060186005) 
(271.7619218 164.7293740006 284.1914405996 180.2060186005))
Assertion failed: (! scaled_font->cache_frozen), function 
cairo_scaled_font_create, file cairo-scaled-font.c, line 1175.
test-pdf-functions.rkt: raco test: non-zero exit: 134
raco test: 
"/Users/clements/racket/racket/share/pkgs/racket-poppler/racket-poppler/examples/test-render-tex.rkt"
application: required keyword argument not supplied
  procedure: latex->pict
  required keyword: #:preamble
  arguments...:
   "$\\sqrt{x^2+y^2}$"
  context...:
   /Users/clements/racket/racket/collects/racket/private/kw.rkt:1544:14
   
"/Users/clements/racket/racket/share/pkgs/racket-poppler/racket-poppler/examples/test-render-tex.rkt":
 [running body]
   temp35_0
   for-loop
   run-module-instance!
   (submod 
"/Users/clements/racket/pkgs/compiler-lib/compiler/commands/test.rkt" process): 
[running body]
   temp35_0
   for-loop
   run-module-instance!
   eval-one-top
test-render-tex.rkt: raco test: non-zero exit: 1
raco test: 
"/Users/clements/racket/racket/share/pkgs/racket-poppler/racket-poppler/ffi.rkt"
raco test: 
"/Users/clements/racket/racket/share/pkgs/racket-poppler/racket-poppler/info.rkt"
raco test: 
"/Users/clements/racket/racket/share/pkgs/racket-poppler/racket-poppler/libs.rkt"
raco test: 
"/Users/clements/racket/racket/share/pkgs/racket-poppler/racket-poppler/main.rkt"
raco test: 
"/Users/clements/racket/racket/share/pkgs/racket-poppler/racket-poppler/render-tex.rkt"
raco test: 
"/Users/clements/racket/racket/share/pkgs/racket-poppler/test-render-tex.rkt"
application: required keyword argument not supplied
  procedure: latex->pict
  required keyword: #:preamble
  arguments...:
   "$\\sqrt{x^2+y^2+z}$"
  context...:
   /Users/clements/racket/racket/collects/racket/private/kw.rkt:1544:14
   
"/Users/clements/racket/racket/share/pkgs/racket-poppler/test-render-tex.rkt": 
[running body]
   temp35_0
   for-loop
   run-module-instance!
   (submod 
"/Users/clements/racket/pkgs/compiler-lib/compiler/commands/test.rkt" process): 
[running body]
   temp35_0
   for-loop
   run-module-instance!
   eval-one-top
test-render-tex.rkt: raco test: non-zero exit: 1
3/3 test failures
hardy:/tmp clements> 



-- 
You received this message because you are subscribed

Re: [racket-users] Implications of stateless servlets & how/whether to avoid them

2020-02-20 Thread Jon Zeppieri
Okay, in that case, you really shouldn't add a content-length header. -Jon

On Thu, Feb 20, 2020 at 1:13 PM Bogdan Popa  wrote:
>
>
> Jon Zeppieri writes:
>
> > When you stream the response, it doesn't use a chunked transfer encoding? 
> > -Jon
>
> The web server chunks all responses on HTTP/1.1 connections[1].
>
> I can confirm that the web server works great[2] for streaming uses cases
> like long polling!
>
> [1]: 
> https://github.com/racket/web-server/blob/564120c0f5e4bb959d4592a37037146d8411948e/web-server-lib/web-server/http/response.rkt#L56
> [2]: 
> https://github.com/Bogdanp/nemea/blob/5c8a58121ed9f264277d7eb56187fbeaad506138/nemea/http/reporting.rkt#L18-L35

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAKfDxxxy_evsbmAPk02K3JX1Z3-sBA5dZDzZ6p8uCtnqicqBvw%40mail.gmail.com.


Re: [racket-users] Lambda calculus done in Racket

2020-02-20 Thread 'John Clements' via Racket Users
I’m sure many other people have something like this, but here’s “Lab 5” from my 
currently-running PL course:

https://www.brinckerhoff.org/clements/2202-csc430/Labs/lab5.html

It introduces church numeral encodings and also this kind of true-false 
encoding as small programming challenges in Racket. It assumes that you already 
know how to program in Racket. It doesn’t go deep.

John

> On Feb 17, 2020, at 9:12 AM, Lawrence Bottorff  wrote:
> 
> I found these blowing down the sidewalk today
> 
> ; TRUE = λx.λy.x
> (define mytrue 
>   (lambda (t) (lambda (f) t)))
> 
> and 
> 
> ; FALSE = λx.λy.y
> (define myfalse
>   (lambda (t) (lambda (f) f)))
> 
> Two problems, I don't understand them and AFAICT, they don't work. I traced 
> them back to this post on stackoverflow. Can anyone get me started here?
> 
> LB
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to racket-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/racket-users/CAFAhFSXjQq2WWei8zvVY38cQmPd9Yb9sd95zCsszWY_aO3xPkA%40mail.gmail.com.



-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/525248ef-03a7-4e88-9ef8-507dd298e433%40mtasv.net.


Re: [racket-users] Implications of stateless servlets & how/whether to avoid them

2020-02-20 Thread Bogdan Popa


Jon Zeppieri writes:

> When you stream the response, it doesn't use a chunked transfer encoding? -Jon

The web server chunks all responses on HTTP/1.1 connections[1].

I can confirm that the web server works great[2] for streaming uses cases
like long polling!

[1]: 
https://github.com/racket/web-server/blob/564120c0f5e4bb959d4592a37037146d8411948e/web-server-lib/web-server/http/response.rkt#L56
[2]: 
https://github.com/Bogdanp/nemea/blob/5c8a58121ed9f264277d7eb56187fbeaad506138/nemea/http/reporting.rkt#L18-L35

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/m2mu9ddt4m.fsf%40192.168.0.142.


Re: [racket-users] Implications of stateless servlets & how/whether to avoid them

2020-02-20 Thread Jon Zeppieri
When you stream the response, it doesn't use a chunked transfer encoding? -Jon

On Thu, Feb 20, 2020 at 12:40 PM Jay McCarthy  wrote:
>
> I assume it is not necessary to be totally accurate, but it is good to when 
> you can, because of the Web principle of accepting broad input and producing 
> specific output. I don't know of any existing program (like a proxy or 
> something) that would fail without an accurate length, but it wouldn't 
> surprise me if there was one.
>
> Jay
>
> --
> Jay McCarthy
> Associate Professor @ CS @ UMass Lowell
> http://jeapostrophe.github.io
> Vincit qui se vincit.
>
>
> On Thu, Feb 20, 2020 at 11:17 AM Brian Adkins  wrote:
>>
>> On Monday, December 3, 2018 at 10:49:40 AM UTC-5, Jay McCarthy wrote:
>>>
>>> > I don't know if the Racket web server (or related libraries) currently 
>>> > provide a way to stream data in the response, but that is something I'll 
>>> > definitely need relatively soon (primarily for streaming large CSV/JSON 
>>> > files). If it doesn't exist, I don't mind writing it, but I also don't 
>>> > want to begin with an approach now that might make adding that capability 
>>> > more difficult later. From my brief research, given the output field of 
>>> > the response struct is a lambda, I think I can stream using that (i.e. 
>>> > return a lambda in the response immediately that begins writing the data 
>>> > as it retrieves it) - hopefully the infrastructure doesn't buffer the 
>>> > entire output. Other than something like that, I'm happy to work mostly 
>>> > at the level of functions from requests to responses.
>>>
>>> The reason why responses have the lambda rather than a byte string is
>>> specifically for streaming like you want. Make sure you specify the
>>> correct response size in the headers.
>>
>>
>> Jay, are you sure it's necessary to specify the correct response size in the 
>> headers? This would be extremely inconvenient in a streaming response 
>> scenario. I looked at some similar code in a Rails project, and it appears 
>> I'm only setting Last-Modified, Content-Disposition and Content-Type headers.
>>
>> Yes, I know this is an old thread, but I'm just now having to stream some 
>> CSV files from the web app :)
>>
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "Racket Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to racket-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/racket-users/995deb39-16f7-432e-8931-3bbae4d86bb7%40googlegroups.com.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to racket-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/racket-users/CAJYbDa%3Dr%2BqARXUCh90Fw1b5c7XqGCyenZcO--t02vK6Sae7wLA%40mail.gmail.com.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAKfDxxx8nFCoMsWH-FbQfwGw8KgAyHqeEYdHJbN8GWmyKV3keg%40mail.gmail.com.


Re: [racket-users] Implications of stateless servlets & how/whether to avoid them

2020-02-20 Thread Jay McCarthy
I assume it is not necessary to be totally accurate, but it is good to when
you can, because of the Web principle of accepting broad input and
producing specific output. I don't know of any existing program (like a
proxy or something) that would fail without an accurate length, but it
wouldn't surprise me if there was one.

Jay

--
Jay McCarthy
Associate Professor @ CS @ UMass Lowell
http://jeapostrophe.github.io
Vincit qui se vincit.


On Thu, Feb 20, 2020 at 11:17 AM Brian Adkins  wrote:

> On Monday, December 3, 2018 at 10:49:40 AM UTC-5, Jay McCarthy wrote:
>>
>> > I don't know if the Racket web server (or related libraries) currently
>> provide a way to stream data in the response, but that is something I'll
>> definitely need relatively soon (primarily for streaming large CSV/JSON
>> files). If it doesn't exist, I don't mind writing it, but I also don't want
>> to begin with an approach now that might make adding that capability more
>> difficult later. From my brief research, given the output field of the
>> response struct is a lambda, I think I can stream using that (i.e. return a
>> lambda in the response immediately that begins writing the data as it
>> retrieves it) - hopefully the infrastructure doesn't buffer the entire
>> output. Other than something like that, I'm happy to work mostly at the
>> level of functions from requests to responses.
>>
>> The reason why responses have the lambda rather than a byte string is
>> specifically for streaming like you want. Make sure you specify the
>> correct response size in the headers.
>
>
> Jay, are you sure it's necessary to specify the correct response size in
> the headers? This would be extremely inconvenient in a streaming response
> scenario. I looked at some similar code in a Rails project, and it appears
> I'm only setting Last-Modified, Content-Disposition and Content-Type
> headers.
>
> Yes, I know this is an old thread, but I'm just now having to stream some
> CSV files from the web app :)
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/995deb39-16f7-432e-8931-3bbae4d86bb7%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAJYbDa%3Dr%2BqARXUCh90Fw1b5c7XqGCyenZcO--t02vK6Sae7wLA%40mail.gmail.com.


Re: [racket-users] Implications of stateless servlets & how/whether to avoid them

2020-02-20 Thread Brian Adkins
On Monday, December 3, 2018 at 10:49:40 AM UTC-5, Jay McCarthy wrote:
>
> > I don't know if the Racket web server (or related libraries) currently 
> provide a way to stream data in the response, but that is something I'll 
> definitely need relatively soon (primarily for streaming large CSV/JSON 
> files). If it doesn't exist, I don't mind writing it, but I also don't want 
> to begin with an approach now that might make adding that capability more 
> difficult later. From my brief research, given the output field of the 
> response struct is a lambda, I think I can stream using that (i.e. return a 
> lambda in the response immediately that begins writing the data as it 
> retrieves it) - hopefully the infrastructure doesn't buffer the entire 
> output. Other than something like that, I'm happy to work mostly at the 
> level of functions from requests to responses. 
>
> The reason why responses have the lambda rather than a byte string is 
> specifically for streaming like you want. Make sure you specify the 
> correct response size in the headers. 


Jay, are you sure it's necessary to specify the correct response size in 
the headers? This would be extremely inconvenient in a streaming response 
scenario. I looked at some similar code in a Rails project, and it appears 
I'm only setting Last-Modified, Content-Disposition and Content-Type 
headers.

Yes, I know this is an old thread, but I'm just now having to stream some 
CSV files from the web app :) 

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/995deb39-16f7-432e-8931-3bbae4d86bb7%40googlegroups.com.


Re: [racket-users] Typed Racket: Casting to types containing type variables

2020-02-20 Thread unlimitedscolobb
Hi Ben,

Thank you for your answer.

On Thursday, February 20, 2020 at 3:29:15 AM UTC+1, Ben Greenman wrote:
>
> On 2/19/20, unlimitedscolobb > wrote: 
> > 
> > [] 
> > 
> > ;Type Checker: Type a could not be converted to a contract because it 
> > contains free variables. 
> > ;   in: a 
> > 
> > Does this mean that I can never cast to types containing type variables? 
>
> Yes 
>

Ah, okay, got it. 
 

> > My original problem comes from playing around with eval, which returns 
> > AnyValues.  Ideally, I would like to be able to retrieve the first 
> returned 
> > 
> > value (done), and then convert it to a type variable bound by one of the 
> > arguments: 
> > 
> > (: my-super-func (All (a) (-> (Type1 a) a))) 
> > (define (my-super-func arg) 
> >   ... 
> >   (get-first-value (eval some-stuff))) ; how to cast to a ? 
>
> You can ask the caller to supply a cast function that turns an Any to an 
> A. 
>

Ahaa, that's a clever idea! 

But depending on what you want to cast to, occurrence typing may be 
> more convenient. For example: 
>
> #lang typed/racket 
>
> (: my-super-func (All (a) (-> (-> Any) (-> Any Boolean : #:+ a) a))) 
> (define (my-super-func get-v check-v) 
>   (assert (get-v) check-v)) 
>
> (ann (my-super-func (lambda () 42) exact-integer?) Integer); 
> ;; 42 
> (ann (my-super-func (lambda () '(A)) (lambda (x) (and (list? x) 
> (andmap symbol? x (Listof Symbol)) 
> ;; '(A) 
>

This does look quite a bit like lifting contracts to types, very nice.

Thank you very much for clarifying and giving a detailed example.  I'm 
coming over from Haskell, so I'm still in process of wrapping my head 
around types and contracts in Racket.

-
Sergiu

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/3fdb2744-fd5b-4668-9da0-ab853fa0efaa%40googlegroups.com.