Skip to content

Instantly share code, notes, and snippets.

@andrevdm
andrevdm / Scotty_websockets.hs
Last active March 6, 2024 01:51
Using websockets with scotty haskell
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Protolude
import qualified Web.Scotty as Sc
import qualified Data.Text as Txt
import qualified Network.Wai.Middleware.Gzip as Sc
@alexott
alexott / minimial-cedet-config.el
Created October 22, 2012 07:30
Working configuration for CEDET from bzr & GNU Emacs (with working C++ & Java name completion)
;;; minimial-cedet-config.el --- Working configuration for CEDET from bzr
;; Copyright (C) Alex Ott
;;
;; Author: Alex Ott <alexott@gmail.com>
;; Keywords: cedet, C++, Java
;; Requirements: CEDET from bzr (http://cedet.sourceforge.net/bzr-repo.shtml)
;; Do checkout of fresh CEDET, and use this config (don't forget to change path below)
#!/bin/bash
echo '#!/bin/bash'
echo ''
echo 'failed_items=""'
echo 'function install_package() {'
echo 'echo EXECUTING: brew install $1 $2'
echo 'brew install $1 $2'
echo '[ $? -ne 0 ] && $failed_items="$failed_items $1" # package failed to install.'
echo '}'
@egonSchiele
egonSchiele / diners.hs
Last active April 23, 2022 17:29
Dining philosophers solution in Haskell using STM. Taken from http://rosettacode.org/wiki/Dining_philosophers#Haskell with some minor modifications.
import Control.Monad
import Control.Concurrent
import Control.Concurrent.STM
import System.Random
import Text.Printf
-- Forks
type Fork = TMVar Int
newFork :: Int -> IO Fork
\[
\begin{tikzcd}
&C
\arrow[ld, "\pi_X"']
\arrow[rd, "\pi_Y"]
\\
P \langle X X \rangle
\arrow[dr, "{P \langle id, f \rangle}"']
&&P \langle Y, Y \rangle
\arrow[dl, "{P \langle f, id \rangle}"]
@sjoerdvisscher
sjoerdvisscher / nucleus.hs
Last active September 25, 2021 06:36
Nucleus of a profunctor
{-# LANGUAGE
PolyKinds
, RankNTypes
, TypeFamilies
, TypeOperators
, TypeApplications
, FlexibleInstances
, ScopedTypeVariables
, AllowAmbiguousTypes
, MultiParamTypeClasses
@TikhonJelvis
TikhonJelvis / cabal-schema.json
Created August 30, 2021 00:41
A nowhere-near complete or correct JSON Schema for Cabal package descriptions
{
"title": "Cabal file",
"type": "object",
"properties": {
"license-files": {
"description": "One or more files containing the precise copyright license for the package.",
"items": {
"type": "string"
},
"type": "array"
@dysinger
dysinger / packages.el
Last active January 16, 2021 19:30
Private spacemacs layer to try out Chris Done's Intero mode for haskell
;; 1. place this in ~/.emacs.d/private/intero/packages.el
;; 2. add intero, syntax-checking and auto-completion to your
;; ~/.spacemacs layer configuration & remove the haskell layer
;; if you were using that before
;; 3. make sure you have stack installed http://haskellstack.org
;; 4. fire up emacs & open up a stack project's source files
@Icelandjack
Icelandjack / OpenKinds.markdown
Last active January 26, 2020 20:53
Rethinking Tricky Classes: Explicit Witnesses of Monoid Actions, Semigroup / Monoid / Applicative homomorphisms
@Icelandjack
Icelandjack / blog_deriving.markdown
Last active October 7, 2019 22:43
Blog Post: Derive instances of representationally equal types

Reddit discusson thread.

I made a way to get more free stuff and free stuff is good.

The current implementation of deriveVia is here, it works with all the examples here. Needs GHC 8.2 and th-desugar.

It doesn't take long

for new Haskellers to get pampered by their compiler. For the price of a line or two the compiler offers to do your job, to write uninteresting code for you (in the form of type classes) such as equality, comparison, serialization, ... in the case of 3-D vectors