Skip to content

Instantly share code, notes, and snippets.

View mvaldesdeleon's full-sized avatar

Martín Valdés de León mvaldesdeleon

View GitHub Profile
let g:ale_fix_on_save = 1
let g:ale_fixers['haskell'] = ['hfmt']
let g:ale_linters = {
\ 'haskell': ['ghc', 'hlint'],
\}
nmap <silent> <Leader>< <Plug>(ale_previous_wrap)
nmap <silent> <Leader>> <Plug>(ale_next_wrap)
nmap <silent> <Leader>? <Plug>(ale_detail)
@mvaldesdeleon
mvaldesdeleon / .gitignore
Created November 13, 2018 21:35
gitignore all the things (...)
# See http://help.github.com/ignore-files/ for more about ignoring files.
# IDEs and editors
.idea/*
**/.idea/*
!.idea/codeStyleSettings.xml
!.idea/watcherTasks.xml
.project
.classpath
.c9/
function mapCompose<A, B, C>(mab: Map<A, B>, mbc: Map<B, C>): Map<A, C> {
const mac: Map<A, C> = new Map();
mab.forEach((value, key) => {
const finalValue = mbc.get(value);
if (finalValue !== undefined) {
mac.set(key, finalValue);
}
});
asInt :: String -> Either String Int
asInt ('-':xs) = negate <$> asInt xs
asInt xs =
foldl
(\acc x -> acc >>= addNextDigit x)
(Right 0)
xs
where addNextDigit x acc = if isDigit x
then Right $ acc * 10 + digitToInt x
else Left $ "non-digit"
// -- EXAMPLE THAT WOULD BE WRONG
// -- wrongBurgerSpec :: IxBurgerBuilder Ready TopBunOn BurgerSpec
// -- wrongBurgerSpec = getEmptyPlate
// -- :>>= placeEmptyBun
// -- :>>= addKetchup
// -- :>>= addCheese -- Can't match PattyOn with BottomBunOn, since we haven't put on the patty, the most important part!!!
// -- :>>= addOnions
// -- :>>= noLettuce
// -- :>>= addTomato
// -- :>>= addTopBun
// -- OUR AMAZING INDEXED BURGER SPEC FROM READY TO TOP BUN ON
// burgerSpec :: IxBurgerBuilder Ready TopBunOn BurgerSpec
// burgerSpec = getEmptyPlate
// :>>= placeEmptyBun
// :>>= addKetchup
// :>>= addPatty
// :>>= addCheese
// :>>= addOnions
// :>>= noLettuce
// :>>= addTomato
// getEmptyPlate :: IxBurgerBuilder Ready EmptyPlate BurgerSpec
// getEmptyPlate = IxBurgerBuilder mempty
const getEmptyPlate = new IxBurgerBuilder<Ready, EmptyPlate, BurgerSpec>([]);
// addIngredient :: forall i o. String -> BurgerSpec -> IxBurgerBuilder i o (BurgerSpec)
// addIngredient x xs = IxBurgerBuilder $ Ingredient x : xs
const addIngredient = <I, O>(s: string) => (spec: BurgerSpec) => new IxBurgerBuilder<I ,O, BurgerSpec>(spec.concat([s]));
// -- ADDING THE BUN
// placeEmptyBun :: BurgerSpec -> IxBurgerBuilder EmptyPlate BottomBunOn BurgerSpec
import { Functor3 } from 'fp-ts/lib/Functor'
import { IxMonad3 } from 'fp-ts/lib/IxMonad';
declare module 'fp-ts/lib/HKT' {
// IxBurgerBuilder :: * -> * -> * -> *
interface URI2HKT3<U, L, A> {
IxBurgerBuilder: IxBurgerBuilder<U, L, A>
}
}
// data Ready
// data EmptyPlate
// data BottomBunOn
// data PattyOn
// data CheeseOn
// data OnionOn
// data LettuceOn
// data TomatoOn
// data PicklesOn
// data TopBunOn
interface Boring {
bore: () => boolean
}
interface Fooable<A> {
foo: () => string,
unfoo: (s: string) => A
}
interface Barable<A> {