. . . all of which suggests that perhaps we should support blazingly fast list
chaperones eventually :)
--
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 racke
On 2/28/19, Brian Craft wrote:
> So, when working with large data that is internal to an app, where schema
> is guaranteed by serialization, there's no way to load that without another
> O(N) pass to satisfy the type checker?
Right. This is how the type checker helps find & prevent bugs.
There's
There is, but it's called "wrap your data in a struct". The type checker
doesn't know that serialization guarantees your schema, and you haven't
proved that *only* previously-serialized data will be constructed. In order
to represent this knowledge with types, you can create a struct wrapper in
So, when working with large data that is internal to an app, where schema
is guaranteed by serialization, there's no way to load that without another
O(N) pass to satisfy the type checker?
On Thursday, February 28, 2019 at 1:03:48 PM UTC-8, Sam Tobin-Hochstadt
wrote:
>
> Yes, a cast to a List
Yes, a cast to a List type checks all the elements of the list.
There's no way to tell if every element of list is a string in less
than O(N) time -- that information just isn't available anywhere.
Sam
On Thu, Feb 28, 2019 at 3:52 PM Brian Craft wrote:
>
> Really? A cast is also O(N)?
>
> On Thu
Really? A cast is also O(N)?
On Thursday, February 28, 2019 at 11:11:01 AM UTC-8, Sam Tobin-Hochstadt
wrote:
>
> Any of these solutions need a O(N) traversal of the data. That's
> because we need to do a full traversal to be sure we got an actual
> (Listof String) from read-json -- there's no w
Any of these solutions need a O(N) traversal of the data. That's
because we need to do a full traversal to be sure we got an actual
(Listof String) from read-json -- there's no way around it.
Sam
On Thu, Feb 28, 2019 at 2:04 PM Brian Craft wrote:
>
> I would think there'd be a large performance
I would think there'd be a large performance issue, as well, due to needing
an O(N) walk of the data. I'm having type checker issues with (time), so
haven't tested it, but maybe (cast) will get me past those.
Thanks!
On Monday, February 25, 2019 at 4:26:52 PM UTC-8, Philip McGrath wrote:
>
> An
An alternative to figuring out how to satisfy the type checker is to use
`cast`, e.g.:
#lang typed/racket
(require typed/json)
(string-join
(cast
(string->jsexpr
"[\"The\",\"quick\",\"brown\",\"fox\",\"...\"]")
(Listof String)))
Obviously this has pros and cons, the main pro being that it
A JSExpr is one of a couple of things:
- A list
- A hash with symbol keys
- A number
- A string
- A boolean
- Null
The (andmap string?) approach implicitly assumes you're giving it a list.
But it might be something else instead, so you want this: (and (list? js)
(andmap string? js))
On Monday,
That's because you don't necessarily have a list there, so you need to
combine it with a list? check.
Sam
On Mon, Feb 25, 2019, 6:44 PM Brian Craft wrote:
> So, that also gives me a type error:
>
> Type Checker: Polymorphic function `andmap' could not be applied to
> arguments:
> Domains: (->
So, that also gives me a type error:
Type Checker: Polymorphic function `andmap' could not be applied to
arguments:
Domains: (-> a b ... b c) (Listof a) (Listof b) ... b
(-> a c : d) (Listof a)
Arguments: (-> Any Boolean : String) (U EOF JSExpr)
in: (andmap string? s)
On Monday, Fe
I think (andmap string? ...) is probably the easiest way to check that.
Sam
On Mon, Feb 25, 2019, 6:20 PM Brian Craft wrote:
> In typed racket, parsing a string list gives me a JSExpr, which is a
> union. I need to pass it to functions that operate on string lists, but
> can't figure out how to
In typed racket, parsing a string list gives me a JSExpr, which is a union.
I need to pass it to functions that operate on string lists, but can't
figure out how to please the type checker. Maybe with occurrence typing?
But I don't know how to assert "this is a list of strings".
--
You receive
14 matches
Mail list logo