Skip to content

Instantly share code, notes, and snippets.

Tony Morris tonymorris

Block or report user

Report or block tonymorris

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View th-example.hs
data Hi =
Hi1 Int
| Hi2 String
| Hi3 [Int]
deriving (Eq, Show)
-- generate this:
class AsHi a where
_Hi ::
  1. As a pilot have you ever faced any hazards with glare:
  • On a take off? If yes, please elaborate

    Yes. In a high-traffic class D airport with east/west runway orientation in the afternoon. I was mostly concerned with other traffic in the area.

    This has occurred on numerous occasions, but most hazardous during the airport's CTAF hours.

  • On landing? If yes, please elaborate

    Yes. On arriving to the same airport from the east during late afternoon, sun glare caused me to have no visibility of the field at all, though I knew I was quite close. It was towered at the time. I chose to make a turn orthogonal to the sun so that I could sight the field and regain better situational awareness, then subsequently regain normal positioning.

View catalans.hs
{-# OPTIONS_GHC -Wall #-}
import Control.Monad(join)
import Data.List(foldl', permutations, sort)
import System.Environment(getArgs)
factorial ::
-> Integer
factorial n =
View lens-fan-out.hs
import Control.Applicative
data Costate a b =
Costate {
put ::
-> b
, pos ::
View sch.hs
import Data.Functor.Identity
data A = A
deriving (Eq, Show)
data B = B
deriving (Eq, Show)
data C = C
deriving (Eq, Show)

Our web applications are getting increasingly more complicated. They are becoming more distributed and increasingly powered by combinations of complex, constantly changing and large datasets. All while users are increasingly more connected and want the latest information instantly without any slow page loads or stale information.

To address this, developers have turned to layers of caching and single page applications so that there are layers of aggregated and preloaded state as close to the user as possible, to be immediately available when it is requested. This comes at a high cost: it is very difficult to invalidate or update those caches when the upstream information changes. This is especially problematic when the stale caches can accidentally cause real bugs rather than show stale data to users.

The big issue here is that we're not just caching expensive-to-compute static data. We are caching data that changes over time. There are a number of architectual patterns that can be applied, but to date, n

View year.hs
{-# OPTIONS_GHC -Wall #-}
{-# LANGUAGE LambdaCase #-}
-- a leap year is a year, divisible by 4, except (those divisible by 100, except those divisible by 400)
-- there is no zero year
-- Distinguish leap years and common years in data types
import Control.Lens
import Data.Semigroup
View l.hs
{-# OPTIONS_GHC -Wall #-}
import Data.Semigroup
import Data.Functor.Contravariant
data List2 a =
List2 [a] [a]
deriving (Eq, Ord, Show)
instance Semigroup (List2 a) where
You can’t perform that action at this time.