Skip to content

Instantly share code, notes, and snippets.

View cjay's full-sized avatar
😼
:suspect:

Johannes Krause cjay

😼
:suspect:
View GitHub Profile
@cjay
cjay / simplified_subsumption.hs
Created May 7, 2022 23:37
Comparison: How simplified subsumption interacts with newtype and with type aliases
{-# LANGUAGE RankNTypes #-}
import Control.Monad.Cont (MonadIO)
-- Comparison: How simplified subsumption interacts with newtype and with type aliases
-- example with type alias:
type Foo a = forall m. MonadIO m => m a
foo :: forall m a. MonadIO m => Int -> m a
@cjay
cjay / vulkan.css
Created July 1, 2021 04:24
Vulkan Spec Dark Mode
/*
For use with the Stylus browser extension, since Dark Reader is slow on the giant single page spec.
*/
html,
body,
input,
textarea,
select,
button {
@cjay
cjay / Derp.hs
Created May 1, 2021 11:53
Trying to map from a type level list to a value level list. Does not type check so far.
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE NoStarIsType #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ConstraintKinds #-}
Mon Jan 21 18:31 2019 Time and Allocation Profiling Report (Final)
day14b +RTS -p -RTS
total time = 18.53 secs (18528 ticks @ 1000 us, 1 processor)
total alloc = 46,140,950,288 bytes (excludes profiling overheads)
COST CENTRE MODULE SRC %time %alloc
generate.gen Main src/Day14b.hs:(83,3)-(91,34) 24.1 36.0
@cjay
cjay / folds.org
Last active February 27, 2019 20:01

List folds in Haskell from a use case oriented perspective

Since the definitions in Data.Foldable are too generic, here are list-specific ones:

-- foldl f z [x1, x2, ..., xn] == (...((z `f` x1) `f` x2) `f`...) `f` xn
foldl :: (b -> a -> b) -> b -> [a] -> b
foldl f z []     = z
foldl f z (x:xs) = let z' = z `f` x
                   in foldl f z' xs