Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/breuleux/earl-shapely
Earl Grey macros for shapely
https://github.com/breuleux/earl-shapely
Last synced: 9 days ago
JSON representation
Earl Grey macros for shapely
- Host: GitHub
- URL: https://github.com/breuleux/earl-shapely
- Owner: breuleux
- Created: 2015-12-23T22:56:33.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-01-15T02:28:09.000Z (almost 8 years ago)
- Last Synced: 2024-10-18T18:55:21.260Z (28 days ago)
- Size: 2.93 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
earl-shapely
============Earl Grey macros to wrap
[shapely](https://github.com/AriaMinaei/shapely) so that it can
interface with
[Earl Grey](https://earl-grey.io)The `::`, `record` and `union` macros are defined and are used as
such:```earlgrey
require:
earl-shapely ->
any, nil, array-ofrequire-macros:
earl-shapely ->
::, record, unionrecord Person:
name :: String
age :: Number
friends :: array-of(Person)union BinaryTree:
nil
record:
val :: any
left :: BinaryTree
right :: BinaryTree
```The `::` operator can also be used to check if something has a certain
type. It is also compatible with Earl Grey's assignment and pattern
matching syntax:```earlgrey
tree :: BinaryTree = {val = 1, left = {val = 10}}if tree :: BinaryTree:
print "It's a tree!"
else:
print "It isn't!"what-is-it(match value) =
s :: String ->
'"{s}" is a string!'
n :: Number ->
'{n} is a number!'
(t and {=> val}) :: BinaryTree ->
'{t} is a binary tree! The top level has value {val}'print what-is-it(tree)
print what-is-it("Blah blah blah")
```