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
import io | |
import os | |
import pathlib | |
from dotenv import load_dotenv | |
from google.cloud import storage | |
from google.oauth2 import service_account | |
from zipfile import ZipFile, ZipInfo | |
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
type Validation<'a, 'e> = | |
| Success of 'a | |
| Failure of 'e | |
module Validation = | |
let map f ma = | |
match ma with | |
| Success a -> Success (f a) | |
| Failure e -> Failure e |
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 Control.Monad.Trans.State (StateT(..), runStateT, evalStateT) | |
import Control.Monad.IO.Class (liftIO) | |
import Data.List (find) | |
import System.Exit (exitSuccess) | |
type FirstName = String | |
type LastName = String |
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
type CoinFlip = Heads | Tails | |
type Ord = LT | EQ | GT | |
let compare (a: CoinFlip) (b: CoinFlip) = | |
match a <= b with | |
| true when a = b -> EQ | |
| true -> LT | |
| _ -> GT | |
// there is a compare function already in F# Core, but it returns -1, 0, and 1 instead of LT, EQ, and GT |
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
*Main> :i Ord | |
class Eq a => Ord a where | |
compare :: a -> a -> Ordering | |
(<) :: a -> a -> Bool | |
(<=) :: a -> a -> Bool | |
(>) :: a -> a -> Bool | |
(>=) :: a -> a -> Bool | |
max :: a -> a -> a | |
min :: a -> a -> a | |
{-# MINIMAL compare | (<=) #-} |
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
public class CoinFlip | |
{ | |
public enum Coin { Heads, Tails }; | |
public Coin Result { get; } | |
public CoinFlip(Coin result) | |
{ | |
Result = result; | |
} |
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
data CoinFlip = Heads | Tails deriving (Eq, Ord) |
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
data CoinFlip = Heads | Tails | |
instance Ord CoinFlip where | |
compare Heads Tails = LT | |
compare Tails Heads = GT | |
compare _ _ = EQ |
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
data CoinFlip = Heads | Tails | |
instance Eq CoinFlip where | |
(==) Heads Heads = True | |
(==) Tails Tails = True | |
(==) _ _ = False |
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
public interface Number<T> | |
{ | |
T Add(T a, T b); | |
T Subtract(T a, T b); | |
} | |
public class Integer : Number<int> | |
{ | |
public int Add(int a, int b) => a + b; |
NewerOlder