Since apparently I am not the only one wanting to use graphs in Typed 
Racket, I will prepare a typed interface to Stephen Chang's graph library: 
typed-graph.  I am planning to upload it to the main package catalog.

If you have any advice or ideas, or want to contribute to the effort, do 
tell me.

-
Sergiu

On Wednesday, December 23, 2020 at 11:59:16 PM UTC+1 unlimitedscolobb wrote:

> Hello,
>
> Again, a question out of curiosity, because I think I found a solution, 
> but I'd like to have something more elegant.
>
> I'm trying to use the (untyped) Racket generic graph library from my Typed 
> Racket code:
>
> #lang typed/racket
>
> (require/typed graph
>   [#:opaque Graph graph?]
>   [directed-graph (->* ((Listof (List Any Any))) ((Listof Any)) Graph)])
>
> (directed-graph '((a b) (b c)))
>
> When I load this code in the REPL I get
>
> graph?: contract violation
>   any-wrap/c: Unable to protect opaque value passed as `Any`
>   value: #<unweighted-graph>
>   This warning will become an error in a future release.
>   in: the 1st argument of
>       a part of the or/c of
>       (or/c
>        struct-predicate-procedure?/c
>        (-> Any boolean?))
>   contract from: (interface for graph?)
>   blaming: <pkgs>/dds/tmp.rkt
>    (assuming the contract is correct)
>   at: <pkgs>/dds/tmp.rkt:4.18
> #<unweighted-graph>
>
> I found this solution by Alex Knauth: 
> https://stackoverflow.com/questions/65386334/racket-generic-graph-library-in-typed-racket
>  
> , which essentially consists in wrapping the opaque graph struct into 
> another struct.  Alex says that the problem comes from the fact that graph? 
> essentially encompasses a couple different internal representations the 
> graph library uses.
>
> While this solution should fit me, I was wondering whether anybody here 
> has encountered this issue and has a different solution.
>
> -
> 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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/0073afbf-4309-4573-a8fc-aa4bfd4e4d77n%40googlegroups.com.

Reply via email to