This file contains hidden or 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 DataKinds #-} | |
{-# LANGUAGE DeriveGeneric #-} | |
{-# LANGUAGE FlexibleContexts #-} | |
{-# LANGUAGE FlexibleInstances #-} | |
{-# LANGUAGE MultiParamTypeClasses #-} | |
{-# LANGUAGE TypeApplications #-} | |
{-# LANGUAGE TypeFamilies #-} | |
{-# LANGUAGE TypeOperators #-} | |
module Main (main, values) where |
This file contains hidden or 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
/** | |
* We declare a package-level function main which returns Unit and takes | |
* an Array of strings as a parameter. Note that semicolons are optional. | |
*/ | |
fun main() { | |
val tree = Node( | |
1, | |
listOf( | |
Node( |
This file contains hidden or 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 has_range (α : Type) := | |
(range : α → α → list α) | |
infix `..`:50 := has_range.range | |
instance : has_range ℕ := | |
{ range := λ a b, (+ a) <$> list.range (b + 1 - a) } | |
instance : has_range char := | |
{ range := λ a b, char.of_nat <$> (a.to_nat .. b.to_nat) } |
This file contains hidden or 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
def parser (α : Type) := | |
list char → list (list char × α) | |
namespace parser | |
variables {α β : Type} | |
protected def pure (value : α) : parser α := | |
λ input, [⟨input, value⟩] | |
protected def bind (p : parser α) (f : α → parser β) : parser β := |
This file contains hidden or 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
import data.buffer data.dlist system.io | |
def parser (α : Type) := | |
∀ (input : char_buffer) (start : ℕ), list (ℕ × α) | |
namespace parser | |
variables {α β : Type} | |
protected def pure (value : α) : parser α := | |
λ input pos, [⟨pos, value⟩] |
This file contains hidden or 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
import system.io | |
namespace parser | |
def guess (α) := | |
list char × α | |
namespace guess | |
variables {α β : Type} | |
def map (f : α → β) : guess α → guess β |
This file contains hidden or 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 AllowAmbiguousTypes #-} | |
{-# LANGUAGE DataKinds #-} | |
{-# LANGUAGE PolyKinds #-} | |
{-# LANGUAGE ScopedTypeVariables #-} | |
{-# LANGUAGE TypeApplications #-} | |
{-# LANGUAGE TypeOperators #-} | |
{-# LANGUAGE UndecidableInstances #-} | |
module Data.Aeson.GenericFields (type (<?>)) where |
This file contains hidden or 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 TypeApplications #-} | |
module Main where | |
import Control.Concurrent.Async (forConcurrently) | |
import Control.Lens hiding ((.=)) | |
import Control.Monad (void) | |
import Data.Aeson (FromJSON (..), ToJSON (..), Value (..), decode, withObject, (.:), (.=)) | |
import Data.Function (on) | |
import Data.Generics.Labels () |
This file contains hidden or 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
{ withHoogle ? false, forceShell ? false }: | |
# A tutorial on Nix, and how you can use 'developPackage' to override | |
# dependencies: | |
# https://www.srid.ca/1948201.html | |
let | |
pkgs = let | |
# You can get a newer ref by looking under "nixpkgs-unstable" in https://status.nixos.org/ | |
nixpkgsRev = "01ed700247e1"; | |
nixpkgsSha = "0sdcb536hrkimvnd55kzkx3ybasp3y1cbijxc2bncnkgzn2rw57k"; | |
in import (builtins.fetchTarball { |
This file contains hidden or 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 AllowAmbiguousTypes #-} | |
{-# LANGUAGE RankNTypes #-} | |
{-# LANGUAGE ScopedTypeVariables #-} | |
{-# LANGUAGE TypeApplications #-} | |
import Unsafe.Coerce | |
class ToString a where | |
toString :: a -> String | |
tag :: String |