Skip to content

Instantly share code, notes, and snippets.

View adinapoli's full-sized avatar
🐘

Alfredo Di Napoli adinapoli

🐘
View GitHub Profile
@kfish
kfish / watch-read.hs
Created February 15, 2011 02:01
Haskell inotify example: monitor file modifications
{-# OPTIONS -Wall #-}
module Main where
import Control.Concurrent (threadDelay)
import System.Environment (getArgs)
import System.INotify
main :: IO ()
main = do
@paolino
paolino / withAlternative.hs
Created October 3, 2011 17:15
Using Alternative <|> to fold nested if
import Control.Monad
import Control.Applicative
checkProperty = undefined
getDmgMult t elem = maybe 1 id $ do
e <- elem
let check f = checkProperty t ((==e) . f) >>= guard
(check succ >> return 2) `mplus` (check pred >> return 0.5)
@thoughtpolice
thoughtpolice / typenats.hs
Created April 9, 2012 18:48
Type literals
-- probably broken
-- no polymorphic kind signatures, which may make things cleaner
{-# OPTIONS_GHC -Wall #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE TypeOperators#-}
@rampion
rampion / RedBlackTree.hs
Created May 11, 2012 13:55
red-black trees in haskell, using GADTs and Zippers
{-# LANGUAGE GADTs #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE StandaloneDeriving #-}
module RedBlackTree where
data Zero
data Succ n
type One = Succ Zero
data Black
@sciolizer
sciolizer / install-xmonad-with-java-patch.sh
Created August 29, 2012 01:34
Install xmonad with java patch
# Codification of discussion at http://code.google.com/p/xmonad/issues/detail?id=177
# Probably better to run each of these lines one by one instead of as a shell
# script, since there's a high probability of `cabal install` failing (usually
# fixed by installing the relevant libfoo-dev package)
# One person said these steps did not work.
# My Java version is:
# java version "1.6.0_34"
# Java(TM) SE Runtime Environment (build 1.6.0_34-b04)
# Java HotSpot(TM) Server VM (build 20.9-b04, mixed mode)
createUser :: Text -- ^ Username
-> ByteString -- ^ Password
-> Handler b (AuthManager b) (Either String AuthUser)
createUser "" _ = return $ Left "Username cannot be empty"
createUser unm pwd = withBackend $ \r -> do
u <- liftIO $ buildAuthUser r unm pwd
return $ Right u
@NicolasT
NicolasT / StateMachine2.hs
Last active February 13, 2018 14:55
Demonstration of a very-type-safe finite deterministic state machine using DataKinds, ConstraintKinds and TypeFamilies
-- Demonstration of a finite deterministic state machine
-- The state is tracked using a single data type, which is parametrised
-- over the type of messages which are allowed to update the state at any
-- point in time.
-- This should be more clear when reading the code :-)
-- Kudos to elliott, merlijn, mm_freak and others in #haskell for all help
-- and pointers
{-# LANGUAGE DataKinds,
@aaronwolen
aaronwolen / slides.md
Last active November 11, 2022 23:57
Pandoc template to generate reveal.js slideshows.

% Title % Name % Date

My first slide

List

@quchen
quchen / trolling_haskell
Last active February 24, 2024 01:30
Trolling #haskell
13:15 <xQuasar> | HASKELL IS FOR FUCKIN FAGGOTS. YOU'RE ALL A BUNCH OF
| FUCKIN PUSSIES
13:15 <xQuasar> | JAVASCRIPT FOR LIFE FAGS
13:16 <luite> | hello
13:16 <ChongLi> | somebody has a mental illness!
13:16 <merijn> | Wow...I suddenly see the error of my ways and feel
| compelled to write Node.js!
13:16 <genisage> | hi
13:16 <luite> | you might be pleased to learn that you can compile
| haskell to javascript now
@tavisrudd
tavisrudd / alphabet.txt
Created April 11, 2013 06:03
My dragonfly / natlink alphabet code words. I also have the standard NATO phonetic alphabet enabled (https://en.wikipedia.org/wiki/NATO_phonetic_alphabet).
Aff
Brav Bravo
Cai
Doy Delt Delta
Eck Echo
Fay
Goff
Hoop
Ish
Jo