Re: [racket-users] Limiting consecutive identical elements with match

2019-12-04 Thread Laurent
I don't know what the exact specs are, but what should be the return values
for '(a a a b b c) and '(a a b b b c) ?

(I can't test right now but I suspect the match approach might miss one)



On Wed, Dec 4, 2019, 23:56 Matthew Butterick  wrote:

>
> On Dec 4, 2019, at 3:26 PM, 'Joel Dueck' via Racket Users <
> racket-users@googlegroups.com> wrote:
>
> I like the trick of using list* to match _ on any number of trailing
> elements. The grammar given in the docs doesn't seem to include it; I'm
> curious by what rule is it "allowed" as a pattern?
>
>
> It's a synonym for the `list-rest` match pattern.
>
>
>
> --
> 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/B5F3E54D-B800-481D-8FE3-A03C6B4F565E%40mbtype.com
> 
> .
>

-- 
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/CABNTSaFDxwS5NBoe5cB76sL%2BwcxX8kxMoGWdkyzpRVEH7u0r%3Dg%40mail.gmail.com.


Re: [racket-users] Limiting consecutive identical elements with match

2019-12-04 Thread Matthew Butterick

> On Dec 4, 2019, at 3:26 PM, 'Joel Dueck' via Racket Users 
>  wrote:
> 
> I like the trick of using list* to match _ on any number of trailing 
> elements. The grammar given in the docs doesn't seem to include it; I'm 
> curious by what rule is it "allowed" as a pattern?

It's a synonym for the `list-rest` match pattern.



-- 
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/B5F3E54D-B800-481D-8FE3-A03C6B4F565E%40mbtype.com.


Re: [racket-users] Limiting consecutive identical elements with match

2019-12-04 Thread 'Joel Dueck' via Racket Users
I feel stupid too!

I like the trick of using list* to match _ on any number of trailing 
elements. The grammar given in the docs doesn't seem to include it; I'm 
curious by what rule is it "allowed" as a pattern?

On Wednesday, December 4, 2019 at 5:02:48 PM UTC-6, Sorawee Porncharoenwase 
wrote:
>
> This is super cool indeed. Now I feel stupid.
>
> On Wed, Dec 4, 2019 at 2:56 PM Matthew Butterick  > wrote:
>
>>
>> On Dec 4, 2019, at 2:39 PM, 'Joel Dueck' via Racket Users <
>> racket...@googlegroups.com > wrote:
>>
>> So it seems easy to match "*at least *N identical elements".
>> But is there a method for matching "*no more than *N identical elements"?
>>
>>
>> ?
>>
>>
>> #lang racket
>> (require rackunit)
>>
>> (define (super-cool? lst)
>>   (match lst
>> [(and (list* _ ... a a _)
>>   (not (list* _ ... a a a _))) #t]
>> [_ #f]))
>>
>> (check-true (super-cool? '(1 1 4)))
>> (check-false (super-cool? '(1 1 1 4)))
>>
>> -- 
>> 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...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/racket-users/1734093C-0C39-4289-9747-41CAFB35851F%40mbtype.com
>>  
>> 
>> .
>>
>

-- 
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/bde135bd-a69a-4c8d-8093-dbea6c9c93b9%40googlegroups.com.


Re: [racket-users] Limiting consecutive identical elements with match

2019-12-04 Thread Sorawee Porncharoenwase
This is super cool indeed. Now I feel stupid.

On Wed, Dec 4, 2019 at 2:56 PM Matthew Butterick  wrote:

>
> On Dec 4, 2019, at 2:39 PM, 'Joel Dueck' via Racket Users <
> racket-users@googlegroups.com> wrote:
>
> So it seems easy to match "*at least *N identical elements".
> But is there a method for matching "*no more than *N identical elements"?
>
>
> ?
>
>
> #lang racket
> (require rackunit)
>
> (define (super-cool? lst)
>   (match lst
> [(and (list* _ ... a a _)
>   (not (list* _ ... a a a _))) #t]
> [_ #f]))
>
> (check-true (super-cool? '(1 1 4)))
> (check-false (super-cool? '(1 1 1 4)))
>
> --
> 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/1734093C-0C39-4289-9747-41CAFB35851F%40mbtype.com
> 
> .
>

-- 
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/CADcuegu4s2bhEZNQ1fNt5JX-ENc91Ythaev7VezWk-ZY8Z2%2BcA%40mail.gmail.com.


Re: [racket-users] Limiting consecutive identical elements with match

2019-12-04 Thread Matthew Butterick

> On Dec 4, 2019, at 2:39 PM, 'Joel Dueck' via Racket Users 
>  wrote:
> 
> So it seems easy to match "at least N identical elements".
> But is there a method for matching "no more than N identical elements"?

?


#lang racket
(require rackunit)

(define (super-cool? lst)
  (match lst
[(and (list* _ ... a a _)
  (not (list* _ ... a a a _))) #t]
[_ #f]))

(check-true (super-cool? '(1 1 4)))
(check-false (super-cool? '(1 1 1 4)))

-- 
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/1734093C-0C39-4289-9747-41CAFB35851F%40mbtype.com.


[racket-users] Limiting consecutive identical elements with match

2019-12-04 Thread 'Joel Dueck' via Racket Users
(This is related to the problem for this year’s Advent of Code day 4, 
so...SPOILERS.)
(I did solve both parts of today's problem, so this is more for my own 
edification.)

The problem involves finding lists of numbers, one of the criteria for 
which is that the list has at least two consecutive identical numbers. I 
was able to solve this part of the problem easily with `match`:

(define (cool? lst)
  (match lst
[(list _ ... a a _ ...) #t]
[_ #f]))

> (cool? '(1 2 3 4 5 6))
#f
> (cool? '(1 2 1 4 5 6))
#f
> (cool? '(1 1 1 4 5 6))
#t

The second part (SPOILER) involves finding lists containing **exactly two** 
consecutive identical numbers.
I was trying to find a way to use pattern matching for this problem and 
could not.

As a simple case:
 
(define (super-cool? lst)
  (match lst
[(list a b b c) #t]
[_ #f]))

> (super-cool? '(1 1 1 4))
#t   ; I want it to be #f!

Using `b b` in the middle of the pattern allows me to require that those 
two elements be identical. But there is no requirement that the outside 
elements be *not* identical despite my giving them different ids. I also 
can't do (list (not a) a a (not a)) because, as the docs say[1], "*instances 
of an `id` in different `or` and `not` sub-patterns are independent. The 
binding for `id` is not available in other parts of the same pattern.*"

So it seems easy to match "*at least *N identical elements".
But is there a method for matching "*no more than *N identical elements"?

[1]: https://docs.racket-lang.org/reference/match.html

-- 
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/5225f7e3-4e96-4366-9978-63375995a5fb%40googlegroups.com.


[racket-users] Scribble output without navigation

2019-12-04 Thread 'Reuben Thomas' via Racket Users
How can I get scribble/base to output HTML without the navigation elements?
I just want a plain HTML page, similar to the look of the LaTeX output.

I can of course extract the "main" div from the standard output, but that
seems to be somewhat shutting the stable door after the horse has bolted.

Grepping the package reveals mentions of "nonavigation" but that seems to
be to do with when links are omitted because you can go no further in one
direction or another.

-- 
https://rrt.sc3d.org

-- 
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/CAOnWdohXeROf75DQmdN75hZ8G_rMieT6-A-%3D8fYisJhptbgjiw%40mail.gmail.com.


Re: [racket-users] Vector length and indices contracts

2019-12-04 Thread Matthew Flatt
At Wed, 4 Dec 2019 22:24:10 +0100, Dominik Pantůček wrote:
> What about all the vector-ref, -set! and basically all indices
> contracts? That should probably be the same.

I'm less enthusiastic about that change. It turns out that a non-fixnum
argument won't work for `vector-ref`, but the stronger constraint is
that the argument needs to be less than the vector's length. So, it
seems redundant in an unhelpful way to require that the argument
individually is a fixnum --- but I'm not completely sure.

-- 
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/20191204212918.5D82C650189%40mail-svr1.cs.utah.edu.


Re: [racket-users] Vector length and indices contracts

2019-12-04 Thread Dominik Pantůček



On 04. 12. 19 20:21, Matthew Flatt wrote:
> I think it makes sense to refine the contract to guarantee a fixnum
> result for `vector-length`.
> 
> This fact is currently documented in `unsafe-vetcor-length`, because
> that's the layer where it has seemed sensible to talk about fixnums in
> the past, but that's not where anyone would think to look. Meanwhile,
> the contract for unsafe operation doesn't specify a nonnegative fixnum
> as it should.
> 
> At Wed, 4 Dec 2019 14:07:47 -0500, George Neuner wrote:
>>
>>
>> It would be more correct to use  (and/c fixnum? (or/c zero? positive?)) 
>> to explicitly limit the value.

My impression is - so far - that (and/c fixnum? (or/c zero? positive?))
or (and/c fixnum? exact-nonnegative-integer?) should be the right way to
go with vector-length.

What about all the vector-ref, -set! and basically all indices
contracts? That should probably be the same.

Also updating the contracts for unsafe-vector-* seems reasonable to me.


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/f54df855-6ffd-4979-0f58-2126c80f577d%40trustica.cz.


Re: [racket-users] Scribble: how to wrap a flow in a style?

2019-12-04 Thread 'Reuben Thomas' via Racket Users
On Wed, 4 Dec 2019 at 13:45, Matthew Flatt  wrote:

> I'm not sure I follow completely, but I think the problem is the
> compound-paragraph parsing that is triggered by the lack of space
> between the two `para` calls:
>

Exactly right. I tried to find out if this is documented. I couldn't find
any mention of what constitutes a compound paragraph, nor did grepping the
scribble package for "blank" get me anywhere. But the fact that you know
suggests I have overlooked something…


> Meanwhile, it may be that compound paragraphs do not render in to HTML
> in a valid way (within a nested flow?). But I think the immediate
> problem is that you don't want the compound paragraph.
>

That certainly works for me. Thanks!

-- 
https://rrt.sc3d.org

-- 
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/CAOnWdojdzLted6XHVOzeZygL4fxR41AKT3nRicOnnbQbf_j%3DHA%40mail.gmail.com.


Re: [racket-users] Vector lenght and indices contracts

2019-12-04 Thread Matthew Flatt
I think it makes sense to refine the contract to guarantee a fixnum
result for `vector-length`.

This fact is currently documented in `unsafe-vetcor-length`, because
that's the layer where it has seemed sensible to talk about fixnums in
the past, but that's not where anyone would think to look. Meanwhile,
the contract for unsafe operation doesn't specify a nonnegative fixnum
as it should.

At Wed, 4 Dec 2019 14:07:47 -0500, George Neuner wrote:
> 
> On 12/4/2019 11:03 AM, Dominik Pantůček wrote
> > looking at vector-length[1] documentation, it returns
> > (exact-nonnegative-integer?). However, as far as I can tell, it returns
> > (fixnum?). Also for subsequent contracts in the vector's documentation
> > all indices are assumed to be (exact-nonnegative-integer?) but usually
> > it is impossible on given platform to use anything larger than (fixnum?)
> > in reality
> 
> You are correct that (exact-nonnegative-integer?) doesn't limit values 
> to fixnum range, but the point of using it is more to exclude negative 
> values than to allow super large positive ones.
> 
> This question - or something substantially similar - has come up 
> before.  Your question is about contracts - which can be used from plain 
> Racket - but it is noteworthy that typed/Racket provides types for  
> positive, negative, nonpositive, and nonnegative fixnums - but there are 
> no built-in tests for any of these, so a suitable contract or type 
> declaration has to be synthesized using multiple tests.
> 
> 
> > For example on 64bit platforms the (fixnum?) could store numbers from (-
> > (expt 2 62)) to (sub1 (expt 2 62)). Vector slots cannot be smaller than
> > 64bits (machine-dependent pointers) which means 8 bytes = 3 bits of
> > address. Given 64bit (VERY theoretical) size of the address space, this
> > leaves the possibility of storing a single vector with (expt 2 61)
> > elements into the memory.
> >
> > If I did not overlook anything, the contracts could be safely changed to
> > (fixnum?).
> 
> It would be more correct to use  (and/c fixnum? (or/c zero? positive?)) 
> to explicitly limit the value.
> 
> 
> > And yes, I found this issue while cleaning up my futures-sort[2] package
> > discussed a few months ago here. If I assume
> > (exact-nonnegative-integer?), I need to manually check for (fixnum?).
> > Even though it - given the information above - does not really make much
> > sense.
> >
> >
> > Should I open a PR?
> 
> I don't remember how the previous discussions went.  I'm not sure 
> anything ever really was resolved.
> 
> 
> > Cheers,
> > Dominik
> >
> >
> > [1]
> > 
> https://docs.racket-lang.org/reference/vectors.html#(def._((quote._~23~25kernel
> )._vector-length))
> > [2] https://docs.racket-lang.org/futures-sort/index.html
> 
> YMMV,
> George
> 
> -- 
> 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/295427b5-9390-43b7-b7d5-cf25cce7
> fd4b%40comcast.net.

-- 
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/20191204192133.5463E65018B%40mail-svr1.cs.utah.edu.


Re: [racket-users] Vector lenght and indices contracts

2019-12-04 Thread George Neuner



On 12/4/2019 11:03 AM, Dominik Pantůček wrote

looking at vector-length[1] documentation, it returns
(exact-nonnegative-integer?). However, as far as I can tell, it returns
(fixnum?). Also for subsequent contracts in the vector's documentation
all indices are assumed to be (exact-nonnegative-integer?) but usually
it is impossible on given platform to use anything larger than (fixnum?)
in reality


You are correct that (exact-nonnegative-integer?) doesn't limit values 
to fixnum range, but the point of using it is more to exclude negative 
values than to allow super large positive ones.


This question - or something substantially similar - has come up 
before.  Your question is about contracts - which can be used from plain 
Racket - but it is noteworthy that typed/Racket provides types for  
positive, negative, nonpositive, and nonnegative fixnums - but there are 
no built-in tests for any of these, so a suitable contract or type 
declaration has to be synthesized using multiple tests.




For example on 64bit platforms the (fixnum?) could store numbers from (-
(expt 2 62)) to (sub1 (expt 2 62)). Vector slots cannot be smaller than
64bits (machine-dependent pointers) which means 8 bytes = 3 bits of
address. Given 64bit (VERY theoretical) size of the address space, this
leaves the possibility of storing a single vector with (expt 2 61)
elements into the memory.

If I did not overlook anything, the contracts could be safely changed to
(fixnum?).


It would be more correct to use  (and/c fixnum? (or/c zero? positive?)) 
to explicitly limit the value.




And yes, I found this issue while cleaning up my futures-sort[2] package
discussed a few months ago here. If I assume
(exact-nonnegative-integer?), I need to manually check for (fixnum?).
Even though it - given the information above - does not really make much
sense.


Should I open a PR?


I don't remember how the previous discussions went.  I'm not sure 
anything ever really was resolved.




Cheers,
Dominik


[1]
https://docs.racket-lang.org/reference/vectors.html#(def._((quote._~23~25kernel)._vector-length))
[2] https://docs.racket-lang.org/futures-sort/index.html


YMMV,
George

--
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/295427b5-9390-43b7-b7d5-cf25cce7fd4b%40comcast.net.


Re: [racket-users] How to use dates (especially gregor) with Typed Racket?

2019-12-04 Thread Jon Zeppieri
On Tue, Dec 3, 2019 at 8:55 PM Ben Greenman  wrote:
>
> The error is because gregor/time doesn't export a struct. But
> nevermind that, because you're probably best off with an opaque type:
>
> ```
> #lang typed/racket
>
> (require/typed gregor/time
>   [#:opaque Time time?]
>   [time (->* [Integer] [Integer Integer Integer] Time)]
>   [time->iso8601 (-> Time String)])
>
> (require/typed gregor
>   [current-time (->* [] [#:tz String] Time)])
>
> (time->iso8601 (current-time))
> ;; "21:04:25.687808105"
> ```

Also, most operations on the date/time data structures are generic,
which makes it a bit more complicated to use with typed racket. The
generic predicates, like `time-provider?`, should probably map to
union types, like so (though people like Ben, who are more savvy about
typed racket, might have other ideas):

```
#lang typed/racket

(require/typed gregor/time
   [#:opaque Time time?]
   [time (->* [Integer] [Integer Integer Integer] Time)]
   [time->iso8601 (-> Time String)])

(require/typed gregor
   [#:opaque Datetime datetime?]
   [datetime (->* [Integer] [Integer Integer Integer
Integer Integer Integer] Datetime)])

(define-type Time-Provider (U Time Datetime))

(require/typed gregor
   [current-time (->* [] [#:tz String] Time)]
   [->hours (-> Time-Provider Integer)])

(time->iso8601 (current-time))
(->hours (current-time))
```

Also, if you want to be more specific with your types:
```
#lang typed/racket #:with-refinements

(define-type Hour (Refine [n : Integer] (and (>= n 0) (< n 24
(define-type Minute (Refine [n : Integer] (and (>= n 0) (< n 60
(define-type Second (Refine [n : Integer] (and (>= n 0) (< n 60
(define-type Nanosecond (Refine [n : Integer] (and (>= n 0) (< n 10

(require/typed
 gregor/time
 [#:opaque Time time?]
 [time (->* [Hour] [Minute Second Nanosecond] Time)])
```
... though this might make the proof obligations too onerous,
depending on how you're using the library.

- Jon

-- 
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/CAKfDxxzq0S6-fzMA%3D%2BVfdxH7ZBqkDFO%2BUHt_Nabj%3DOipP%3DMMwQ%40mail.gmail.com.


[racket-users] Vector lenght and indices contracts

2019-12-04 Thread Dominik Pantůček
Hello,

looking at vector-length[1] documentation, it returns
(exact-nonnegative-integer?). However, as far as I can tell, it returns
(fixnum?). Also for subsequent contracts in the vector's documentation
all indices are assumed to be (exact-nonnegative-integer?) but usually
it is impossible on given platform to use anything larger than (fixnum?)
in reality.

For example on 64bit platforms the (fixnum?) could store numbers from (-
(expt 2 62)) to (sub1 (expt 2 62)). Vector slots cannot be smaller than
64bits (machine-dependent pointers) which means 8 bytes = 3 bits of
address. Given 64bit (VERY theoretical) size of the address space, this
leaves the possibility of storing a single vector with (expt 2 61)
elements into the memory.

If I did not overlook anything, the contracts could be safely changed to
(fixnum?).

And yes, I found this issue while cleaning up my futures-sort[2] package
discussed a few months ago here. If I assume
(exact-nonnegative-integer?), I need to manually check for (fixnum?).
Even though it - given the information above - does not really make much
sense.


Should I open a PR?


Cheers,
Dominik


[1]
https://docs.racket-lang.org/reference/vectors.html#(def._((quote._~23~25kernel)._vector-length))
[2] https://docs.racket-lang.org/futures-sort/index.html

-- 
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/e9ea30ad-5563-fe1a-688c-73fe47b51e68%40trustica.cz.


Re: [racket-users] Scribble: how to wrap a flow in a style?

2019-12-04 Thread Matthew Flatt
I'm not sure I follow completely, but I think the problem is the
compound-paragraph parsing that is triggered by the lack of space
between the two `para` calls:

 @foo{@para[#:style "foo"]{Bar.}
 @para{Bar.}}

If you change it to

 @foo{@para[#:style "foo"]{Bar.}

 @para{Bar.}}

then the "SIntrapara" layer goes away.

If all the arguments to `foo` will be paragraphs, then one solution is
skip the `decode-flow` call that is creating a compound paragraph. In
that case, use square brackets, since `foo` then expects normal
arguments instead of text-mode argument:

 @foo[@para[#:style "foo"]{Bar.}
  @para{Bar.}]

Meanwhile, it may be that compound paragraphs do not render in to HTML
in a valid way (within a nested flow?). But I think the immediate
problem is that you don't want the compound paragraph.

At Wed, 4 Dec 2019 11:09:40 +, Reuben Thomas wrote:
> After a few more experiments, I find that I can't work out another problem
> I was having: nested  elements (which is not legal HTML).
> 
> This occurs when I put a style on a @para; for example, a small change to
> the example code that Matthew kindly provided:
> 
> #lang scribble/base
> @(require scribble/core
>   scribble/decode
>   scribble/html-properties)
> 
> @(define foo-style (make-style "foo" (list (alt-tag "div"
> @(define (foo . content) (make-nested-flow foo-style (decode-flow content)))
> 
> @foo{@para[#:style "foo"]{Bar.}
> @para{Bar.}
> 
> This generates (excerpted):
> 
>  class="foo">Bar. class="SIntrapara">Bar.
> 
> My understanding is that a nested flow should be able to contain multiple
> paragraphs. If I remove the style then the extra  elements are not
> generated, but this doesn't seem to be the real problem; rather, it's that
> the paragraphs are wrapped in a single  element containing  class="SIntrapara"> elements for the actual paragraphs. I find the
> following documentation:
> 
>   [@css{SIntrapara} @elem{Used with @tt{} instead of @tt{} for a
> paragraph
>within a @racket[compound-paragraph].}]
> 
> So it looks as though the contents of @foo is being treated as a "compound
> paragraph", which itself is a somewhat tricky idea to me: it looks like
> it's a way to typeset multiple paragraphs without each one being indented
> (so really multiple paragraphs?) yet, as the name suggests, it's clearly
> modelled as a single paragraph. But surely multiple @para's with a
> nested-flow should work correctly?
> 
> I'm sorry, I can't work out whether the confusion is purely mine, or
> whether there's something on going on in Scribble here!
> 
> -- 
> https://rrt.sc3d.org

-- 
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/5de7b860.1c69fb81.e2da.eb45SMTPIN_ADDED_MISSING%40gmr-mx.google.com.


Re: [racket-users] Scribble: how to wrap a flow in a style?

2019-12-04 Thread 'Reuben Thomas' via Racket Users
After a few more experiments, I find that I can't work out another problem
I was having: nested  elements (which is not legal HTML).

This occurs when I put a style on a @para; for example, a small change to
the example code that Matthew kindly provided:

#lang scribble/base
@(require scribble/core
  scribble/decode
  scribble/html-properties)

@(define foo-style (make-style "foo" (list (alt-tag "div"
@(define (foo . content) (make-nested-flow foo-style (decode-flow content)))

@foo{@para[#:style "foo"]{Bar.}
@para{Bar.}

This generates (excerpted):

Bar.Bar.

My understanding is that a nested flow should be able to contain multiple
paragraphs. If I remove the style then the extra  elements are not
generated, but this doesn't seem to be the real problem; rather, it's that
the paragraphs are wrapped in a single  element containing  elements for the actual paragraphs. I find the
following documentation:

  [@css{SIntrapara} @elem{Used with @tt{} instead of @tt{} for a
paragraph
   within a @racket[compound-paragraph].}]

So it looks as though the contents of @foo is being treated as a "compound
paragraph", which itself is a somewhat tricky idea to me: it looks like
it's a way to typeset multiple paragraphs without each one being indented
(so really multiple paragraphs?) yet, as the name suggests, it's clearly
modelled as a single paragraph. But surely multiple @para's with a
nested-flow should work correctly?

I'm sorry, I can't work out whether the confusion is purely mine, or
whether there's something on going on in Scribble here!

-- 
https://rrt.sc3d.org

-- 
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/CAOnWdojgEUr7Wuncg8%2BesnjgHMFjvzoPpzj6xtiPJJ9GMXsF%2BA%40mail.gmail.com.


Re: [racket-users] Scribble: how to wrap a flow in a style?

2019-12-04 Thread 'Reuben Thomas' via Racket Users
On Mon, 2 Dec 2019 at 23:06, Matthew Flatt  wrote:

>
> Ah, it looks like `alt-tag` is the one that works, instead of
> `body-id`. (I'll fix the docs.)
>

Thanks for this. I had come across alt-tag before, but I didn't think of it
here; it didn't occur to me that an HTML-specific solution would work! I
was instead getting stuck on the fact that not every level of the
Scribble's document model has an associated struct (e.g. there is no
"block").

Anyway, this does what I want, so thanks again; it's also reasonably
accurate model-wise: my "foo"s are actually "poem"s, and having them as
nested flows makes sense.

-- 
https://rrt.sc3d.org

-- 
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/CAOnWdoiaEYRYY2iOP1rCWEO5RQMFHooNx-35zZDPrV%2BGvbQXug%40mail.gmail.com.