This file contains 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
trait Functor[F[_]] { | |
def map[A,B](fa: F[A])(f: A => B): F[B] | |
} | |
// For lifting pure values into effects and to chain effects | |
trait Monad[F[_]] extends Functor[F] { | |
def pure(x: A): F[A] | |
def flatMap[A, B](fa: F[A])(f: A => F[B]): F[B] | |
// map can now be defined in terms of pure and flatten so Monad is a functor | |
} |
This file contains 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
-- Natural Numbers | |
data Nat = Zero | Succ Nat | |
instance Show Nat where | |
show Zero = "Zero" | |
show (Succ m) = printf "Succ (%s)" (show m) | |
nat2int :: Nat -> Int | |
nat2int Zero = 0 |
This file contains 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 Main where | |
import Lib | |
import Data.Char | |
import Prelude | |
import Text.Printf | |
main :: IO () | |
main = someFunc |
This file contains 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
trait Service { | |
def sendMessage(msg: String, recv: String): Unit | |
} | |
class SMSService extends Service { | |
def sendMessage(msg: String, recv: String) = | |
println(s"SMS sent to ${recv} containing ${msg}") | |
} | |
class EmailService extends Service { | |
def sendMessage(msg: String, recv: String) = | |
println(s"Email sent to ${recv} containing ${msg}") |
This file contains 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
sealed trait Direction | |
case object Horizontal extends Direction | |
case object Vertical extends Direction | |
object Direction { | |
def random(): Direction = | |
if (Math.random() < 0.5) | |
Horizontal | |
else | |
Vertical |
This file contains 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
set expandtab | |
set shiftwidth=2 | |
set softtabstop=2 | |
set hlsearch | |
set wildignore+=*/node_modules/* | |
set wildignore+=*/dist/* | |
set wildignore+=*/build/* | |
set listchars=tab:▸\ ,eol:¬,trail:▫ | |
set encoding=utf-8 |
This file contains 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
dashboard "Food": | |
- h1 text: Food | |
- h2 text: By caloric content | |
- 3 columns: | |
- rows: | |
- h3 text: Bananas | |
- pie chart: { | |
"columns": [ | |
["Protein", 5], ["Sugar", 10], ["Other carbs", 40], ["Fat", 1] | |
] |
This file contains 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
#!/usr/bin/env node | |
console.log("Say hello"); |
This file contains 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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <assert.h> | |
#include <string.h> | |
#define MAX 100 | |
#define EXIT_CHOICE 10 | |
#define USERS_FILE "users.txt" | |
#define BOOKS_FILE "books.txt" |
This file contains 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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <assert.h> | |
#include <string.h> | |
#define MAX 100 | |
#define EXIT_CHOICE 10 | |
#define USERS_FILE "users.txt" | |
#define BOOKS_FILE "books.txt" |
NewerOlder