Skip to content

Instantly share code, notes, and snippets.

View Softsapiens's full-sized avatar

Daniel Pous Montardit Softsapiens

View GitHub Profile
@zhangchiqing
zhangchiqing / flatMap.js
Last active July 16, 2016 22:15
flatMap.js
/*
* flatMap can be implemented in terms of flatten and map
* which can be implemented using reduce
*/
'use strict';
// > reduce(function(sum, value) { return sum + value; },
// . 0, [1,2,3])
// 6
var reduce = function(iter, initial, arr) {

This is unmaintained, please visit Ben-PH/spacemacs-cheatsheet

Useful Spacemacs commands

  • SPC q q - quit
  • SPC w / - split window vertically
  • SPC w - - split window horizontally
  • SPC 1 - switch to window 1
  • SPC 2 - switch to window 2
  • SPC w c - delete current window
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
import Control.Monad.IO.Class
import Control.Monad.Trans.Class
import Prelude hiding (log)
--------------------------------------------------------------------------------
-- The API for cloud files.
class Monad m => MonadCloud m where
saveFile :: Path -> Bytes -> m ()
module Test.Main where
import Prelude (Applicative, Apply, Functor, Show, Unit(), (<*>), (<>), (<$>), ($), (<<<), id, bind, map, pure, return, unit)
import Control.Applicative.Free (FreeAp(), NaturalTransformation(), liftFreeAp, foldFreeAp)
import Control.Apply (lift2)
import Control.Monad.Eff (Eff())
import DOM (DOM())
import DOM.Node.Types (Element())
@non
non / half.scala
Last active June 10, 2022 03:11
Scala implementation of 16-bit floating point numbers. Also, a test prgoram.
package half
import scala.math.{pow, round, signum}
import scala.util.Random.nextInt
import java.lang.{Float => JFloat}
/**
* Float16 represents 16-bit floating-point values.
*
* This type does not actually support arithmetic directly. The
@gigiigig
gigiigig / auxpattern.scala
Last active November 3, 2025 12:17
Aux Pattern
import shapeless._
import scalaz._
import Scalaz._
object console extends App {
trait Foo[A] {
type B
def value: B
@CMCDragonkai
CMCDragonkai / higher_kinded_types_in_rust_and_haskell.md
Last active March 31, 2026 18:51
Rust/Haskell: Higher-Kinded Types (HKT)

Rust/Haskell: Higher-Kinded Types (HKT)

A higher kinded type is a concept that reifies a type constructor as an actual type.

A type constructor can be thought of in these analogies:

  • like a function in the type universe
  • as a type with a "hole" in it
@ohanhi
ohanhi / frp.md
Last active May 7, 2026 01:30
Learning FP the hard way: Experiences on the Elm language

Learning FP the hard way: Experiences on the Elm language

by Ossi Hanhinen, @ohanhi

with the support of Futurice 💚.

Licensed under CC BY 4.0.

Editorial note

@raichoo
raichoo / gist:4d88028301b452818267
Last active August 29, 2015 14:22
Polynomial functors, initial algebras and catamorphisms
{-# LANGUAGE PatternSynonyms #-}
module Polynomial where
import Prelude hiding (Maybe(..))
class Bifunctor f where
bimap :: (a -> b) -> (c -> d) -> f a c -> f b d
instance Bifunctor (,) where
bimap f g (x, y) = (f x, g y)
@filippovitale
filippovitale / FreeConsole
Last active June 4, 2021 06:09
FreeConsole – Simplest end to end example of Coyoneda and Free Monad in Scala
import scalaz.effect.IO
import scalaz.std.function._
import scalaz.{Coyoneda, Free, Monad, State, ~>}
object NonFunctor extends App {
// my simple algebra
sealed trait Console[A]
case class PrintLine(msg: String) extends Console[Unit]
case object ReadLine extends Console[String]