Skip to content

Instantly share code, notes, and snippets.

@TheSirC
TheSirC / shell.nix
Last active September 20, 2023 01:29
egui/eframe with NixOS
{ pkgs ? import <nixpkgs> { overlays = [ (import (builtins.fetchTarball https://github.com/mozilla/nixpkgs-mozilla/archive/master.tar.gz)) ]; } }:
with pkgs;
mkShell {
nativeBuildInputs = with xorg; [
libxcb
libXcursor
libXrandr
libXi
@snoyberg
snoyberg / transformers.rs
Created December 2, 2020 08:39
Transformers: Rust in disguise
#![feature(generic_associated_types)]
trait Functor {
type Unwrapped;
type Wrapped<A>: Functor;
fn map<F, B>(self, f: F) -> Self::Wrapped<B>
where
F: FnOnce(Self::Unwrapped) -> B;
}
@vjeux
vjeux / tldr.md
Last active April 26, 2020 01:37

tldr of https://serokell.io/blog/2018/12/17/why-dependent-haskell

Standard Haskell: Ergonomics + Performance

He basically wants a language with a type system that lets you ensure that reading an element at an arbitrary position is safe and cannot crash because the index is always within the range of the array. He goes through all the mainstream languages and finds out that none would work.

Agda: Ergonomics + Correctness

He gives an example of a language that has this property, Agda. It's actually not a traditional language but a proof assistant. The way lookup is defined is the following way:

@marcosh
marcosh / Application.hs
Created June 14, 2018 13:20
Web applications as profunctors
module Application where
import Data.Profunctor
newtype Application request response = Application {unApplication :: request -> IO response}
instance Profunctor Application where
dimap actOnRequest actOnResponse application = Application $ (fmap actOnResponse) . (unApplication application) . actOnRequest
@phadej
phadej / poly-nfdata.hs
Last active November 6, 2017 22:24
Example how is possible to write polykinded type-classes in GHC-8.0. It's not that bad or messy, but I'm not sure it's practical either.
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeSynonymInstances #-}
@AndrasKovacs
AndrasKovacs / HVector.hs
Last active March 20, 2016 18:36
HLists backed by contiguous data
{-# language
FlexibleInstances, UndecidableInstances, MagicHash,
PatternSynonyms, GADTs, TypeFamilies, ScopedTypeVariables, TypeOperators,
DataKinds, ViewPatterns, RoleAnnotations, RankNTypes, ConstraintKinds #-}
import GHC.Prim
import Data.Vector (Vector)
import qualified Data.Vector as V
import Data.Proxy
import Text.Show
Authors

Merijn Verstraaten

Date

2014/11/22

So You Want to Be a Super Cool GHC Hacker?

So you have a pet peeve/bug/feature request that you'd like to see added to GHC. You made sure there was a Trac ticket for it, but despite your patient waiting no one is solving your problem. Those selfish GHC hackers!

@rwbarton
rwbarton / A.hs
Last active February 2, 2017 09:32 — forked from 23Skidoo/A.hs
-- Code taken from http://stackoverflow.com/questions/12735274/breaking-data-set-integrity-without-generalizednewtypederiving/12744568#12744568
-- Discussion on haskell-cafe: http://thread.gmane.org/gmane.comp.lang.haskell.cafe/100870
-- http://www.haskell.org/pipermail/haskell-cafe/2012-October/103984.html
-- Modified to remove orphan instances by rwbarton
module A where
data U = X | Y deriving (Eq, Ord, Show)
data T u b c = T u b c deriving (Eq, Show)
@hiratara
hiratara / main.hs
Created November 8, 2012 12:58
Kleisli endo-morphisms are an instance of Monoid.
{-# LANGUAGE FlexibleInstances, OverlappingInstances #-}
module Main where
import Data.Monoid
import Control.Monad
instance Monad m => Monoid (a -> m a) where
mempty = return
mappend = (>=>)
main :: IO ()