Type classes are a language of their own, this is an attempt to document some features.
Work in progress.
(Hackage) EDSL, Ivory
-- | Things that can be safely stored in references.
Windows Registry Editor Version 5.00 | |
[HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\Sessions\monokai] | |
"Colour21"="255,255,255" | |
"Colour20"="245,222,179" | |
"Colour19"="200,240,240" | |
"Colour18"="0,217,217" | |
"Colour17"="179,146,239" | |
"Colour16"="174,129,255" | |
"Colour15"="122,204,218" |
{-# LANGUAGE OverloadedStrings #-} | |
module Main where | |
import System.Process.Streaming | |
import System.Exit | |
import Data.ByteString (ByteString) | |
import qualified Data.ByteString.Lazy.Char8 as S | |
import Pipes.ByteString (toLazyM) |
{- | |
This code shows how to check if a type-level list contains a given type. | |
It first shows the approach required for older versions of GHC (< 7.6.x) | |
and then a version using closed type families supported in GHC 7.8.1 and greater. | |
-} | |
{-# LANGUAGE FlexibleContexts #-} | |
{-# LANGUAGE UndecidableInstances #-} | |
{-# LANGUAGE FlexibleInstances #-} | |
{-# LANGUAGE MultiParamTypeClasses #-} |
module Printf | |
%default total | |
data Format = FInt Format -- %d | |
| FString Format -- %s | |
| FOther Char Format -- [a-zA-Z0-9] | |
| FEnd -- | |
format : List Char -> Format |
{-# LANGUAGE DataKinds #-} | |
{-# LANGUAGE FlexibleInstances #-} | |
{-# LANGUAGE MultiParamTypeClasses #-} | |
{-# LANGUAGE OverloadedLabels #-} | |
{-# LANGUAGE TemplateHaskell #-} | |
{-# LANGUAGE TypeFamilies #-} | |
{-# LANGUAGE FlexibleContexts #-} | |
{-# LANGUAGE UndecidableInstances #-} | |
{-# LANGUAGE MagicHash #-} | |
{-# LANGUAGE ScopedTypeVariables #-} |
Type classes are a language of their own, this is an attempt to document some features.
Work in progress.
-- | Things that can be safely stored in references.
-- The meta-circular interpreter from section 5 of Reynolds's Definitional | |
-- Interpreters for Higher Order Programming Languages | |
-- (http://www.cs.uml.edu/~giam/91.531/Textbooks/definterp.pdf) | |
data EXP | |
= CONST Const | |
| VAR Var | |
| APPL Appl | |
| LAMBDA Lambda | |
| COND Cond |
Quite a lot of different people have been on the same trail of thought. Gary Bernhardt's formulation of a "functional core, imperative shell" seems to be the most voiced.
"Imperative shell" that wraps and uses your "functional core".. The result of this is that the shell has fewer paths, but more dependencies. The core contains no dependencies, but encapsulates the different logic paths. So we’re encapsulating dependencies on one side, and business logic on the other side. Or put another way, the way to figure out the separation is by doing as much as you can without mutation, and then encapsulating the mutation separately. Functional core — Many fast unit tests. Imperative shell — Few integration tests
# Aliases for common git commands. E.g., enter "git d" for "git diff" | |
# These settings live in the ~/.gitconfig file. | |
[alias] | |
b = branch | |
ba = branch -a | |
ci = commit | |
co = checkout | |
d = diff | |
dc = diff --cached |
Copyright © 2017 Fantasyland Institute of Learning. All rights reserved.
A function is a mapping from one set, called a domain, to another set, called the codomain. A function associates every element in the domain with exactly one element in the codomain. In Scala, both domain and codomain are types.
val square : Int => Int = x => x * x