Skip to content

Instantly share code, notes, and snippets.

View fayimora's full-sized avatar
🕺

Fayi FB fayimora

🕺
  • London, England
View GitHub Profile

I think the better approach is to know what is a Functor before asking about Monads.

A Functor is a Higher Kinded Type/Type Constructor/Function at the type level that has a certain shape (that is, it implements a map function). A Functor is also what's known as a typeclass. A Monad is also a typeclass

Typeclasses are a form of ad-hoc polymorphism that let you add functionality to existing code that you may or may not have written.

Here's is the basic definition of a Functor

trait Functor[F[_]] {
 def map[A, B](fa: F[A])(f: A => B): F[B]
@fayimora
fayimora / controllers.application.js
Created November 10, 2016 22:17 — forked from poteto/controllers.application.js
ember-changeset-validations demo
import Ember from 'ember';
import AdultValidations from '../validations/adult';
import ChildValidations from '../validations/child';
import { reservedEmails } from '../validators/uniqueness';
import { schema } from '../models/user';
const { get } = Ember;
const { keys } = Object;
export default Ember.Controller.extend({
var appButton = document.getElementById("app-button");
appButton.addEventListener("mouseover",function() {
this.src = "path/to/image";
});
appButton.addEventListener("mouseout",function(){
// return stuff to default
this.src = "path/to/image";
});
public class LocationServiceF extends IntentService {
private static final String TAG = "LocationService";
private Pubnub pubnub;
private Rider currentRider;
public LocationServiceF() {
super("LocationService");
}

Keybase proof

I hereby claim:

  • I am fayimora on github.
  • I am fayimora (https://keybase.io/fayimora) on keybase.
  • I have a public key ASBXT7j-rCkBXSuXqq7czNpnC1yUlpbVtw3YIDwaObF0aAo

To claim this, I am signing this object:

// THIS
$coord = \App\Classes\geoClass::getCoord($request->address1." ".$request->address2, $request->postcode);
// SHOULD BE
$coord = \App\Classes\GeoClass::getCoord($request->address1." ".$request->address2, $request->postcode);
// NOTE: geoClass -> GeoClass
import android.app.Service;
import android.content.Intent;
import android.location.Location;
import android.os.IBinder;
import android.util.Log;
import com.google.android.gms.location.LocationRequest;
import com.pubnub.api.Pubnub;
@fayimora
fayimora / types.md
Created April 19, 2016 11:39
So you want a Type!

So you want a Type!

The Compiler: Avoid Silly Errors

You have probably heard me say this more times than you care to remember but it really cannot be overstated. In python you can initialise a variable, num = 10 and later down the line override that variable like this num = some_complex_func(). Everything looks ok until you try to use that variable. So let's divide that number by a sentinel, sentinel = 3 and result = num/sentinel. On first scan, this looks great but if you take a deeper look, we have no guarantees that some_complex_func() will return a number, talk more of a number with the right type. You deploy your code and it bites you in the ass, AT RUNTIME!

Imagine something like this:

isValid = check_if_valid()
var distance = require('google-distance');
var _ = require('lodash');
module.exports = function (pubnub) {
pubnub.subscribe({
channel: "dispatch",
message: onNewDispatch
});
function onNewDispatch(message) {
module.exports = function(foo) {
function setName(name) {
}
function getName() {
}
// .................