Skip to content

Instantly share code, notes, and snippets.

var findByTitle: (String) -> (MutableList<Movie>) -> List<Movie> =
{ query -> { collection ->
val predicate = matches(query)
filter(predicate)(collection)
}}
val filter: ((Movie) -> Boolean) -> (List<Movie>) -> List<Movie> =
{ predicate -> { collection ->
collection.filter(predicate)
}}
var findByTitle: (String) -> (MutableList<Movie>) -> List<Movie> =
{ query -> { collection ->
val predicate = matches(query)
filter(predicate)(collection)
}}
val filter: ((Movie) -> Boolean) -> (List<Movie>) -> List<Movie> =
{ predicate -> { collection ->
collection.filter(predicate)
}}
@clojj
clojj / main.hs
Created October 12, 2018 20:48
InsistentLazyRedundantcode created by anonymous - https://repl.it/repls/InsistentLazyRedundantcode
gcdHaskell :: Int -> Int -> Int
gcdHaskell x y | x > y = gcdHaskell (x - y) y
| x < y = gcdHaskell x (y - x)
| otherwise = x
main = print $ gcdHaskell 4 2
@clojj
clojj / ttt.idr
Created October 13, 2017 14:35
fresh start on typed tic tac toe
module TicTacToe
import Data.Vect
data Piece = X | O | N
next : Piece -> Piece
next X = O
next O = X
next N = N
@clojj
clojj / tictactoe.idr
Last active October 12, 2017 21:05
Idris type-level tic-tac-toe
module TicTacToe
import Data.Vect
||| All possible player pieces, where N represents empty
data Piece = X | O | N
||| Select next player
next : Piece -> Piece
next X = O
module TicTacToe
import Data.Vect
||| All possible player pieces, where N represents empty
data Piece = X | O | N
||| Select next player
next : Piece -> Piece
next X = O
@clojj
clojj / compose.hs
Last active January 26, 2017 15:04
compose function from list of functions
import Data.List
compose :: [a -> a] -> a -> a
compose fs v = foldl' (flip (.)) id fs $ v
@clojj
clojj / compose-maybe-functions.hs
Last active January 26, 2017 10:40
compose list of Maybe functions
import Data.List
compose :: [Maybe (a -> a)] -> a -> a
compose fs v = foldl' compf id fs $ v
compf :: (a -> a) -> Maybe (a -> a) -> (a -> a)
compf f mg =
case mg of
Nothing -> f
Just g -> g . f
@clojj
clojj / Main.hs
Created January 21, 2017 00:42
mvc with vty
#!/usr/bin/env stack
-- stack --resolver lts-7.14 --install-ghc runghc --package vty --package pipes --package pipes-concurrency
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Graphics.Vty
import Data.Default
import Control.Monad
import System.IO
@clojj
clojj / InteroProcess.scala
Last active January 2, 2017 20:53
alternative stdio handling
package intellij.haskell.external.repl
import java.io._
import java.util.concurrent.{ConcurrentLinkedDeque, SynchronousQueue}
import com.intellij.util.EnvironmentUtil
import scala.collection.JavaConverters._
import scala.collection.mutable.{ArrayBuffer, ListBuffer}
import scala.io._