kongware / scriptum Goto Github PK
View Code? Open in Web Editor NEWFunctional Programming Unorthodoxly Adjusted to Client-/Server-side Javascript
License: MIT License
Functional Programming Unorthodoxly Adjusted to Client-/Server-side Javascript
License: MIT License
lensGet
et al. shouldn't leak the information whether they depend on Cont
or Id
internally. Additionally, these combinators need to be parameterized over the Lens
type (objLens
, arrLens
etc.), so that they are ad-hoc polymorphic in this regard.
By additionally passing the current index we can prematurely break out of a fold of an indexed compisite type::
const strFold = alg => zero => s => {
let acc = zero;
for (let i = 0; i < s.length; i++)
[acc, i] = alg(acc) (s, i);
return acc;
};
or we can skip certain iterations. I think this approach is superior to indicate the premature break with a special type, as I've done so far.
Find names for $>
, <$
, *>
, <*
and implement them.
Name suggestions:
mapConst
apFst
/apSnd
This way we can choose at runtime if an async function is evaluated sequential or in parallel.
Based on hashed array mapped tries (HAMT).
I think multimethods are a more natural approach to allow function overloading for dynamically typed languages than typeclasses. Provided I've considered all aspects I will probably replace typeclasses.
multimethods must have the following properties:
String
s)(a, a -> b)
/(a, b, a -> b -> c)
As opposed to typeclasses multimethods cannot express return type polymorphism, because without a value you cannot introspect a type.
The Loop
type was replaced by Cont
.
Consider left-biased (error propagating) and right-biased (error fixing) instances for Either. This would require distinct types. What would be meaningful names for their type and value constructors?
namely
specifically
There are no destructive variants since String
is immutable.
I mean functions like fileCopy
or fileUnlink
. For the time being they just return None
(from Option
), They should return someting IO related, though. scriptum uses Task
for asynchronous and Effect
for synchronous IO. So just Task((res, rej) => res(None))
for the former and Effect(() => None)
for the latter? Would that be an improvement?
Say there is a Task
foo
and I want to reuse foo
's result several times. The problem with Task
is that it is based on continuations (CPS) and thus lazily evaluated. So every time I call foo.runTask(res, rej)
the computation is reevaluated instead of simply returning the result.
There seems no way to allow for sharing foo
's result, even not with an impure solution. The only way I can think of is to be in the right scope:
const foo = fileRead("utf8") ("./foo.txt");
foo.runTask(s => {
// in this scope we can reuse s as often we want
}, id);
This is not satisfying, of course. Maybe someone will come up with a better solution.
This results in reducers for arrFoldWhile
of the following form:
acc => x => k => k(...)
Pros:
Cons:
The type should implement the Iterable protocol to be destructable.
namely for
We can replace four functions with just two. This assumes that any call of push et al. is transformed in the following totally mechanic way:
arrPush([1,2,3]) (4);
becomes
arrAppend([1,2,3]) ([4]);
strMatchAll
should return [Matched<String>]
instead of [Matched<Option<<String>>]
.
Is a Prism
/Getter
/Setter
so Lens-like that it simply uses the Lens
constructor internally? That would simplify composition with Lenses
immensely.
In Haskell every monad transformer gets its own type and there is a lot of wrapping/unwrapping taking place.
Since local mutations are not harmful but reasonable in a language without native persistent data types and structural sharing this seems to be a useful endeavor.
namely...
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.