giuseppemag / bccc Goto Github PK
View Code? Open in Web Editor NEWStatically typed Bi-Cartesian Closed Categories and basic conversions in TypeScript.
Statically typed Bi-Cartesian Closed Categories and basic conversions in TypeScript.
As a programmer interested in adopting more principled methodologies, I absolutely love the ideas you've demonstrated through this library and view it as an extremely valuable resource for learning. Thank you! I really appreciate what you've done here!
I would like to use this as an on-going reference for understanding a subject that tends to allude me (category theory) in terms that I find familiar (mainstream programming languages). As typescript happens to be quite permissive, I can't help but wonder about your decision making process in how you annotated your types. Taking your id
function as an example, I can imagine a myriad of ways to annotate it:
let id = function<a>() : Fun<a,a> { return fun(x => x) } // from your source
let id = <a>():Fun<a,a> => fun(x => x) // same as above but with arrow function syntax
let id = <a>() => fun((x:a):a => x) // one variation
let id:<a>() => Fun<a,a> = () => fun(x => x) // another variation
let id:<a>() => Fun<a,a> = <a>():Fun<a,a> => fun((x:a):a => x) // multiple variations
Another example that has more obvious effects on usage could be the variety of ways to type a function from a to b:
type Fun = <a,b>(_:a) => b
type Fun<a,b> = (_:a) => b
type Fun<a> = <b>(_:a) => b
type Fun<b> = <a>(_:a) => b
I can understand that (at least in the first example), the differences may be of trivial importance. At this time, I'm more curious about another, perhaps equally pedantic, decision: is the fun
wrapper a necessary implementation detail for achieving current usability?
In terms of typescript, I've always written id as let id = <a>(a:a):a => a
. It could be reduced to let id = <a>(a:a) => a
, utilizing inference on the return type, or even simply let id = a => a
in flow, which utilized flow-based programming. The implications of the fun
wrapper reach into other areas, like the semantics of this
and .
, that are somewhat coupled to the language itself and I'm curious whether your implementation could be further simplified (by removing the fun
wrappers) without loss of functionality or if attempting to do so would be a fool's errand.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.