7 ms·
Fantasy Land 1.0
- frio 10y agoJavascript is in somewhat of a weird neverland currently. I really want to use this style of library -- mori, Ramda and others are extremely tempting, and fantasy-land (/static-land, which is more up my alley) are doing great work. ... but, all these libraries are huge. I feel guilty foisting hundreds of kilobytes of JS on my users, just so I can write code that I feel is slightly more elegant. I'm avidly waiting for tree-shaking/jsnext:main to truly take hold, and make these tools more practical. Gripes aside, congratulations to the Fantasy Land team :).
- wrong_variable 10y agoYou could add Google Closure Compiler to your pipeline. The trick to not breaking your build is to know which libraries GCC can optimize without breaking. The ones it can - browserify them seperately and then ones it cannot - browserify them later. Its a longer step I agree, but its a small price to pay to be in Fantasy Land :D ( sorry couldn't help it )
- rtpg 10y agoI know some libraries are big but this one seems pretty small? A lot of files but each one's less than 1k. If you set up a concat+minifying step in your process (you should be doing this anyways if you're shipping a real amount of JS) then the total cost of a library like this might just be a couple kilobytes. Angular.JS (which has a huge amount of functionality in its core) is only 50kb gzipped.
- frio 10y agoMy understanding is that this is small because it's a specification :). Most of the things I've seen implement it (eg. Ramda) are larger. Yes, I have a concat/minifying step, but as I mentioned, I'd love to see broader acceptance/implementation of tree-shaking. As it is, tying together fantasy-land, Ramda/mori, React, Redux all adds up very quickly (and that's without writing any business logic!).
- smhenderson 10y agoI don't have a lot of experience with js but isn't the idea that you link to their file urls and if everyone does this than users are only downloading once and caching (typically anyway)? Or are you more worried about page load time, not download time? typically unless you're like me and clear cache when the browser closes...
- hyperpape 10y agoCommon misconception. Even on large web properties like Facebook, a large number of users have empty caches. For your site, with less traffic than Facebook, it'll probably be worse. Linking to shared libraries hosted on a CDN often ends up failing because of distinct versions.
- girvo 10y agoLeverage Rollup's "tree-shaking" optimisation along with ES6 modules ("import { Maybe } from 'ramda-fantasy'") and you'll only be adding what features you actually use. Combine it with a decent transpiler (I recommend Bublé) and Uglify and you're off to the races: tiny builds, that work wonderfully.
- frio 10y agoYep! As I mentioned, I agree that this is the future :). We're just not quite there yet (mainly because lots of libraries still don't ship `jsnext:main` entries, and plenty of downstream libraries end up doing an `import _ from 'lodash'` or similar).
- girvo 10y agoTotally agreed. I'm definitely looking forward to it though, that's for certain! Rollup still has a little ways to go, as does the ecosystem in general, but I'm optimistic for sure!
- mmastrac 10y agoThe main page [1] gives some info about the project and might be a better link: "Specification for interoperability of common algebraic structures in JavaScript" [1] https://github.com/fantasyland/fantasy-land https://github.com/fantasyland/fantasy-land
- sotojuan 10y agoFantasy Land is a great project—proof of how extensible JavaScript can be. There are some very interesting related projects: https://github.com/Avaq/Fluture https://github.com/Avaq/Fluture is basically lazy and better promises. A+ spec got nothing on this. https://github.com/sanctuary-js/sanctuary https://github.com/sanctuary-js/sanctuary adds better typechecks, combinators, and types like Maybe. https://github.com/origamitower/folktale https://github.com/origamitower/folktale An upcoming collection of similar tools for JavaScript. And of course, there's Ramda. I think these libraries may sound impossible to use at work at first, but if you play with them for fun, you can at least learn some cool techniques or paradigms.
- spion 10y ago> lazy and better promises. A+ spec got nothing on this Better how? Does it for example support unbounded recursion without stack overflow? function f(n) { if (n > 0) return Promise.resolve(n - 1).then(f) } Because promises do (there is no maximum n above) Also at a quick glance I see the following: > Be careful when cancelling a hooked Future. If the resource was acquired but not yet consumed, it will no longer be disposed This works in Bluebird; the resource will be disposed even if the promise is cancelled.
- wrong_variable 10y agoPromises are Eagar - it means it has the advantages of Eagerness. Being Lazy has the advantages of laziness which is that if you do not clean your room, you became a hoarder and your room overflows. The point I am making is that either of these tools are not holy grail. I do not think a solution for all is going to exist, just use them when it best suits the application - I think ( Like its just my dumb opinion ) also @spion I think we are going to take this argument to our death beds :D
- sotojuan 10y agoAgreed and I probably shouldn't have said native promises are bad. I think they're okay—flutures just work better with me and how I program.
- BatFastard 10y agoThe link say absolutely nothing about what the project is.
- wrong_variable 10y agoJames Forbes has an amazing article explaining Fantasy Land. https://james-forbes.com/?/posts/the-perfect-api https://james-forbes.com/?/posts/the-perfect-api
- recursive 10y agoI'm one of the unwashed masses that probably just doesn't see the Point, but I'm confused why claims like this are made. > the last API you'll ever need So like... if I wanted to make a post to twitter, I'm pretty sure I'd need another API.
- daneel 10y agoAPI in this case refers to it's original meaning, that is, the interface that is available on a specific "class" of objects. Here, the "class" of objects are mimicking haskell like typeclasses. The chart on the fantasy-land github page demonstrates the interfaces available on each typeclass. For instance, a Maybe is a functor, so it has the map interface. It's also a Monad so it has the chain interface. Unfortunately, API is a loaded term and I think the author doesn't do a good job differentiating from the common usage of the term.
- recursive 10y agoEven in that meaning, it still doesn't make sense. Say there was an abstracted twitter standard defined in an RFC, and a library was provided for interacting with it. There is no Twitter(tm), just implementations of the twitter RFC. Even then, I need to know what the names of the properties are that I have to provide to the fantasy-land-compliant-whatever. Being an expert in fantasy land doesn't tell me that "message" is the property that contains the body of the twitter-compliant message. I still need an api.
- grayrest 10y agoIf you're interested in fantasy land, you might also be interested in: https://github.com/rpominov/static-land https://github.com/rpominov/static-land https://github.com/gcanti/flow-static-land https://github.com/gcanti/flow-static-land
- qwertyuiop924 10y agoNice project. Of course, when I think Fantasy Land, I think of this: https://youtube.com/watch?list=PLMs_JcuNozJa7tg80N_kITisZjHHeE3uo&v=GpjgvANB5mY https://youtube.com/watch?list=PLMs_JcuNozJa7tg80N_kITisZjHH... There's something wrong with me.
- jestar_jokin 10y agoNow I just some way to use it with TypeScript! Unfortunately, it seems support for Higher Kindred Types is lacking. Apparently you can use some neat trick to kinda fake HKTs in Flow, but not in TypeScript, due to its lack of nominal typing. (I don't know the details, though.)
- pschastain 10y agoSo what exactly is it? No explanation on Github. Based on the first comment here it seems to be a javascript library of some kind, but nothing on what it does or should be used for.
- dr_zoidberg 10y agoFrom the README.md on GitHub: > (aka "Algebraic JavaScript Specification") It's a JS library to implement algebras in code. And: > An algebra is a set of values, a set of operators that it is closed under and some laws it must obey. > Each Fantasy Land algebra is a separate specification. An algebra may have dependencies on other algebras which must be implemented. So that is it. It's "weird", it has a lot of functional concepts (which may or may not be present already in the language -- I'm not a JS-guy myself). It sure must be interesting working on code that does all the things this project does, and I can see it must've required it's share of effort.
- pschastain 10y agoWhere did you find the "README.md"? The op link has 5 bullet points from the v1.0.0 release notes and a "thanks to..."
- dr_zoidberg 10y agoGo to the project page[0] on GitHub and the first thing it loads is the README.md file. [0] https://github.com/fantasyland/fantasy-land https://github.com/fantasyland/fantasy-land
- ilostmykeys 10y agoHaskel Land is a more apt name, don't you think?