Skip to content

Instantly share code, notes, and snippets.

View kana-sama's full-sized avatar
🌚

kana kana-sama

🌚
View GitHub Profile
@kana-sama
kana-sama / 1qwe.hs
Last active February 21, 2021 11:45
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
module Main (main, values) where
/**
* 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(
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) }
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 β :=
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⟩]
import system.io
namespace parser
def guess (α) :=
list char × α
namespace guess
variables {α β : Type}
def map (f : α → β) : guess α → guess β
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
module Data.Aeson.GenericFields (type (<?>)) where
{-# 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 ()
{ 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 {
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
import Unsafe.Coerce
class ToString a where
toString :: a -> String
tag :: String