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
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
  • 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'.
@Pitometsu
Pitometsu / multiple cake-patterns.md
Created December 24, 2018 13:54 — forked from aappddeevv/multiple cake-patterns.md
scala, cake patterns, path-dependent types and composition (and a little bit of slick)

Scala and Cake Patterns and the Problem

Standard design patterns in scala recommend the cake pattern to help compose larger programs from smaller ones. Generally, for simple cake layers, this works okay. Boner's article suggests using it to compose repository and service layers and his focus is on DI-type composition. As you abstract more of your IO layers however, you realize that you the cake pattern as described does not abstract easily and usage becomes challenging. As the dependencies mount, you create mixin traits that express those dependence and perhaps they use self-types to ensure they are mixed in correctly.

Then at the end of the world, you have to mix in many different traits to get all the components. In addition, perhaps you have used existential types and now you must have a val/object somewhere (i.e. a well defined path) in order to import the types within the service so you can write your program. Existential

@Pitometsu
Pitometsu / circe_shapes.scala
Created December 19, 2018 17:08 — forked from n4to4/circe_shapes.scala
coproduct json = circe + shapeless
// https://stackoverflow.com/questions/44309520/my-coproduct-encoding-is-ambiguous
import io.circe._, io.circe.generic.semiauto._
import io.circe.shapes._, io.circe.syntax._
import shapeless._, shapeless.union._, shapeless.syntax.singleton._
object Main extends App {
object model {
case class A(a: String)
case class B(a: String, i: Int)
@Pitometsu
Pitometsu / gist:eef5ae6583339f658a9e9ef38eb933e8
Created August 21, 2018 21:35 — forked from dacr/gist:4642782
Custom scala collection examples
import scala.collection._
import scala.collection.mutable.{ArrayBuffer,ListBuffer, Builder}
import scala.collection.generic._
import scala.collection.immutable.VectorBuilder
// ================================ CustomTraversable ==================================
object CustomTraversable extends TraversableFactory[CustomTraversable] {

Advanced Functional Programming with Scala - Notes

Copyright © 2016-2017 Fantasyland Institute of Learning. All rights reserved.

1. Mastering Functions

A function is a mapping from one set, called a domain, to another set, called the codomain. A function associates every element in the domain with exactly one element in the codomain. In Scala, both domain and codomain are types.

val square : Int => Int = x => x * x
@Pitometsu
Pitometsu / Swift.md
Created May 4, 2017 13:10 — forked from briancroom/Swift.md
How to create a Swift modular library

I am trying to determine if it is possible to build a Swift dynamic library which is itself composed of one of more private modules, without needing to expose to that fact to outside users. My hope was that I could build the private module as a static library, which would be linked into the primary (dynamic) library. The dylib could then be deployed together with its swiftmodule and swiftdoc and be imported, with the private module and its symbols not being exposed at all.

Unfortunately, what I'm currently observing seems to indicate that the private module's swiftmodule also has to be available for the primary library to be successfully imported.

This can be reproduced as follows. I have the following directory structure:

./Greeter/Logger/Logger.swift:

public func log(_ message: String) {

How to inform Eclipse and other Mac applications of the command line PATH

  1. Update Mac OS X's notion of PATH.
$ defaults write ~/.MacOSX/environment PATH "`echo $PATH`"
$ echo "setenv PATH $PATH" | sudo tee /etc/launchd.conf
  1. Restart Mac OS X.
@Pitometsu
Pitometsu / Beerware License
Last active March 8, 2017 12:35 — forked from azizshamim/Beerware License
Beerware License
/*
* --------------------------------------------------------------
* "THE BEERWARE LICENSE" (Revision 42):
* <pitometsu@gmail.com> wrote this code. As long as you retain
* this notice, you can do whatever you want with this stuff. If
* we meet someday, and you think this stuff is worth it, you can
* buy me a beer in return. Yuriy Pitomets
* --------------------------------------------------------------
*/