Skip to content

Instantly share code, notes, and snippets.

View Heimdell's full-sized avatar
🔨
Right tool for the right job

Андреев Кирилл Heimdell

🔨
Right tool for the right job
  • Ульяновск
View GitHub Profile
@Heimdell
Heimdell / Bind.hs
Created October 19, 2022 19:14
Unifier
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE ImportQualifiedPost #-}
{-# LANGUAGE BlockArguments #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE QuantifiedConstraints #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE UndecidableInstances #-}
@Heimdell
Heimdell / Lexer.hs
Last active October 17, 2022 08:25
{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-}
{-# HLINT ignore "Redundant multi-way if" #-}
{-# LANGUAGE ApplicativeDo #-}
{-# LANGUAGE BlockArguments #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE ImportQualifiedPost #-}
{-# LANGUAGE InstanceSigs #-}
{-# LANGUAGE LambdaCase #-}
{- | Source of fresh names.
-}
module Gensym where
data T s v = Gensym
{ gState :: s
, gStep :: s -> (v, s)
}
@Heimdell
Heimdell / Fixpoint.hs
Created July 16, 2022 21:15
Unification ex-di
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE BlockArguments #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE DeriveFoldable #-}
module AST where
import Data.Text qualified as Text
import Data.Text (Text)
import Data.Scientific
data Module = Module QName [Import] [Toplevel]
data Import = Import
{ from :: [Name]
module Color where
type Color = (Int, Int)
toCode :: Color -> String
toCode (hue, -1) = show (30 + hue) ++ ";2"
toCode (hue, 0) = show (90 + hue)
toCode (hue, 1) = show (30 + hue) ++ ";1"
toCode c = error $ "toCode: should be (0..16 (15?), -1.. 1), but it is " ++ show c
@Heimdell
Heimdell / roll.hs
Last active July 30, 2021 17:08
Create new haskell package _fast_
#!/usr/bin/env stack
-- stack --resolver lts-17.14 script
{-# language LambdaCase #-}
import System.Environment
import System.Directory
import System.FilePath
main = do
using System;
using System.Collections.Generic;
// For clarity. In haskell, standard Dictionary is called "Map".
//
using Set1 = System.Collections.Generic.HashSet<int>;
using Map1 = System.Collections.Generic.Dictionary<int, System.Collections.Generic.HashSet<int>>;
class Closure {
use std::sync::Arc;
enum Octree<B, A>
{ Branch
{ preview : B
, subtrees : [Arc<Octree<B, A>>; 8]
}
, Atom
{ leaf : A
{- | A chunk of 16x16x16 atoms.
-}
module Chunk where
import Prelude hiding (read)
import Control.Monad
import Control.Monad.Primitive