Skip to content

Instantly share code, notes, and snippets.

View Pitometsu's full-sized avatar
🐫
∀:camel:.P(:camel:) → ∅ ≡ (∃:camel:.P(:camel:)) → ∅

Yuriy Pitomets Pitometsu

🐫
∀:camel:.P(:camel:) → ∅ ≡ (∃:camel:.P(:camel:)) → ∅
View GitHub Profile
@Pitometsu
Pitometsu / Main.hs
Last active July 9, 2023 16:04
STM queue
{-# Language BlockArguments, ExplicitNamespaces, DerivingStrategies, ViewPatterns
, NoFieldSelectors, OverloadedRecordDot, DuplicateRecordFields #-}
{-# OPTIONS_GHC -main-is Main.test -Wall #-}
module Main (
Queue(push, pop, front, back, size, empty), new, onSome, test) where
import GHC.Conc (type STM, newTVar, readTVar, writeTVar, retry)
import Numeric.Natural (type Natural)
@Pitometsu
Pitometsu / Main.hs
Created July 5, 2023 18:01 — forked from lexi-lambda/Main.hs
Minimal Haskell implementation of Complete and Easy Bidirectional Typechecking for Higher-Rank Polymorphism
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
module Language.HigherRank.Main
( Expr(..)
, EVar(..)
, Type(..)
, TVar(..)
, TEVar(..)
, runInfer
) where
@Pitometsu
Pitometsu / default.nix
Last active May 29, 2023 11:59
Internet Computer development environment with dfx and mops
with import <nixpkgs> {}; with builtins; let
dfx-env = import (fetchTarball https://github.com/ninegua/ic-nix/releases/latest/download/dfx-env.tar.gz) {};
mops-nix = https://raw.githubusercontent.com/nomeata/ic-certification/3f51849073d19d2ab46aaff3c4985bf8c60196a1;
nodeEnv = import (fetchurl "${mops-nix}/mops.nix/node-env.nix") {
nodejs = nodejs-14_x;
inherit (pkgs) stdenv lib python2 runCommand writeTextFile writeShellScript;
inherit pkgs;
libtool = if pkgs.stdenv.isDarwin then pkgs.darwin.cctools else null;
};
mops = (import (fetchurl "${mops-nix}/mops.nix/node-packages.nix") {
@Pitometsu
Pitometsu / KeepitAssignment-ng.lisp
Last active May 9, 2023 02:17
A test assignment on the Common Lisp position at KeepIT.
#! /usr/bin/env sh
#|
exec nix-shell --show-trace --pure -Q -p clisp --run "clisp -q -q $0 ${1+"$@"}"
exit
|#
;; Supposed to be O(letters + total-word * log unique-words) time,
;; and slightly less then O(unique-words) space.
;; For slower but much more memory efficient version
;; alphabetical trees could be useful.
@Pitometsu
Pitometsu / pattern.hs
Created December 30, 2022 18:35
deriving via: pattern synonyms instead of GADTs
{-# Language GADTs, LambdaCase, PatternSynonyms, QuantifiedConstraints, RoleAnnotations, TypeApplications, StandaloneDeriving, DerivingVia, MultiParamTypeClasses, StandaloneKindSignatures, FlexibleInstances, DataKinds, PolyKinds, TypeFamilies, FlexibleContexts, FunctionalDependencies, ConstraintKinds, AllowAmbiguousTypes, RankNTypes, ScopedTypeVariables #-}
import Data.Kind
import Data.Coerce (type Coercible)
type MyClass :: Type -> Constraint
class MyClass t
data HtmlT m t
@Pitometsu
Pitometsu / chat.log
Created April 18, 2022 11:45
partial application
Yan Shkurinskiy, [18/4/22 8:41 AM]
foo :: Int -> Int
foo x = map fib [0..] !! x
where
fib 0 = 1
fib 1 = 1
fib n = foo (n-2) + foo (n-1)
foo :: Int -> Int
foo = (map fib [0..] !!)
#! /usr/bin/env nix-shell
#! nix-shell --show-trace --pure -Q -i "runghc --ghc-arg=-main-is --ghc-arg=Solution.main" -p "ghc.withPackages (pkgs: with pkgs; [ either text ])" -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/cf7475d2061ac3ada4b226571a4a1bb91420b578.tar.gz
-- You'll need nix to automatically download the dependencies:
-- `{ curl https://nixos.org/nix/install | sh ; } && . ~/.nix-profile/etc/profile.d/nix.sh`
{-# LANGUAGE OverloadedStrings
, PatternSynonyms #-}
import Prelude hiding (lookup)
@Pitometsu
Pitometsu / default.nix
Created November 16, 2020 11:02
./nix/channel/default.nix
let
channel = with builtins; fromJSON
(readFile ./lock);
in fetchTarball {
url = "https://github.com/NixOS/nixpkgs-channels/archive/" +
"${channel.rev}.tar.gz";
inherit (channel) sha256;
}
  • Algorithm Design with Haskell
  • Beginning Haskell: A Project-Based Approach
  • Developing Web Apps with Haskell and Yesod
  • Functional Design and Architecture
  • Get Programming with Haskell
  • Haskell Book
  • Haskell Cookbook
  • Haskell Data Analysis Cookbook
  • Haskell Design Patterns
  • Haskell from the Very Beginning
@Pitometsu
Pitometsu / Term.java
Created May 19, 2020 21:09 — forked from jbgi/Term.java
Generalized Algebraic Data Types (GADT) in Java
import static java.lang.System.*;
import java.util.function.BiFunction;
import java.util.function.Function;
// Implementation of a pseudo-GADT in Java, translating the examples from
// http://www.cs.ox.ac.uk/ralf.hinze/publications/With.pdf
// The technique presented below is, in fact, just an encoding of a normal Algebraic Data Type
// using a variation of the visitor pattern + the application of the Yoneda lemma to make it
// isomorphic to the targeted 'GADT'.