Skip to content

Instantly share code, notes, and snippets.

@philopon
philopon / Main.purs
Created December 19, 2014 13:31
xhr-json
module Main where
import Data.Maybe
import Debug.Trace
import Data.JSON
import Network.XHR
main = get defaultAjaxOptions
{ onReadyStateChange = onSuccess $ \response -> do
txt <- getResponseText response
#!/usr/bin/env python3
from html.parser import HTMLParser
import sys
import os.path
class Parser(HTMLParser):
def handle_starttag(self, tag, attrs):
if tag == 'a':
path = None
@philopon
philopon / hello.elm
Created December 10, 2014 11:32
Hello-Elm
import Text(asText)
main = asText "Hello, world!"
@philopon
philopon / hello.hs
Last active August 29, 2015 14:09
hello-apiary
{-# LANGUAGE OverloadedStrings #-}
import Network.Wai.Handler.Warp
import Web.Apiary.Heroku
main :: IO ()
main = runHeroku run def $
action (bytes "Hello, world!")
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE DataKinds #-}
import GHC.TypeLits
import GHC.Exts(Constraint)
data MbNat
= D
@philopon
philopon / 00-Fusion.hs
Created October 21, 2014 08:15
Stream Fusion
import Control.Monad
import Control.Applicative
import System.IO.Unsafe
import Foreign.C
import Foreign.ForeignPtr
import Foreign.Marshal
import Foreign.Storable
newtype FInt = FInt (ForeignPtr CInt)
@philopon
philopon / replicate.hs
Last active August 29, 2015 14:05
replicate of lengthed list
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE OverlappingInstances #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE StandaloneDeriving #-}
@philopon
philopon / dep.hs
Last active August 29, 2015 14:04
{-# LANGUAGE CPP #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE OverlappingInstances #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FlexibleContexts #-}
import Data.Monoid
import Data.Char
import Text.Read
import Options.Applicative
data Mode = Foo | Bar | Baz deriving (Show, Read, Enum, Bounded)
data Options = Options
{ verbose :: Bool
, limit :: Int