Coder Social home page Coder Social logo

qfunq / typescript-io-monad Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 73 KB

Port of Bartosz Milewski's C++ monadic IO to typescript. Created a mix of Maybe/IO/Promise, which is a fully functional CCC environment, allowing for recursion to code more complex operations, and inherits all the convenient properties of its components.

Home Page: https://www.youtube.com/watch?v=vkcxgagQ4bM

License: MIT License

CSS 0.17% TypeScript 99.83%
monadic input-output typescript cpp cartesian-closed-category

typescript-io-monad's People

Contributors

qfunq avatar

Watchers

 avatar

typescript-io-monad's Issues

Chat

Welcome to IO-Monad chat.

Feel free to discuss ideas, techniques, compiler technology, or just to say hi!

Compiler tech is my first issue, yes, the code can be more efficiently implemented in terms of trampolines, but its much more
work, and the compiler should be smart enough to know when code is in the CMC, and it can apply optimsations, since intermediary results are inaccessible. The CCC assumes every state is cloneable, which introduces copying. Obviously both cases involve code transformations to a trampoline, for O(1) stack growth. Without it, the beautiful simplicity of the IO monad is purely aesthetic, in all but non-recursive environments (the easy route for compiler writers).

To obtain ultimate performance requires a jump instruction, so none of C,C++ or wasm make ideal targets for this type of code. A good old fashioned jump is needed. However, trampolines can be used in all of these languages, and my own research shows extremely good performance from C++, treated as a high level assembler for a higher level abstraction of it, capable of performing the required transformations.

If it's possible for a single programmer to do this, how come there are essentially no languages out there that do it? The only reason I can think of is that most programming languages provide apis for various components, strings, IO, objects, interfaces, Promises, exceptions. Haskell is an exception to this, but it doesn't really seem practical to code in. For a functional language, it doesn't look very much like the lambda calculus! But its founding functors are very cleverly constructed. The do notation doesn't read naturally, and it is strangely dependent on a pre processor less powerful than itself.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.