Basic unit type:
λ> replTy "()"
() :: ()Basic functions:
| module Control.Monad.List.Trans where | |
| import Prelude | |
| import Data.List | |
| import Data.Either | |
| import Control.Apply | |
| import Control.Bind | |
| import Control.Monad.Eff |
| import Control.Monad | |
| type Var = Integer | |
| type Subst = [(Var, Term)] | |
| type State = (Subst, Integer) | |
| type Program = State -> KList State | |
| data Term = Atom String | Pair Term Term | Var Var deriving Show | |
| -- Apply a substitution to the top level of a term |
Basic unit type:
λ> replTy "()"
() :: ()Basic functions:
Spurred by recent events (https://news.ycombinator.com/item?id=8244700), this is a quick set of jotted-down thoughts about the state of "Semantic" Versioning, and why we should be fighting the good fight against it.
For a long time in the history of software, version numbers indicated the relative progress and change in a given piece of software. A major release (1.x.x) was major, a minor release (x.1.x) was minor, and a patch release was just a small patch. You could evaluate a given piece of software by name + version, and get a feeling for how far away version 2.0.1 was from version 2.8.0.
But Semantic Versioning (henceforth, SemVer), as specified at http://semver.org/, changes this to prioritize a mechanistic understanding of a codebase over a human one. Any "breaking" change to the software must be accompanied with a new major version number. It's alright for robots, but bad for us.
SemVer tries to compress a huge amount of information — the nature of the change, the percentage of users that wil
| {-# LANGUAGE OverloadedStrings, RecordWildCards, LambdaCase #-} | |
| import Conduit | |
| import Data.Conduit | |
| import Data.Conduit.Network | |
| import qualified Data.ByteString.Char8 as BS | |
| import Data.Conduit.TMChan | |
| import Text.Printf (printf) | |
| import Control.Concurrent.STM | |
| import qualified Data.Map as Map |
| -- in reply to http://www.reddit.com/r/haskell/comments/21mja6/make_lllegal_state_transitions_unrepresentable/ | |
| -- | |
| -- We implement a tiny language with three commands: Open, Close, and Get. | |
| -- The first Get after an Open returns 1, the second Get returns 2, and so on. | |
| -- | |
| -- Get is only valid while the state is open, and | |
| -- Open must always be matched by a Close. | |
| -- We enforce both restrictions via the type system. | |
| -- | |
| -- There are two valid states: Opened and Closed. |
| module InventoryItems(Command(..), Event(..), handle) where | |
| import Data.Maybe(isJust) | |
| type Id = String | |
| type Name = String | |
| type Amount = Int | |
| data Command = CreateInventoryItem Id | |
| | RenameInventoryItem Id Name |
| {-# LANGUAGE TypeFamilies #-} | |
| import Data.Function (on) | |
| import Control.Applicative | |
| data EventData e = EventData { | |
| eventId :: Int, | |
| body :: Event e | |
| } |
| data IOAction a = Return a | |
| | Put String (IOAction a) | |
| | Get (String -> IOAction a) | |
| get = Get Return | |
| put s = Put s (Return ()) | |
| seqio :: IOAction a -> (a -> IOAction b) -> IOAction b | |
| seqio (Return a) f = f a | |
| seqio (Put s io) f = Put s (seqio io f) |
| s x y z = x z (y z) | |
| k x y = x | |
| i = s k k | |
| c = s (s (k (s (k s) k)) s) (k k) | |
| b = s (k s) k | |
| hello = | |
| s(s(k s)(s(k k)(s(k s)(s(k(s(k s)))(s(s(k s)(s(k k)(s(k b)i)))(k(s b(s b(s b(s b(s b(s b(s b(s b(s b(s b(s b(s b(s b(s b(s b(s b(s b(s b(s b(s b(s b(s b(s b(s b(s b(s b(s b(s b(s | |
| b(s b(s b(s b(s b(s b(s b(s b(s b(s b(s b(s b(s b(s b(s b(s b(s b(s b(s b(s b(s b(s b(s b(s b(s b(s b(s b(s b(s b(s b(s b(s b(s b(s b(c k)))))))))))))))))))))))))))))))))))))))))) | |
| )))))))))))))))))))))))))))(s(s(k s)(s(k k)(s(k s)(s(k(s(k s)))(s(s(k s)(s(k k)(s(k b)i)))(k(s b(s b(s b(s b(s b(s b(s b(s b(s b(s b(s b(s b(s b(s b(s b(s b(s b(s b(s b(s b(s b(s |