What you're seeing is that `scribble/srcdoc` looks for the _binding_
of `->` from `racket/contract` which is being shadowed by the version
of `->` from `ffi/unsafe`. I would do something like this:

#lang racket
(require (rename-in ffi/unsafe [-> -->]) scribble/srcdoc)
(provide
  (proc-doc/names
    a-struct?
    (-> any/c boolean?)
    (a)
    ("Returns true if a is a-struct")))
(struct a-struct (b))

and then use `-->` in ffi declarations.

Sam

On Mon, Dec 23, 2019 at 3:10 AM Dominik Pantůček
<dominik.pantu...@trustica.cz> wrote:
>
> Hello,
>
> apart from parallel sorting and working with unsafe ops, I stumbled upon
> a very strange behavior using ffi-lib:
>
> ------>8------
> #lang racket
> (require scribble/srcdoc)
> (provide
>   (proc-doc/names
>     a-struct?
>     (-> any/c boolean?)
>     (a)
>     ("Returns true if a is a-struct")))
> (struct a-struct (b))
> ----->8-----
>
> Running this works without a glitch:
>
> $ racket test1.rkt
> $
>
> But if we require ffi/unsafe, something bad happens:
>
> ------>8------
> #lang racket
> (require ffi/unsafe scribble/srcdoc)
> (provide
>   (proc-doc/names
>     a-struct?
>     (-> any/c boolean?)
>     (a)
>     ("Returns true if a is a-struct")))
> (struct a-struct (b))
> ----->8-----
>
> $ racket test2.rkt
> test2.rkt:8:4: proc-doc/names: unsupported procedure contract form (no
> argument names)
>   at: (-> any/c boolean?)
>   in: (proc-doc/names a-struct? (-> any/c boolean?) (a) ("Returns true
> if a is a-struct"))
>   location...:
>    test2.rkt:8:4
>   context...:
>    do-raise-syntax-error
>    /usr/share/racket/pkgs/scribble-lib/scribble/srcdoc.rkt:342:2:
> proc-doc/names-transformer
>    /usr/share/racket/pkgs/scribble-lib/scribble/srcdoc.rkt:127:24
>    /usr/share/racket/pkgs/scribble-lib/scribble/srcdoc.rkt:124:0:
> do-provide/doc
>    /usr/share/racket/collects/racket/provide-transform.rkt:63:2:
> pre-expand-export
>    /usr/share/racket/collects/racket/private/reqprov.rkt:708:2: provide
>    apply-transformer-in-context
>    apply-transformer52
>    dispatch-transformer41
>    do-local-expand50
>    /usr/share/racket/collects/syntax/wrap-modbeg.rkt:46:4:
> do-wrapping-module-begin
>    apply-transformer-in-context
>    apply-transformer52
>    dispatch-transformer41
>    loop
>    finish
>    ...
> $
>
> I assume that ffi/unsafe somehow re-defines -> and it does it in a very
> srcdoc-incompatible way. Did anyone spot the same behavior? Can it be
> fixed? That is without rewriting the whole ffi/unsafe library.
>
> I am using a simple workaround to scribble my libraries with ffi/unsafe
> requires:
>
> ----->8-----
> #lang racket
> (require
>  ffi/unsafe
>  scribble/srcdoc)
> (provide
>   (proc-doc/names
>     a-struct?
>     (->* (any/c) () boolean?)
>     ((a) ())
>     ("Returns true if a is a-struct")))
> (struct a-struct (b))
> ----->8-----
>
> But it is kind of strange to use (-> any/c boolean?) contract for
> predicate in one module and (->* (any/c) () boolean?) in another one.
>
> It sort of feels like the problem with requiring unsafe-vector-ref
> without knowing. Although this is also "without knowing", it at least
> exhibits itself at the syntax stage (and not at run-time).
>
>
>
> Cheers,
> Dominik
>
> --
> 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/2ac9a533-4325-53da-6855-01bd07da81a3%40trustica.cz.

-- 
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/CAK%3DHD%2Ba00bzG24AC%2BoxDqzJAWc%2BNFXUVOOAKuMbJcMcesOs8GA%40mail.gmail.com.

Reply via email to