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 Monad[M[_]] { | |
def pure[A](a: A): M[A] | |
def flatMap[A, B](m: M[A])(f: A => M[B]): M[B] | |
} | |
enum MyOption[+T]: | |
case None | |
case Some(value: T) | |
given Monad[MyOption] with |
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
case class IO[A](unsafeRun: () => A): | |
def map[B](f: A => B): IO[B] = | |
IO(() => f(unsafeRun())) | |
def flatMap[B](f: A => IO[B]): IO[B] = | |
IO(() => f(unsafeRun()).unsafeRun()) | |
val io: IO[Int] = IO(() => { | |
println("Running side effect!!!") |
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
package org.example; | |
import java.util.Optional; | |
import java.util.Random; | |
import java.util.function.Supplier; | |
class NPEChecked extends Exception implements Supplier<NPEChecked> { | |
private static final NPEChecked instance = new NPEChecked(); | |
@Override |
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 Currency | |
case object Dollar extends Currency | |
case object Euro extends Currency | |
case class Money[T <: Currency](value: Int, currency: T) { | |
def +(that: Money[T]): Money[T] = { | |
Money[T](this.value + that.value, currency) | |
} | |
} |
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
{-# LANGUAGE GeneralizedNewtypeDeriving #-} | |
module Main where | |
newtype USD = USD Int deriving (Show, Num) | |
newtype EUR = EUR Int deriving (Show, Num) | |
main :: IO () | |
main = do | |
print $ (USD 12) + (USD 11) |
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
{-# LANGUAGE FlexibleContexts #-} | |
{-# LANGUAGE QuasiQuotes #-} | |
module Lib | |
( run | |
) where | |
import Text.Regex.PCRE.Heavy | |
newtype Word' = |
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
# This file is responsible for configuring your application | |
# and its dependencies with the aid of the Mix.Config module. | |
use Mix.Config | |
config :kafka_ex, | |
# a list of brokers to connect to in {"HOST", port} format | |
brokers: [ | |
{"localhost", 9092} | |
], | |
# the default consumer group for worker processes, must be a binary (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
/* | |
* Copyright (C) 2015 Jared Rummler <jared.rummler@gmail.com> | |
* | |
* 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 |
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
javascript:(function(fontUrl,font,style){if(location.protocol==='https:'){fontUrl='https://lucho-yankov.github.io/assets/fonts/SansBullshitSans.ttf'}else{fontUrl='http://dailyffs.com/sansbullshitsans/SansBullshitSans.ttf';}font='@font-face{font-family:SansBullshitSans;src:url('+fontUrl+');font-weight:normal}';style=document.createElement('style');style.innerHTML=font+'*{font-family:SansBullshitSans;font-feature-settings:\'liga\',\'dlig\';font-variant-ligatures:common-ligatures;}';document.head.appendChild(style);}()); |
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
config_dict = { | |
'group1': { | |
'server1': { | |
'apps': ('nginx', 'mysql'), | |
'cpus': 4 | |
}, | |
'maintenance': True | |
}, | |
'firewall_version': '1.2.3', | |
'python2.7': True |
NewerOlder