Skip to content

Instantly share code, notes, and snippets.

😀
Working on open source

Piotr Paradziński lemastero

😀
Working on open source
  • Scalac
  • Lublin
View GitHub Profile
@lemastero
lemastero / ProfunctorOpticsCategoricalUpdate.hs
Created Jan 26, 2020
Profunctor optics, a categorical update - Bryce Clarke, Derek Elkins, Jeremy Gibbons, Fosco Loregian, Bartosz Milewski, Emily Pillmore, Mario Román
View ProfunctorOpticsCategoricalUpdate.hs
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE QuantifiedConstraints #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeOperators #-}
@lemastero
lemastero / haginoGen.hs
Created Dec 9, 2019 — forked from sjoerdvisscher/haginoGen.hs
Categorical Data Types ala Hagino in 2 different ways
View haginoGen.hs
{-# LANGUAGE RankNTypes, GADTs #-}
import Data.Functor.Adjunction
import Data.Functor.Identity
import Data.Functor.Product
import Data.Functor.Const
newtype Left f g = L (forall l. (f l -> g l) -> l)
cata :: (f a -> g a) -> Left f g -> a
@lemastero
lemastero / Cotra.hs
Created Nov 28, 2019 — forked from sjoerdvisscher/Cotra.hs
Cofree traversable functor
View Cotra.hs
{-# LANGUAGE GADTs #-}
import Data.Functor.HCofree
import Data.Vec.Lazy
import Data.Fin
import Data.Type.Nat
data Cotra f a where
Cotra :: SNat n -> f (Fin n) -> Vec n a -> Cotra f a
to :: Functor f => Cotra f a -> HCofree Traversable f a
View Unsoundness.scala
import scala.language.existentials
class A { class E }
class B extends A { class E }
trait CD { type E }
trait C extends CD { type E = Int }
trait D extends CD { type E = String }
object Test {
type EE[+X <: { type E }] = X#E
@lemastero
lemastero / algebra.v
Created Oct 5, 2019 — forked from andrejbauer/algebra.v
Uinversal algebra in Coq
View algebra.v
(* An initial attempt at universal algebra in Coq.
Author: Andrej Bauer <Andrej.Bauer@andrej.com>
If someone knows of a less painful way of doing this, please let me know.
We would like to define the notion of an algebra with given operations satisfying given
equations. For example, a group has of three operations (unit, multiplication, inverse)
and five equations (associativity, unit left, unit right, inverse left, inverse right).
*)
@lemastero
lemastero / ProfunctorBifunctorHierarchy.scala
Created May 13, 2019
Profunctor and Bifunctor can be expressed using 3 more basic abstractions. This nicely split organise laws for them.
View ProfunctorBifunctorHierarchy.scala
import scala.language.higherKinds
trait LeftContravariant[F[_,_]] {
def contramap[A,AA,B](fa: F[A,B])(f: AA => A): F[AA,B]
}
trait RightCovariant[F[_,_]] {
def map[A,B,BB](fa: F[A,B])(g: B => BB): F[A,BB]
}
@lemastero
lemastero / ModularCategoryTheory.scala
Created May 13, 2019
Modular approach to abstractions from Category Theory
View ModularCategoryTheory.scala
import Wizard.ConstUnit
import Wizard.Id
import scala.language.higherKinds
/*
Are there any constructions in Category Theory something like:
Given:
C category
@lemastero
lemastero / WordsAboutNothingAndAny.scala
Last active Jan 28, 2019
What we say when we say F.. Yea! or F... No!
View WordsAboutNothingAndAny.scala
import scalaz.{Comonad, Monad}
import scalaz.{Arrow, Contravariant, Profunctor}
import scalaz.{Lan, Ran}
object AnyAndNothingInstances {
// Monad
// https://twitter.com/runarorama/status/1085383309969014784
type FYea[A] = Any
@lemastero
lemastero / ttg.hs
Created Jan 28, 2019 — forked from tonymorris/ttg.hs
Trees That Grow
View ttg.hs
{-# OPTIONS_GHC -Wall #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE StandaloneDeriving #-}
@lemastero
lemastero / Sudoku.hs
Created Jan 3, 2019 — forked from danoneata/Sudoku.hs
Applicative-based Sudoku solver
View Sudoku.hs
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
import Control.Applicative
import Data.Char
import Data.List (intersperse)
import Data.Monoid hiding (All, Any)
import Data.Foldable hiding (all, any)
import Prelude hiding (all, any)
You can’t perform that action at this time.