Skip to content

Instantly share code, notes, and snippets.

{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings #-}
-- | Look up user locally, then in brig, then return the 'UserId'. If either lookup fails, return
-- 'Nothing'. See also: 'Spar.App.createUser'.
--
-- ASSUMPTIONS: User creation on brig/galley is idempotent. Any incomplete creation (because of
-- brig or galley crashing) will cause the lookup here to yield invalid user.
getUser :: SAML.UserRef -> Spar (Maybe UserId)
getUser uref = do
muid <- wrapMonadClient $ Data.getUser uref
case muid of
@neongreen
neongreen / travis.diff
Created September 2, 2018 18:47
Breaking a Travis CI build into two
diff --git a/.travis.yml b/.travis.yml
index 2068d7d..261c7f5 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -17,37 +17,43 @@ cache:
- .stack-work
timeout: 1000
-matrix:
+jobs:
---
# Amazon MQ can only be set up in a VPC (created in vpc.yml). However, all
# the other services are running on EC2-Classic, and it's impossible for
# security groups to filter traffic between EC2-VPC and EC2-Classic.
#
# One solution is to leave Amazon MQ accessible on the public internet and
# use credentials for controlling access. We don't want to go this way
# because it's one more set of credentials to maintain.
#
# Use Fedora as the base
FROM fedora:27
# Install git
RUN dnf -y install git
# Install Stack
ARG STACK_VERSION=1.6.3
RUN curl -sSfL https://github.com/commercialhaskell/stack/releases/download/v${STACK_VERSION}/stack-${STACK_VERSION}-linux-x86_64-static.tar.gz \
| tar --wildcards -C /usr/local/bin --strip-components=1 -xzvf - '*/stack' && chmod 755 /usr/local/bin/stack
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE NoImplicitPrelude #-}
import BasePrelude
import Data.Text (Text)
import Data.ByteString (ByteString)
import qualified Data.ByteString as BS
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE OverloadedLabels #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE DataKinds #-}
import SuperRecord
import Data.Aeson
import Data.ByteString (ByteString)
-- stack --resolver lts-10.3 --install-ghc runghc --package fmt --package base-prelude --package optparse-applicative --package text
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE ApplicativeDo #-}
-- | A small program replicating a part of @aws-cli@ (only the interface,
-- not the functionality).
module Main where
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE MonoLocalBinds #-}
import Generics.Eot
import Data.Char
greadMaybe :: forall a. (HasEot a, EnumType (Eot a)) => String -> Maybe a
@neongreen
neongreen / atoms.hs
Last active February 15, 2018 17:04
{-# OPTIONS -Wall #-}
{-# LANGUAGE FlexibleContexts #-} -- not all of these are needed
{-# LANGUAGE ViewPatterns #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-} -- really
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE KindSignatures #-} -- don't get scared