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 / configuration.nix
Last active July 11, 2023 18:58
NixOS system config
# Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running ‘nixos-help’).
{ config, pkgs, ... }:
rec {
imports =
@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 / 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;
}
#! /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 / 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..] !!)
@Pitometsu
Pitometsu / cc-overlay.nix
Created September 13, 2019 05:58
How to override CC by Nix overlay?
(self: super:
let
# gcc = super.pkgs.gcc8;
# gcc8 = super.pkgs.gcc8.override { stdenv = super.stdenv; };
stdenv = super.stdenvAdapters.overrideCC super.stdenv super.pkgs.gcc8;
in
{
inherit stdenv; # gcc8 gcc;
# stdenv = super.overrideCC super.stdenv self.pkgs.gcc;
# gcc8 = super.gcc8.override { stdenv = super.stdenv; };