Skip to content

Instantly share code, notes, and snippets.

@anilanar
anilanar / callbag.purs
Last active December 12, 2018 00:39
Callbags in purescript
module Main where
import Prelude
import Data.Array.NonEmpty (NonEmptyArray, (..))
import Data.Traversable (class Traversable, sequence)
import Effect (Effect)
import Effect.Console (log)
import Prelude as P
@graninas
graninas / enq-node-framework.md
Last active November 7, 2023 17:20
Building network actors with Node Framework
@parsonsmatt
parsonsmatt / haskell-app-layers.md
Created December 11, 2017 15:48
A basic draft of a future blog post

The question of "How do I design my application in Haskell?" comes up a lot. There's a bunch of perspectives and choices, so it makes sense that it's difficult to choose just one. Do I use plain monad transformers, mtl, just pass the parameters manually and use IO for everything, the ReaderT design pattern, free monads, freer monads, some other kind of algebraic effect system?!

The answer is: why not both/all?

Lately, I've been centering on a n application design architecture with roughly three layers:

Layer 1:

newtype AppT m a = AppT { unAppT :: ReaderT YourStuff m a } deriving ............ The ReaderT Design Pattern, essentially. This is what everything gets boiled down to, and what everything eventually gets interpreted in. This type is the backbone of your app. For some components, you carry around some info/state (consider [MonadMetrics](https://hackage

@MonoidMusician
MonoidMusician / Main.purs
Last active September 1, 2017 21:20
mixst
module Main where
import Type.Prelude
import Type.Row
import Type.Data.Boolean
import Type.Data.Symbol as Symbol
import Data.Newtype
data RProxy (r :: # Type) = RProxy
data RLProxy (rl :: RowList) = RLProxy
@i-am-tom
i-am-tom / fanfic.md
Last active April 14, 2018 22:13
The morning of Gary Burgess, 01/09/17

"For services to the PureScript Community, Gary Burgess!"

You've done it, Gary. Moore, Lineker, Coleman, and now Burgess. All the work was worth it. The halls erupted with praise. Children dressed as Space Ghost, teens with "I only get high on Halogen" t-shirts, a giant banner held aloft with the message, "Tuple @garyb me". Through the noise of the crowds and Phil's uninterpretable Northern accent, he barely managed to hear his theme tu-

BZZP. BZZP.

-- | Binary operation
class Magma a where
op ∷ a → a → a
-- | Associativity: `∀ a b. (a • b) • c = a • (b • c)`
class Magma a ⇐ Associative a
-- | Identity: `∀ a. a • identity = a && identity • a = a`
class Magma a ⇐ Identity a where
identity ∷ a
@i-am-tom
i-am-tom / Json.purs
Last active February 15, 2020 17:14
Parsing, Generating, and Diffing JSON in PureScript
module Main where
-- | JSON is an incredibly simple format. Even its lists are untyped.
-- | As with all languages, functional programming encourages us to
-- | make a domain-specific language (or DSL) to capture the "ideas"
-- | of the language, which we can then use to talk about its content.
-- | In this little snippet, we'll build a JSON DSL, transform it into
-- | a recursive structure, and then use that result to generate some
@unya
unya / example-app.yml
Created July 27, 2017 10:21
Example Ingress + Let's encrypt setup to use with nginx-ingress-controller on GKE
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: example
spec:
replicas: 2
selector:
matchLabels:
app: example
@ahmetb
ahmetb / gcrgc.sh
Last active February 26, 2024 09:14
Script to clean up Google Container Registry images pushed before a particular date
#!/bin/bash
# Copyright © 2017 Google Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
@leighman
leighman / Main.purs
Last active April 9, 2023 18:21 — forked from oxbowlakes/3nightclubs.scala
A Tale of 3 Nightclubs
module Main where
import Prelude
import Control.Monad.Eff (Eff)
import Control.Monad.Eff.Console (CONSOLE, logShow)
import Data.Either (Either(..))
import Data.Foldable (elem, notElem)
import Data.Int (toNumber)
import Data.Traversable (traverse)
import Data.Validation.Semigroup (invalid)