Skip to content

Instantly share code, notes, and snippets.

View patrickt's full-sized avatar
🍉

Patrick Thomson patrickt

🍉
View GitHub Profile
module Cata
import Data.Morphisms
data Expr a
= Lit Int
| Plus a a
| Times a a
instance Show (Expr a) where

Keybase proof

I hereby claim:

  • I am patrickt on github.
  • I am patrickthomson (https://keybase.io/patrickthomson) on keybase.
  • I have a public key whose fingerprint is EE5D FCA1 EA29 1E10 15B4 1476 7368 3120 FC06 BA28

To claim this, I am signing this object:

{-# LANGUAGE GADTs, FlexibleInstances, GeneralizedNewtypeDeriving, DeriveFunctor, DeriveFoldable, DeriveTraversable, TemplateHaskell, FlexibleContexts, OverloadedStrings, ViewPatterns, RankNTypes, NoMonomorphismRestriction #-}
module Main where
import Prelude hiding (break)
import Control.Lens
import Control.Monad
import Control.Monad.Free
import Control.Monad.Free.TH
--import Data.ByteString (ByteString)
struct __darwin_fp_control
{
unsigned short __invalid :1,
__denorm :1,
__zdiv :1,
__ovrfl :1,
__undfl :1,
__precis :1,
:2,
__pc :2,
parsePointers :: CParser (Endo (Term SpecifierSig))
parsePointers = mconcat <$> some pointer where
pointer = do
ptr <- endo C.iPointer "*"
quals <- many parseModifier
let ordered = reverse quals ++ [ptr]
return $ getDual $ mconcat $ Dual <$> ordered
import Data.ByteString (ByteString)
import System.Environment
import System.IO (openFile, IOMode (..))
import System.IO.Streams (InputStream, concatInputStreams, connectTo)
import System.IO.Streams.Handle (handleToInputStream, stdout)
argf :: IO (InputStream ByteString)
argf = do
args <- fmap tail getArgs
handles <- mapM (flip openFile ReadMode) args
data Either a b = Left a | Right b
isLeft :: Either a b -> Bool
isLeft (Left _) = True
isLeft _ = False
either :: (a -> c) -> (b -> c) -> Either a b -> c
either f _ (Left x) = f x
either _ g (Right y) = g y
{-# LANGUAGE OverloadedStrings #-}
module Main where
-- third-party libraries
import qualified Data.Configurator as Config
import Network.HTTP.Client
import System.IO.Streams as Streams
import Control.Concurrent
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
type CGFloat = Double
data CGPoint = CGPoint { x :: CGFloat, y :: CGFloat } deriving (Eq, Show)
instance Num CGPoint where
(CGPoint x y) + (CGPoint x' y') = CGPoint { x = x+x', y = y+y' }
(CGPoint x y) * (CGPoint x' y') = CGPoint { x = x*x', y = y*y' }
(CGPoint x y) - (CGPoint x' y') = CGPoint { x = x-x', y = y-y' }
#include <stdio.h>
#include <stdlib.h>
struct helium_connection_s {
int retain_count;
int foo;
};
typedef struct helium_connection_s *helium_connection_t;