Disordered letters
It is funny that words with disordered letters can still be read fluently.
It is funny that words with disordered letters can still be read fluently.
This post explore the idea of how would look like if pattern matching would be added to PHP.
And by pattern matching i actually mean racket’s match form.
This post will describe a POC on how to typecheck sql query in typed/racket.
The goal is to make this typecheck:
(: some-query : (Listof (Vector String String)))
(define some-query
(query
movies
#:from ([actor a] [movie m])
#:where (= a.name "Jhon Wayne")
#:select (a.name m.name)))
With the schema defined as:
(define-schema movies
(actor [id Integer]
[name String])
(movie [id Integer]
[name String]
[director_id Integer])
(director [id Integer]
[name String]))
Some ideas on how to build a php to javascript transpiler
I spend a good part of my work time in front of php or javascript code, so I wonder what will it be to compile php to javascript (in a browser context only). All of this is not tested it is just out of my head, I should have looked up how other have come up with problems like yield
but this would kill all interest.
This post describe the implementation of a descriptive macro to fill structures from sql result.
At end of this post we will archive this:
;; assume the table actor exist and have at least id, name, age
(struct actor ([id #:auto] [name #:auto] [age #:auto])
#:transparent #:mutable #:auto-value #f)
(select
(["id" actor id]
["name" actor name]
["age" actor age])
"SELECT a.* FROM actor AS a where a.id = $1"
12)
;; => '(((actor 12 "some name" 80)))
The objective is to implement the most basic working fastcgi protocol in pure racket.
The minimal fastcgi implementation will look like: