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
#!/bin/sh | |
## Or use an AUR helper, e.g. | |
## sudo aura -A nix | |
sudo pacman -S base-devel git | |
git clone https://aur.archlinux.org/nix.git | |
cd nix | |
makepkg -s | |
sudo pacman -U nix-*.pkg.tar.xz |
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 FlexibleInstances #-} | |
{-# LANGUAGE DeriveFoldable #-} | |
import Data.Foldable | |
class GetKeys a where | |
getKeys :: a -> [Char] | |
instance Foldable t => GetKeys (t Char) where | |
getKeys = toList |
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 TupleSections #-} | |
import Control.Lens | |
data Expr | |
= Var String | |
| App Expr Expr | |
| Lam String Expr | |
deriving Show |
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 SizedExample where | |
open import Data.List using (List; []; _∷_) | |
open import Data.Product using (_×_; proj₁; proj₂) | |
open import Size using (Size; Size<_) | |
record Stream (i : Size) (A : Set) : Set where | |
coinductive | |
field | |
head : A |
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 IO.Primitive as Prim | |
open import Coinduction | |
open import Data.Unit | |
open import IO | |
cat : IO ⊤ | |
cat = ♯ getContents >>= (\cs → ♯ (putStr∞ cs)) |
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 IO.Primitive as Prim | |
open import Data.Unit | |
open import IO | |
open import Coinduction | |
nonTerminatingIO : IO ⊤ | |
nonTerminatingIO = ♯ nonTerminatingIO >> ♯ return tt |
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 scalaz | |
import java.net.{ InetSocketAddress, StandardSocketOptions } | |
import java.nio.ByteBuffer | |
import java.nio.channels.{ AsynchronousFileChannel, AsynchronousServerSocketChannel, AsynchronousSocketChannel, CompletionHandler } | |
import java.nio.charset.StandardCharsets.UTF_8 | |
import java.nio.charset.{ Charset, CharsetEncoder } | |
import java.nio.file.{ Path, OpenOption, StandardOpenOption } | |
import java.util.Date |
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
object Example { | |
@inline final def id[A](a: A): A = | |
a | |
final def example1: List[Int] = | |
Nil | |
final def example2: List[Int] = | |
id(Nil) |
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
class Witness[A, B >: A] { | |
@inline final def apply(a: A): B = a | |
} | |
object Witness { | |
final val example: List[Int] = | |
(new Witness[List[Nothing], List[Int]])(Nil) | |
} | |
// scalac -Yinline -optimise Witness.scala |
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 Nat { | |
def isZero: Boolean | |
def pred: Nat | |
@annotation.tailrec final def countDown(xs: List[Nat]): List[Nat] = { | |
val next: List[Nat] = | |
this :: xs | |
if (isZero) | |
next | |
else |