This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { | |
| always, | |
| equals, | |
| identity, | |
| ifElse, | |
| map, | |
| partial, | |
| } from 'ramda' | |
| const isObject = input => input !== null && typeof input === 'object' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { class, interface, implements } from 'sweet-interfaces'; | |
| const constant = x => _ => x; | |
| const identity = x => x; | |
| const flip = f => (a, b) -> f(b, c); | |
| interface Setoid { | |
| // eq :: Setoid a => a ~> a -> Boolean | |
| eq(b) { return this === b; } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Sometimes, you might want to supply *some* config, but | |
| // not necessarily *all*. Maybe your password is really | |
| // secret, so you don't want to risk saving it in a config | |
| // file. In which case, you'll want to ask the user to enter | |
| // it when your script runs. | |
| // This interface provides a flexible approach, where | |
| // the user is prompted for a missing key when it's | |
| // requested - if a particular key isn't needed for a given | |
| // run, the user won't need to enter it. Of course, if the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var byMonth = R.groupBy(R.prop('Month')); | |
| var byAuthor = R.groupBy(R.prop('Author')); | |
| var royalty_key = 'Royalty (SUM)'; | |
| var months_keys = R.uniq(R.map(R.prop('Month'), data)).sort(); | |
| var monthly_revenue = | |
| R.map((group) => | |
| R.reduce((acc, record) => acc + parseMoney(record[royalty_key]), 0, group), | |
| byMonth(data)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| CATEGORY THEORY FOR PROGRAMMERS | |
| Category Theory 1.1: Motivation and Philosophy | |
| https://www.youtube.com/watch?v=I8LbkfSSR58&index=1&list=PLbgaMIhjbmEnaH_LTkxLI7FMa2HsnawM_ | |
| Composability, Abstraction, Reusability | |
| Category Theory is a higher-level language. | |
| Not a practical, executable language. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const reg = new RegExp("([^?=&]+)(=([^&]*))?", "g") | |
| function qs (uri) { | |
| const obj = {} | |
| uri = uri.replace(/^.*\?/, '') | |
| uri.replace(reg, map) | |
| return obj | |
| function map (a0, a1, a2, a3) { | |
| obj[decodeURIComponent(a1)] = decodeURIComponent(a3) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type Request<'i,'o,'k> = 'i * ('o -> 'k) | |
| let bindRequest bind f (s,k) = s, fun v -> bind(k v,f) | |
| type Id = int | |
| type Entity<'e> = Entity of Id option * 'e | |
| [<Measure>] type money | |
| type User = {name : string; email : string; ballance : int<money>} | |
| type Product = { name : string; quantity : int; price : int<money>} | |
| type Email = {body:string; subject : string} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /*eslint-env es6 */ | |
| // Inspired by the paper "A tutorial on the universality and | |
| // expressiveness of fold" by Graham Hutton (available at | |
| // http://www.cs.nott.ac.uk/~gmh/fold.pdf), implementing some generic | |
| // list handling functions in JavaScript in terms of `fold`. | |
| // Personally I had an enlightnening moment when I realised the | |
| // beautiful interplay of cons lists and foldr during the FP101x | |
| // Haskell course. JavaScript's syntax doesn't make this very apparent |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Linq; | |
| using Raven.Abstractions.Data; | |
| using Raven.Abstractions.Logging; | |
| using Raven.Bundles.Replication.Plugins; | |
| using Raven.Json.Linq; | |
| namespace RavenConflictResolverPlugin | |
| { | |
| public class LastInWinsReplicationConflictResolver |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module BorrowABook = | |
| type BookLoanProblem = | |
| NotInCatalogue | |
| | OutOnLoan | |
| | InsufficientPermission | |
| | Failed of string | |
| type Book = Book | |
| type BookModel = BookModel |