Skip to content

Instantly share code, notes, and snippets.

@dacr
dacr / index.md
Last active April 20, 2024 13:35
David's programming examples knowledge base / published by https://github.com/dacr/code-examples-manager #fecafeca-feca-feca-feca-fecafecafeca/211658a4b67b6bf297ce7b4351a7080d22b50ad3

David's programming examples knowledge base

akka-pekko

@pchiusano
pchiusano / list.u
Created August 5, 2019 21:09
Some list functions for Unison, scratch file log
-- X filter
-- -- maybe some tests with List.all and List.any
--
-- intersperse
-- X head
-- X isEmpty
-- X tail
-- X init
-- X last
@Daenyth
Daenyth / 1-MapTraverse.md
Last active March 29, 2024 16:35
Scala (cats) map/traverse parallels

Parallels between map and similar functions

map          :: F[A] => (A =>     B)   => F[B]
flatMap      :: F[A] => (A =>   F[B])  => F[B]
traverse     :: G[A] => (A =>   F[B])  => F[G[B]]
flatTraverse :: G[A] => (A => F[G[B]]) => F[G[B]]
traverse_    :: F[A] => (A =>   F[B])  => F[Unit]
@BalmungSan
BalmungSan / Polymorphism.md
Last active January 7, 2024 18:41
Polymorphism in Scala.

Polymorphism in Scala.

This document aims to show and compare three alternatives for achieving polymorphism in Scala.

  • Subtyping, common in object-oriented languages like Java.
  • Duck typing, common in dynamically typed languages like Python.
  • Typeclasses, common in functional languages like Haskell.

Additionally, when implementing the typeclass pattern in Scala,

@mathiasverraes
mathiasverraes / MonoidalFizzBuzz.hs
Created November 16, 2016 16:21
Extensible Monoidal FizzBuzz in Haskell
module MonoidalFizzBuzz where
import Data.Monoid
import Data.Maybe
-- based on @mittie https://twitter.com/mittie/status/798257339736453120
monoidalFizzbuzz = zipWith fromMaybe numbers strings
where
fizzes = cycle [Nothing, Nothing, Just "Fizz"]
buzzes = cycle [Nothing, Nothing, Nothing, Nothing, Just "Buzz"]

Applied Functional Programming with Scala - Notes

Copyright © 2016-2018 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 => Int = x => x * x
@jeroenvdgulik
jeroenvdgulik / Talklist.md
Last active December 17, 2023 19:04
My mostly incomplete list of memorable talks that should probably be required material

The list is now hosted on a repository so you can PR -> https://github.com/jeroenvdgulik/awesome-talks/blob/master/README.md

The list

@subfuzion
subfuzion / curl.md
Last active May 9, 2024 18:17
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@danieldietrich
danieldietrich / Monads.md
Last active January 15, 2018 15:03
Monads in Javaslang

Monad Laws

Let

  • A, B, C be types
  • unit: A -> Monad<A> a constructor
  • f: A -> Monad<B>, g: B -> Monad<C> functions
  • a be an object of type A
  • m be an object of type Monad<a>
@tpolecat
tpolecat / gist:7401433
Last active August 29, 2020 08:00
set is not a functor mkay
scala> case class Bad(a: Int) { override def equals(a:Any) = true }
scala> val f = (n:Int) => Bad(n)
scala> val g = (b:Bad) => b.a
...
scala> Set(1,2,3).map(f andThen g)
res2: scala.collection.immutable.Set[Int] = Set(1, 2, 3)
scala> Set(1,2,3).map(f).map(g)