Skip to content

Instantly share code, notes, and snippets.

View taktoa's full-sized avatar
🤔
Confused about why this feature exists

Remy Goldschmidt taktoa

🤔
Confused about why this feature exists
View GitHub Profile
@anka-213
anka-213 / Goto.hs
Created April 15, 2018 23:12
A version of http://d.hatena.ne.jp/fumiexcel/20121111/1352624678 that protects against labels escaping an invocation of runGotoT
{-# LANGUAGE RankNTypes #-}
import qualified Data.IntMap as M
import Control.Monad.Trans.Free
import Control.Monad.Trans
{-
The phantom parameter s protects labels from escaping an invocation of runGotoT.
For example, this program:
invalid = runGotoT label >>= runGotoT . goto
is rejected at compile time with this version, but crashes

Things to keep in mind

  • If you write a server using raw UDP, the size of a packet returned as a result of a packet received must be strictly smaller than the size of the packet received, to prevent DoS amplification attacks.
@ekmett
ekmett / QC.hs
Created March 8, 2018 19:44
Using Quantified Constraints for Optics -- untypechecked (no compiler available)
{-# language TypeInType, QuantifiedConstraints, ConstraintKinds, RankNTypes, UndecidableInstances, MultiParamTypeClasses, TypeFamilies, KindSignatures #-}
module QC where
import Data.Constraint
import Data.Functor.Contravariant
import Data.Kind
import Data.Profunctor
type C = (Type -> Type) -> (Type -> Type -> Type) -> Constraint
@mrkgnao
mrkgnao / TopSites.hs
Created February 19, 2018 16:19
What hosts do you visit most often in Firefox?
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeOperators #-}
module Main where
import Protolude hiding ((:*:), optional)
import Database.Selda
{-|
- Example of using free constructions to build a flexible little compiler.
-
- The goal here is not necessarily efficiency but readability and flexibility.
-
- The language grammar is represented by an ADT; however, instead of
- recursively referring to itself it instead references a type variable.
-
- We derive instances of 'Functor' and 'Traversable' for this type.
-
@taktoa
taktoa / haskell-pain-points.md
Last active October 26, 2019 04:18
A rant about pain points in Haskell, written as a response to https://redd.it/7rwuxb

I started writing this polemic to answer your question, but I ended up touching on most of my gripes with Haskell in general, not just in a corporate context.

GHC

GHC is a modern compiler with an amazing RTS and tons of features, but I have some issues with it.

Monolithic and Hard to Contribute To

@andyrbell
andyrbell / scanner.sh
Last active April 5, 2024 09:01
Make a pdf look scanned using ImageMagick
# use ImageMagick convert
# the order is important. the density argument applies to input.pdf and resize and rotate to output.pdf
convert -density 90 input.pdf -rotate 0.5 -attenuate 0.2 +noise Multiplicative -colorspace Gray output.pdf
@bontaq
bontaq / el
Created December 8, 2017 22:58
Brittany for emacs
;; brittany-hs.el --- Minor mode to format JS code on file save
;; Version: 0.1.0
;; Copyright (c) 2014 The go-mode Authors. All rights reserved.
;; Portions Copyright (c) 2015-present, Facebook, Inc. All rights reserved.
;; Redistribution and use in source and binary forms, with or without
;; modification, are permitted provided that the following conditions are
;; met:
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE MagicHash #-}
{-# LANGUAGE UnboxedTuples #-}
module Unsafe.Maybe where
import GHC.Prim (Addr#,nullAddr#,addrToAny#,anyToAddr#,eqAddr#,unsafeCoerce#)
import GHC.Magic (runRW#)
import GHC.Types (Any)
import Unsafe.Coerce (unsafeCoerce)
@alpmestan
alpmestan / ghc.diff
Created October 7, 2017 00:39
Adding :kind!! to ghci, for expanding type families _AND_ type synonyms
diff --git a/ghc/GHCi/UI.hs b/ghc/GHCi/UI.hs
index 32e581a10d..b320ef42ce 100644
--- a/ghc/GHCi/UI.hs
+++ b/ghc/GHCi/UI.hs
@@ -76,6 +76,7 @@ import Linker
import Maybes ( orElse, expectJust )
import NameSet
import Panic hiding ( showException )
+import Type ( expandTypeSynonyms )
import Util