Question for those using web-server
, do you have some way of auto-reloading code whilst developing? Or do you have some other workflow which you like?
Thanks! Will check it out.
koyo watches the filesystem and restarts the server as needed, but it’s kind of slow. I ran into a number of problems with the reloadable approach in the past (some details https://github.com/Bogdanp/koyo/issues/19\|here).
The runner is https://github.com/Bogdanp/koyo/blob/11698c92463acb0a839409a1c38967d33f209e1f/koyo-lib/koyo/runner.rkt\|here and should be fairly easy to adapt to another project if you want to give that approach a try.
Cheers. I’ll take a look at that too.
@hazel has joined the channel
I just do the following which is probably as quick as anything else:
<ctrl>-c
raco make app.rkt
rlwrap racket app.rkt 1
Everything is in command history for that shell tab, so it’s fast, but not fancy :)
I do admit I was spoiled by Rails code reloading though. I just saved the file and refreshed the browser. If the racket-reloadable
does that, I’ll need to check it out.
how do I represent an X-Expression in Typed Racket? (require/typed xml [#:opaque Xexpr xexpr?])
doesn’t appear to work
(: test (String -> Xexpr))
(define (test str)
`(p ,str))
this type errors with that opaque type
If you really want to use that opaque type, then you need a cast
, I think.
(define (test str)
(cast `(p ,str) Xexpr))
is there a better way of representing an xexpr as a type?
I think it’s possible. I know there’s SExp
type, which is very similar to XExpr
.
frankly, SExp
is probably fine
(define-type Xexpr Sexp) ; close enough
See also JSExpr
(define-type JSExpr
(U 'null Boolean String Integer Inexact-Real (Listof JSExpr) (HashTable Symbol JSExpr)))
looking that up made me realize that making an opaque Url
type was useless, so thanks
(didn’t realize typed/net/url
was a thing)
xexprs are easy to write down with Typed Racket
(define-type Xexpr (U String (List* Symbol (Listof (List Symbol String)) (Listof Xexpr)))
is pretty close
I’m surprised that it doesn’t need Rec
. When must Rec
be used then?
there’s an implicit top-level recursion
Right. Is it accurate then that Rec
is unnecessary for users because they can always use the implicit top-level recursion instead?
@josef.richter has joined the channel