This file contains 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
{-# LANGUAGE DeriveDataTypeable #-} | |
module PrintF | |
where | |
import Data.Generics | |
import qualified Language.Haskell.TH as TH | |
import Language.Haskell.TH.Quote | |
data Format = FInt Format -- %d |
This file contains 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 okay: | |
type Regex<'T> = | |
| Seq of Regex<'T> list | |
| Alt of Regex<'T> list | |
| Singleton of 'T | |
// This is okay: | |
type Regex<'T> = | |
private Seq of Regex<'T> list | |
| Alt of Regex<'T> list |
This file contains 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
using System; | |
using System.Collections; | |
using System.Collections.Generic; | |
using System.IO; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace TypedTaglessFinal | |
{ |
This file contains 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
<Query Kind="Program"> | |
<Namespace>System.Threading.Tasks</Namespace> | |
</Query> | |
void Main() | |
{ | |
Client().Wait(); | |
} | |
async Task Client() |
This file contains 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
{-# LANGUAGE GeneralizedNewtypeDeriving #-} | |
import Data.Monoid | |
newtype On = On [(Int, String)] deriving Monoid | |
on n s = On [(n, s)] | |
messages (On x) = cycle $ map funcFor [1..maxM] | |
where | |
maxM = foldl1 lcm $ map fst x |
This file contains 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
{-# LANGUAGE FlexibleInstances, TypeSynonymInstances #-} | |
import Data.List | |
-- unchanged from blog post apart from signature | |
compile :: Compilable a => String -> a | |
compile [] = empty | |
compile ('?' :cs) = anyChar `append` compile cs | |
compile ('*' :cs) = whatever `append` compile cs | |
compile ('\\':c:cs) = char c `append` compile cs |
This file contains 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
public struct Result<T>(T value) | |
{ | |
public static implicit operator Result<T>(T value) => new Result<T>(value); | |
public static implicit operator Result<T>(Result<Any> any) => default(Result<T>); | |
public static implicit operator Result<T>(Result<T, Any> value) => new Result<T>(value.Value); | |
public bool HasValue { get; } = true; | |
public T Value { get; } = value; | |
} |
This file contains 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
{-# LANGUAGE DataKinds, KindSignatures, TypeOperators, ScopedTypeVariables, TypeFamilies #-} | |
import Prelude hiding (length) | |
import qualified Data.Vector as V | |
import qualified GHC.TypeLits as T | |
import qualified Data.Proxy as P | |
newtype FVec a (n :: T.Nat) = FVec (V.Vector a) deriving (Show, Eq) | |
type a ^ n = FVec a n |
This file contains 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
using System; | |
class Foo | |
{ | |
event EventHandler DoAThing; | |
void WhyYouEvenGottaDoAThing() | |
{ | |
DoAThing.Raise(this); | |
} |
This file contains 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 F | |
module State = | |
type State<'s, 'r> = | |
// A stateful computation takes an initial state of type 's | |
// and returns a result of some type 'r and a new state of type 's. | |
private State of ('s -> 'r * 's) | |
// You can run a stateful computation by supplying the state value: |