This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module GCounter | |
import Data.Vect | |
||| GCounter is a Conflict Free Replicated Datatype. | |
||| For a definition, see https://en.wikipedia.org/wiki/Conflict-free_replicated_data_type | |
||| It provides update, query and merge operations. | |
||| merge is commutative, associative and idempotent. | |
data GCounter : Nat -> Type where | |
Nil : GCounter Z |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This is my short-ish tutorial on how to implement closures in | |
a simple functional language: Foo. | |
First, some boilerplate. | |
> {-# LANGUAGE DeriveFunctor, TypeFamilies #-} | |
> import Control.Applicative | |
> import Control.Monad.Gen | |
> import Control.Monad.Writer | |
> import Data.Functor.Foldable |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Payments where | |
data Customer = Customer { name :: String, age :: Int } deriving (Eq, Ord, Show) | |
-- I know partial record fields is an anti-pattern, but who's counting? | |
data Payment | |
= Cash { customer :: Customer, amount :: Double } | |
| Credit { customer :: Customer, amount :: Double, cardNumber :: Int } | |
| Check { customer :: Customer, amount :: Double, routingNumber :: Int, accountNumber :: Int } | |
deriving (Eq, Ord, Show) |
OlderNewer