Ideas of a match form for PHP
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 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]))
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: