Skip to content

Instantly share code, notes, and snippets.

View develop7's full-sized avatar

Andrei Dziahel develop7

View GitHub Profile
@VictorTaelin
VictorTaelin / collapse_monad.hs
Last active April 14, 2025 15:05
The Collapse Monad
import Control.Monad (ap, forM_)
import qualified Data.Map as M
-- The Collapse Monad
-- ------------------
-- The Collapse Monad allows collapsing a value with labelled superpositions
-- into a flat list of superposition-free values. It is like the List Monad,
-- except that, instead of always doing a cartesian product, it will perform
-- pairwise merges of distant parts of your program that are "entangled"
-- under the same label. Examples:
@7h3kk1d
7h3kk1d / TransactionExample.java
Created October 26, 2022 14:28
Transactional Example
public class TransactionExample {
public static void main(String[] args) {
Transactor<IO<?>, Unit, String> transactor = new Transactor<>() {
@Override
public <A> IO<Either<String, A>> runTransactional(Transactional<IO<?>, String, Unit, A> transactional) {
Unit connection = UNIT;
return IO.io(() -> System.out.println("Starting Transaction"))
.discardL(transactional.run(connection)
.<IO<Either<String, A>>>coerce()
.flatMap(e -> e.match(s -> IO.io(() -> System.err.printf("Rolling back transaction due to %s%n", s)),
@TOTBWF
TOTBWF / IOHCC.hs
Last active July 21, 2021 00:41
My submission for the International Obfuscated Haskell Code Competetion
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE ImpredicativeTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
module IOHCC where
import Unsafe.Coerce
u = unsafeCoerce

haskell-effort-graph

  • Red area is a result of the upfront, fixed cost of learning Haskell vs Java.
    • The company pays this for each new hire.
  • Yellow area is the developer's productivity gain once they're "over the hump."
    • The company can benefit from this, but it must first reach a break-even point vs the cost of learning.
    • If average employee tenure is less than this break-even point, the company is taking an absolute loss on each employee.
    • For Haskell to truly be worth it from a business perspective, the average tenure must not just eclipse the break-even point, but it must go further to account for the opportunity cost of better productivity during that learning period.
  • However, employees always benefit from this regardless of turnover - they get to take the productivity gain with them. This - in my opinion - naturally results in some tension.
@ChrisPenner
ChrisPenner / Optics Cheatsheet.md
Last active April 21, 2025 12:45
Optics Cheatsheet
@Elvecent
Elvecent / Concurrent.hs
Last active September 1, 2019 23:52
Running jobs asynchronously but yielding results in order
module Utils.Concurrent (mkPipeline, launchNukes) where
import Control.Concurrent (threadDelay)
import Control.Concurrent.Async (Async, async, cancel, wait)
import Control.Concurrent.STM (TBQueue, atomically, newTBQueueIO,
readTBQueue, writeTBQueue)
import Control.Monad (forever, void)
import Control.Monad.IO.Class (MonadIO, liftIO)
import GHC.Natural (Natural)
@JoeyBurzynski
JoeyBurzynski / 55-bytes-of-css.md
Last active April 8, 2025 14:18
58 bytes of css to look great nearly everywhere

58 bytes of CSS to look great nearly everywhere

When making this website, i wanted a simple, reasonable way to make it look good on most displays. Not counting any minimization techniques, the following 58 bytes worked well for me:

main {
  max-width: 38rem;
  padding: 2rem;
  margin: auto;
}
@graninas
graninas / enq-node-framework.md
Last active February 26, 2025 03:34
Building network actors with Node Framework

Настройка IDE для Haskell.

Для haskell есть haskell ide engine (далее hie).Это приблуда которая поддерживает Language Server Protocol и благодаря этому может интегрироваться со множеством редакторов (neovim, atom, emacs, sublime, vs code).

Установка hie nix-ом работающего с несколькими GHC одновременно - all-hies

Описана здесь . С помощью одной простой комманды вы можете установить HIE:

nix-env -iA selection --arg selector 'p: { inherit (p) ghc864 ghc863 ghc843; }' -f https://github.com/infinisil/all-hies/tarball/master