Skip to content

Instantly share code, notes, and snippets.

Avatar
🎨
painting boxes

Paco pakoito

🎨
painting boxes
View GitHub Profile
View specs-example.rs
extern crate specs;
use specs::Component;
use specs::VecStorage;
use specs::System;
use specs::WriteStorage;
use specs::ReadStorage;
use specs::World;
use specs::DispatcherBuilder;
use specs::RunNow;
@pakoito
pakoito / Recursive
Last active Feb 15, 2018
Recursive datatypes in Kotlin
View Recursive
sealed class NaturalNum
object Zero: NaturalNum()
class PlusOne<N: NaturalNum>(): NaturalNum()
fun num(zero: Zero) = 0
fun num(one: PlusOne<Zero>) = 1
@pakoito
pakoito / lwo.kt
Last active Jan 17, 2018
Lightweight Option
View lwo.kt
inline fun <A, B> A?.fold(crossinline fn: () -> B, crossinline f: (A) -> B): B =
if (this == null) fn() else f(this)
inline fun <A, B> A?.map(crossinline f: (A) -> B): B? = fold({ null }, f)
inline fun <A> A?.orElse(crossinline fn: () -> A): A = fold(fn, { it })
View KECS.hs
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}
data family Component a :: *
data instance Component Health = HealthC
data instance Component Stamina = StaminaC
View Advanced-FP-with-Scala.md

Advanced Functional Programming with Scala - Notes

Copyright © 2017 Fantasyland Institute of Learning. All rights reserved.

1. Mastering Functions

A function is a mapping from one set, called a domain, to another set, called the codomain. A function associates every element in the domain with exactly one element in the codomain. In Scala, both domain and codomain are types.

val square : Int =&gt; Int = x =&gt; x * x
View ECS
data ComponentR a = ComponentR
{ entity :: EntityId
, info :: InfoR a
}
data InfoR a = InfoR
{ get :: a
}
data World = World
@pakoito
pakoito / ChainableEx.kt
Created Feb 19, 2017
Chainable example
View ChainableEx.kt
interface Chainable
inline fun <T : Chainable, U: Chainable> T.andThen(func: (T) -> U): U = func(this)
data class UserInfo(val id: String)
data class UserInfoDto(var id: String?)
sealed class ViewState : Chainable {
class Idle : ViewState()
@pakoito
pakoito / HeadlessDevelopmentInFullyReactiveApps.kt
Last active Apr 14, 2017
Headless Development in Fully Reactive Apps
View HeadlessDevelopmentInFullyReactiveApps.kt
/*
* Copyright (c) pakoito 2017
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@pakoito
pakoito / TurismoEnUK.txt
Last active Aug 24, 2019
Turismo en UK
View TurismoEnUK.txt
LONDON
===
South Bank
Millenium Bridge
Blackfriars Bridge
Tower Bridge
Tower of London
Trafalgar Square
Rascacielos de Bank y Shoredich
Soho
@pakoito
pakoito / gist:22a2ec849ff7e846566f36d5fc4a9d95
Last active Jan 22, 2017
Designing function returns on generic programming
View gist:22a2ec849ff7e846566f36d5fc4a9d95
## What does this function return?
Is it coupled in time? Is it synchronous?
YES
How many results are there?
NONE