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/e2899e3e-7f2c-42cd-a994-2b711423a7aan%40googlegroups.com.

Reply via email to