Skip to content

Instantly share code, notes, and snippets.

class MonadClient m where
performRequestCT :: Proxy ct -> method -> Req -> m a
instance MonadClient ClientM where
....
instance OVERLAPPING_
-- Note [Non-Empty Content Types]
( MonadClient m, MimeUnrender ct a, BuildHeadersTo ls, ReflectMethod method, cts' ~ (ct ': cts)
) => HasClient (Verb method status cts' (Headers ls a)) where
@abailly
abailly / gist:8b3d99bdf70db8a4a84a9d334efe21d7
Created July 18, 2017 15:33
Error while trying to compile Idris
[113 of 113] Compiling IRTS.BCImp ( src/IRTS/BCImp.hs, .stack-work/dist/x86_64-osx/Cabal-1.24.2.0/build/IRTS/BCImp.o )
Preprocessing executable 'idris' for idris-1.0...
[1 of 1] Compiling Main ( main/Main.hs, .stack-work/dist/x86_64-osx/Cabal-1.24.2.0/build/idris/idris-tmp/Main.o )
Linking .stack-work/dist/x86_64-osx/Cabal-1.24.2.0/build/idris/idris ...
Preprocessing executable 'idris-codegen-c' for idris-1.0...
[1 of 2] Compiling Paths_idris ( .stack-work/dist/x86_64-osx/Cabal-1.24.2.0/build/autogen/Paths_idris.hs, .stack-work/dist/x86_64-osx/Cabal-1.24.2.0/build/idris-codegen-c/idris-codegen-c-tmp/Paths_idris.o )
[2 of 2] Compiling Main ( codegen/idris-codegen-c/Main.hs, .stack-work/dist/x86_64-osx/Cabal-1.24.2.0/build/idris-codegen-c/idris-codegen-c-tmp/Main.o )
Linking .stack-work/dist/x86_64-osx/Cabal-1.24.2.0/build/idris-codegen-c/idris-codegen-c ...
Preprocessing executable 'idris-codegen-javascript' for idris-1.0...
[1 of 2] Compiling Paths_idris ( .stack-work/d
@abailly
abailly / Retry.hs
Created July 16, 2017 11:07
A Retry combinator for servant
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
@abailly
abailly / GenericUUID.hs
Created June 1, 2017 14:08
example of defining Generic instances
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeOperators #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
------------------------------------------------------------------------
-- | UUID support for Generics
-- inspired by https://raw.githubusercontent.com/tibbe/hashable/master/Data/Hashable/Generic.hs
module Gorilla.UUID.Generic where
@abailly
abailly / Stack.idr
Last active May 13, 2017 06:32
Stack calculator with generic binary operator handling
module Main
import Data.Vect
data StackOp : Type -> Nat -> Nat -> Type where
Push : Integer -> StackOp () height (S height)
Pop : StackOp Integer (S height) height
Top : StackOp Integer (S height) (S height) -- this means there has to be at least one item on the stack
GetStr : StackOp String height height
PutStr : String -> StackOp () height height
@abailly
abailly / random.hs
Last active April 24, 2017 07:37
A haskell implementation of a pseudo-random number generator using Salsa20 algorithm
#!/usr/bin/env runhaskell -threaded --
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE ScopedTypeVariables #-}
import Control.Concurrent (forkIO)
import Control.Exception (IOException, catch)
import Control.Monad (forM, forM_, when)
import Data.Array.IO
@abailly
abailly / Survey.idr
Last active March 23, 2017 20:57
A dependently-typed survey system
interface Displayable d where
total display : d -> String
data Question : Type where
QCM : {numOptions : Nat}
-> (question : String)
-> (qcmOptions : Vect numOptions String)
-> (expected : Fin numOptions)
-> Question
Grade : (question : String)
@abailly
abailly / McBride.hs
Last active November 6, 2016 21:02
McBride's Outrageous Fortune
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE ViewPatterns #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE TypeFamilies #-}
module Gorilla.Test exposing(..)
import Navigation
type Array a = Array
type Project = Project
type Entity = Entity
type alias Time = Int
type alias Route = String
@abailly
abailly / Test.elm
Created August 26, 2016 11:36
Sample PBT in Elm
all : Test
all =
describe "Test URL parsing & Routing"
[ fuzz component "toURL/fromUrl can roundtrip given listing id is a digit" <|
\ c ->
let u = toUrl c
in Expect.equal (Ok c) (fromUrl u)
]