Re: [racket-users] How to embed version and build date in an application executable?

2017-01-05 Thread WarGrey Gyoudmon Ju
I realized I was wrong just after posting that email.
Then I figured the way using environment variables, but hesitated because I
never made the `create-embedding-executable` work if more arguments are
passed to it.

Vincent's way delights me.

On Fri, Jan 6, 2017 at 10:42 AM, Alex Harsanyi 
wrote:

> Perhaps I should have clarified this better, but
>
> My application is an executable built with "create-embedding-executable",
> not a package, I'm not sure that the info.rkt can be compiled and packaged
> inside an exe.
>
> I would like to have this information compiled as a .zo file and embedded
> into this executable, so it cannot easily changed. My current solution is
> writing a separate file which is read at run-time, similar to what you
> proposed, but this has the downside that one can change the version just by
> editing the file.
>
> For reference, the application is https://github.com/alex-hhh/ActivityLog2,
> you can have a look at build.rkt for how it is currently done (it creates
> the file build-id.txt).
>
> Cheers,
> Alex.
>
> On Friday, January 6, 2017 at 10:31:43 AM UTC+8, WarGrey Gyoudmon Ju wrote:
> > A racket application usually has an `info.rkt` file in the root
> directory of the project/package/collection.
> > see https://docs.racket-lang.org/raco/getinfo.html
> >
> >
> > You can put your meta information in that file than read it with
> (get-info/full dirpath) which returns a function that works like `hash-ref`.
> >
> >
> > I recommend that way, there are also other alternatives.
> > One that match your example is, just (write)ing a racket list into
> "app-version.rktl" (note, "rktl" is also a conventional name, the "l"
> stands for "load"),
> > then you can (read) back it:
> >
> >
> >
> > (match-define (list app-version app-commit-id app-build-date)
> >   (with-handlers ([exn:fail:filesystem? (lambda [e] (list "dev build"
> "unknown" "no build"))])
> > (call-with-input-file "app-version.rkt" read)))
> >
> >
> > This alternative is simpler than the one using `info.rkt` when you
> update the meta information programmatically.
> >
>
> --
> 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.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] How to embed version and build date in an application executable?

2017-01-05 Thread Vincent St-Amour
You can write compile-time code to query the current date, and get the
version number from an environment variable:

#lang racket
(require (for-syntax racket/date))
(define-syntax (embed-version stx)
  (syntax-case stx ()
[_ #`(format "~a - ~a"
 #,(date->seconds (current-date))
 #,(getenv "VERSION"))]))
(displayln (embed-version))


$ VERSION=3 racket test-date.rkt 
1483670494 - 3
$ VERSION=3 raco make test-date.rkt 
$ racket test-date.rkt
1483670499 - 3
$ racket test-date.rkt
1483670499 - 3

Note: the reason I'm using environment variables is that command-line
arguments are harder to pass through raco make. Probably doable, though.

Vincent


On Thu, 05 Jan 2017 20:08:57 -0600,
Alex Harsanyi wrote:
> 
> I would like to embed versioning and build date information in my application
> executable, and I'm not sure how to do that.  To clarify, in C or C++, I would
> write the following:
> 
>#include 
> 
>#ifndef APPVER
>#define APPVER "no version"
>#endif
> 
>void main()
>{
> printf("%s\n", APPVER);
>}
> 
> I can than compile the code by passing "-D APPVER=1.0" to the compiler command
> line and have it print the correct version.
> 
> How can this be done in Racket?
> 
> I don't really want to check-in a file with the version number in it, and
> besides, I would like to add my GIT commit ID and build date as well in the
> same way.
> 
> My idea is that the build script would write a file like this at build time:
> 
>#lang racket/base
>(define (app-version) "1.0")
>(define (app-commit-id) "abcdefg")
>(define (app-build-date) "06-01-2017T09:10:12")
>(provide app-version app-commit-id app-build-date)
> 
> I would than require this file from other places, but only if it exists,
> something like this:
> 
>(if (file-exists? "app-version.rkt")
>(require "app-version.rkt")
>(begin
>  (define (app-version) "dev build")
>  (define (app-commit-id) "unknown")
>  (define (app-build-date) "no build")))
> 
> Unfortunately, the code above does not work because require needs to be
> defined at top level.
> 
> Does anyone have any suggestions?
> 
> Thanks,
> Alex.
> 
> -- 
> 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.
> For more options, visit https://groups.google.com/d/optout.

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] How to embed version and build date in an application executable?

2017-01-05 Thread Alex Harsanyi
Perhaps I should have clarified this better, but

My application is an executable built with "create-embedding-executable", not a 
package, I'm not sure that the info.rkt can be compiled and packaged inside an 
exe.

I would like to have this information compiled as a .zo file and embedded into 
this executable, so it cannot easily changed. My current solution is writing a 
separate file which is read at run-time, similar to what you proposed, but this 
has the downside that one can change the version just by editing the file.

For reference, the application is https://github.com/alex-hhh/ActivityLog2, you 
can have a look at build.rkt for how it is currently done (it creates the file 
build-id.txt).

Cheers,
Alex.

On Friday, January 6, 2017 at 10:31:43 AM UTC+8, WarGrey Gyoudmon Ju wrote:
> A racket application usually has an `info.rkt` file in the root directory of 
> the project/package/collection.
> see https://docs.racket-lang.org/raco/getinfo.html
> 
> 
> You can put your meta information in that file than read it with 
> (get-info/full dirpath) which returns a function that works like `hash-ref`.
> 
> 
> I recommend that way, there are also other alternatives.
> One that match your example is, just (write)ing a racket list into 
> "app-version.rktl" (note, "rktl" is also a conventional name, the "l" stands 
> for "load"),
> then you can (read) back it:
> 
> 
> 
> (match-define (list app-version app-commit-id app-build-date)
>   (with-handlers ([exn:fail:filesystem? (lambda [e] (list "dev build" 
> "unknown" "no build"))])
>     (call-with-input-file "app-version.rkt" read)))
> 
> 
> This alternative is simpler than the one using `info.rkt` when you update the 
> meta information programmatically.
> 

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] How to embed version and build date in an application executable?

2017-01-05 Thread WarGrey Gyoudmon Ju
A racket application usually has an `info.rkt` file in the root directory
of the project/package/collection.
see https://docs.racket-lang.org/raco/getinfo.html

You can put your meta information in that file than read it with
(get-info/full dirpath) which returns a function that works like `hash-ref`.

I recommend that way, there are also other alternatives.
One that match your example is, just (write)ing a racket list into
"app-version.rktl" (note, "rktl" is also a conventional name, the "l"
stands for "load"),
then you can (read) back it:

(match-define (list app-version app-commit-id app-build-date)
  (with-handlers ([exn:fail:filesystem? (lambda [e] (list "dev build"
"unknown" "no build"))])
(call-with-input-file "app-version.rkt" read)))

This alternative is simpler than the one using `info.rkt` when you update
the meta information programmatically.


On Fri, Jan 6, 2017 at 10:08 AM, Alex Harsanyi 
wrote:

> I would like to embed versioning and build date information in my
> application
> executable, and I'm not sure how to do that.  To clarify, in C or C++, I
> would
> write the following:
>
>#include 
>
>#ifndef APPVER
>#define APPVER "no version"
>#endif
>
>void main()
>{
> printf("%s\n", APPVER);
>}
>
> I can than compile the code by passing "-D APPVER=1.0" to the compiler
> command
> line and have it print the correct version.
>
> How can this be done in Racket?
>
> I don't really want to check-in a file with the version number in it, and
> besides, I would like to add my GIT commit ID and build date as well in the
> same way.
>
> My idea is that the build script would write a file like this at build
> time:
>
>#lang racket/base
>(define (app-version) "1.0")
>(define (app-commit-id) "abcdefg")
>(define (app-build-date) "06-01-2017T09:10:12")
>(provide app-version app-commit-id app-build-date)
>
> I would than require this file from other places, but only if it exists,
> something like this:
>
>(if (file-exists? "app-version.rkt")
>(require "app-version.rkt")
>(begin
>  (define (app-version) "dev build")
>  (define (app-commit-id) "unknown")
>  (define (app-build-date) "no build")))
>
> Unfortunately, the code above does not work because require needs to be
> defined at top level.
>
> Does anyone have any suggestions?
>
> Thanks,
> Alex.
>
> --
> 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.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[racket-users] How to embed version and build date in an application executable?

2017-01-05 Thread Alex Harsanyi
I would like to embed versioning and build date information in my application
executable, and I'm not sure how to do that.  To clarify, in C or C++, I would
write the following:

   #include 

   #ifndef APPVER
   #define APPVER "no version"
   #endif

   void main()
   {
printf("%s\n", APPVER);
   }

I can than compile the code by passing "-D APPVER=1.0" to the compiler command
line and have it print the correct version.

How can this be done in Racket?

I don't really want to check-in a file with the version number in it, and
besides, I would like to add my GIT commit ID and build date as well in the
same way.

My idea is that the build script would write a file like this at build time:

   #lang racket/base
   (define (app-version) "1.0")
   (define (app-commit-id) "abcdefg")
   (define (app-build-date) "06-01-2017T09:10:12")
   (provide app-version app-commit-id app-build-date)

I would than require this file from other places, but only if it exists,
something like this:

   (if (file-exists? "app-version.rkt")
   (require "app-version.rkt")
   (begin
 (define (app-version) "dev build")
 (define (app-commit-id) "unknown")
 (define (app-build-date) "no build")))

Unfortunately, the code above does not work because require needs to be
defined at top level.

Does anyone have any suggestions?

Thanks,
Alex.

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] `apply`ing polymorphic functions in typed/racket

2017-01-05 Thread WarGrey Gyoudmon Ju
On Thu, Jan 5, 2017 at 3:28 PM, Matthew Eric Bassett 
wrote:
>
> the type signatures of this functions are:
> (-> (Setof e) (Setof e) * (Setof e))
>
> > (define list0
> (list (set 2) (set 3 2)))
>   (apply set-union list0)
>
> > (define list2 : (Listof (Setof Positive-Byte))
> (list (set 2) (set 3 2)))
>   (apply set-union list2)
>
> Why does the former work and the latter fail ?
>

because,
`list0` has a type `(List (Setof Positive-Byte) (Setof Positive-Byte))`
which is guaranteed to hold at least one set value.
`list2` may be `null`.

So you get it. `set-union` requires at least one set value as input.

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[racket-users] DrRacket's XML Boxes not hygenic

2017-01-05 Thread Leif Andersen
I noticed today that DrRacket's XML boxes are not hygenic

Lets say I have:

```
#lang racket

(define x [[]])
```

(where [[ ]] denotes the text of an xml box)

X will be, as expected:

```
'(hello ())
```

However, if we redefine quasiquote at the top of the file:

```
#lang racket

(define-syntax (quasiquote stx) #'42)

(define x [[]])
```

Now x is equal to 42.

I know in general that the quasiquote symbol (`) is not hygenic, but this
does not apply here.  When you look at the implementation of these boxes
the thing that the reader converts them to is:

```
(list 'quasiquote clean-xexpr
```

Where `clean-xexpr` is the xml converted to an xexpr.

So, the problem is not the use of the (`) symbol, but the fact that this
function is evaluating to an s-expression rather than a syntax object.

Understandably, if you return a syntax object: #`(quasiquote
#,clean-xexpr), the macro expander will complain about ambiguous scopes.
But, in general, is there a way to say we would like quasiquote to be bound
to the definition in the module defining XML boxes, rather than whatever
one the module using an XML box happens to have?

Thank you.

~Leif Andersen

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Mobile Friendly HTML in Scribble?

2017-01-05 Thread Neil Van Dyke
Just my own current thinking, on laying out paragraph-heavy text, like 
Racket documentation...


For laying out (or typesetting) paragraphs of text single-column -- 
whether it's in a paper book or on-screen -- note that we have a maximum 
column width that the human eye can scan well, for reading paragraphs of 
text at a time.  Approximating roughly, let's say this ideal column 
width is around 70em.  (Think of "em" as very roughly the width of a 
character, in whatever typeface and size is being used, though the width 
can vary a lot within a typeface and font.)


Also note that Web browsers do (and have always, from the very-very 
start) had a default font size for the user's preference on the device.  
For layout purposes, Web designers should still treat this as the user's 
preferred size for reading paragraphs of body text, which was the 
original use (going back to original HTML, which was an SGML encoding of 
a simplified LaTeX-like article style).


Sometimes, at the user's preferred font size, we can't show our full 
70em ideal column width, and/or we can't show both the 70em and whatever 
sidebar stuff we have in the layout, so we dynamically adapt our layout 
gracefully ("responsively").  We keep the highest priority on the user's 
preferred font size (don't make me call the accessibility cops on you), 
and second-highest priority on our ideal column width.  After those two 
top priorities comes the various stuff we might put in any extra 
horizontal space, and we have a lot of flexibility in how we use that 
extra horizontal space, depending how big it is.


A public example (pardon the corny old visual design) of using CSS to 
implement a variation on these priorities, although for a 
not-paragraph-heavy small Web site that puts a higher priority on its 
retro appearance (for no good reason), but still respecting user's font 
size:


http://www.neilvandyke.org/racket/

If you view this on a desktop browser, and vary your window width, you 
can see 3 layout modes:


* More width than we need, so we use our 70em-ish column, plus 
sideheads, plus horizontal dead space.


* Not quite enough room for our sideheads plus our 70em-ish column, but 
we still have enough room for our campy sideheads plus a good-enough 
column width.


* Window is narrow enough that there's really no excuse for our cool 
sideheads, so we reluctantly switch to a smartphone-like layout, with 
headings as horizontal bars between paragraphs.


If the use of non-main-column space were much more complicated, we'd 
have to mix in some JS with the CSS, but in this Web site's case (and 
probably for most paragraph-heavy sites), we can do the layout entirely 
in CSS with media queries:


http://www.neilvandyke.org/neilvandyke-blueboxes.css

The two CSS "@media" queries at the end of the file, combined with the 
pretty clean earlier stuff, implement the 3 layout modes.


Now, that's a corny amateur visual design from 1999, the HTML is ancient 
generated stuff, and the CSS reimplementation is mostly from 2002, 
retrofitted in 2015 to implement the 3 modes... but it's holding up, and 
you get the idea.  "Responsive" layout implementation of paragraph-heavy 
pages can be simple and maintainable, no frameworks required, and you 
can always respect the user's font size.


I'm not talking here about non-paragraph-heavy pages, like many 
marketing pages, or app UIs.  Though some of the principles sometimes 
still apply.


P.S., I just saw the new racket-lang.org Web site for the first time, 
and it looks awesome!  Kudos!  (You might want to remove the third-party 
HTTP requests, and host your nicely modest dependencies yourself, for 
privacy and good-example security reasons.)


--
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.
For more options, visit https://groups.google.com/d/optout.