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 RadioCode where | |
import Control.Arrow | |
import Data.Char | |
import Data.List | |
import Data.Maybe | |
icao :: [(Char, String)] | |
icao = | |
(head &&& delete ',') |
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
using System; | |
using System.Collections; | |
using System.Collections.Generic; | |
public class Foo : IEnumerable<int> | |
{ | |
public IEnumerator<int> GetEnumerator() | |
{ | |
yield return 42; | |
yield return 1337; |
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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace Ploeh.Samples.ChainOfResponsibility | |
{ | |
public class Maybe<T> | |
{ |
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
-- Translation to Haskell of: | |
-- http://ccd-school.de/2017/06/stratified-design-over-layered-design | |
-- I've deliberately translated each method to a function, in order to show the | |
-- similarity. Some functions, like extractWords, are redundant (already built | |
-- in) or almost too simple to get their own function. | |
module Main where | |
import Data.List (partition) |
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
{-# LANGUAGE DeriveFunctor #-} | |
module PollingConsumer where | |
import Data.Time.Clock | |
import Control.Monad.Trans.Free (Free, FreeF(..), liftF, runFree) | |
import Control.Concurrent (threadDelay) | |
import System.Random (getStdRandom, random, randomR) | |
import Text.Printf (printf) | |
-- "Types prevent typos" - https://twitter.com/hmemcpy/status/867647943108681728 |
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
open System | |
open System.Drawing | |
open System.Windows.Forms | |
// Create a form to display the graphics | |
let width, height = 500, 500 | |
let form = new Form(Width = width, Height = height) | |
let box = new PictureBox(BackColor = Color.White, Dock = DockStyle.Fill) | |
let image = new Bitmap(width, height) | |
let graphics = Graphics.FromImage(image) |
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 Main where | |
import Control.Monad.Eff (Eff) | |
import Data.Maybe (fromJust) | |
import Data.Tuple (Tuple(..)) | |
import Graphics.Canvas (CANVAS, Context2D, closePath, getCanvasElementById, | |
getContext2D, lineTo, moveTo, setLineWidth, strokePath) | |
import Math (cos, pi, sin) | |
import Partial.Unsafe (unsafePartial) | |
import Prelude (Unit, bind, discard, negate, void, ($), (*), (+), (-), (/), (<=)) |
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 Tuple2 | |
let replicate x = x, x | |
let curry f x y = f (x, y) | |
let uncurry f (x, y) = f x y | |
let swap (x, y) = (y, x) |
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 ApiModel where | |
import Data.Time (ZonedTime(..), parseTimeM, defaultTimeLocale, iso8601DateFormat) | |
data ReservationRendition = ReservationRendition | |
{ rDate :: String | |
, rName :: String | |
, rEmail :: String | |
, rQuantity :: Int } | |
deriving (Eq, Show, Read) |
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
safeHead [] = Left "The list was empty. No head is available." | |
safeHead xs = Right . head $ xs | |
-- Sample usage from GHCI: | |
-- | |
-- *Safefs> safeHead [1..3] | |
-- Right 1 | |
-- *Safefs> safeHead [7] | |
-- Right 7 | |
-- *Safefs> safeHead [2, 3] |
NewerOlder