Skip to content

Instantly share code, notes, and snippets.

View phadej's full-sized avatar
🦉
Someone here is possessed by an owl. Who?

Oleg Grenrus phadej

🦉
Someone here is possessed by an owl. Who?
View GitHub Profile
import Data.Coerce
import Data.Monoid
-- This combinator is based on ala' from Conor McBride's work on Epigram.
alaf :: (Coercible n o, Coercible n' o')
=> (o -> n) -> ((a -> n) -> b -> n') -> (a -> o) -> b -> o'
alaf _ = coerce
myfoldl :: Foldable t => (b -> a -> b) -> b -> t a -> b
myfoldl f z xs = alaf (Dual . Endo) foldMap (flip f) xs z
From 9f72a94762e730da15ada2147cd5a6ccb4f90406 Mon Sep 17 00:00:00 2001
From: Oleg Grenrus <oleg.grenrus@iki.fi>
Date: Thu, 30 Dec 2021 21:04:11 +0200
Subject: [PATCH] PoC RecordDot
---
compiler/GHC/Driver/Session.hs | 3 ++
compiler/GHC/Hs/Expr.hs | 2 +-
compiler/GHC/HsToCore/Expr.hs | 4 +-
compiler/GHC/Parser/Lexer.x | 14 ++---
import Debug.Trace (traceM)
import Data.String (IsString (..))
-- $setup
-- >>> :set -XOverloadedStrings
-- | A formatter.
--
-- The power of simple Haskell.
--
Only in DBFunctor-0.1.2.1: cabal.project
Only in DBFunctor-0.1.2.1: dist-newstyle
Only in DBFunctor-0.1.2.1: .ghc.environment.x86_64-linux-8.6.5
diff -ur orig/DBFunctor-0.1.2.1/src/RTable/Core.hs DBFunctor-0.1.2.1/src/RTable/Core.hs
--- orig/DBFunctor-0.1.2.1/src/RTable/Core.hs 2021-05-23 18:03:12.000000000 +0300
+++ DBFunctor-0.1.2.1/src/RTable/Core.hs 2021-10-28 00:00:45.265149734 +0300
@@ -818,11 +818,6 @@
-- anything else is just False
_ == _ = False
@phadej
phadej / Mokhov.agda
Created July 1, 2021 08:56
Mokhov is (at least) skew monoidal product, see https://arxiv.org/pdf/1201.4981.pdf
{-# OPTIONS --cubical --type-in-type #-}
module Mokhov where
open import Cubical.Foundations.Everything
open import Cubical.Data.Sum
open import Cubical.Data.Prod
open import Cubical.Data.Unit
record Mokhov (F : Set → Set) (G : Set → Set) (A : Set) : Set where
constructor mokhov
data Mokhov2 f g a where
Mokhov2 :: (x -> Either a (y -> a)) -> f x -> g y -> Mokhov2 f g a
toMokhov2 :: Mokhov f g a -> Mokhov2 f g a
toMokhov2 (x :<*?: y) = Mokhov2 f y x where
f :: (x -> a) -> Either a (Either x a -> a)
f xa = Right $ either xa id
fromMokhov2 :: (Functor f, Functor g) => Mokhov2 f g a -> Mokhov f g a
fromMokhov2 (Mokhov2 f x y) =
-- Selective
class Applicative f => Selective f where
select :: f (Either a b) -> f (a -> b) -> f b
apS :: Selective f => f (a -> b) -> f a -> f b
apS f x = select (Left <$> f) ((&) <$> x)
-- Free Selective
data Select f a where
Pure :: a -> Select f a
{-# LANGUAGE TypeFamilies, RankNTypes #-}
import Data.Kind
import Data.Coerce
import Data.Functor.Identity
import Data.Proxy
import Data.Void
-- from hkd package, for FFunctor
import Data.HKD
{-# LANGUAGE DataKinds, PolyKinds #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE EmptyCase #-}
{-# LANGUAGE TypeOperators #-}
{-# OPTIONS -Wall -Wno-unticked-promoted-constructors #-}
import qualified Control.Category as C
-- It's all paths...
From 99908846a224e73ef7322604048dd21a22dbbcfb Mon Sep 17 00:00:00 2001
From: Oleg Grenrus <oleg.grenrus@iki.fi>
Date: Fri, 16 Apr 2021 19:40:18 +0300
Subject: [PATCH] WIP: make basement,memory,cryptonite dependency optional
Few tests don't pass. I probably screwed something in Dhall.Crypto
(those functions don't have tests and it's all ByteStrings, so
maybe I convert to wrong bytes somewhere).
cryptohash-sha256 needs base relaxation too,