The original code (~7.2s on my laptop).
import System.Random
import System.CPUTime
rainfall :: [Int] -> Int
rainfall xs = sum (zipWith (-) mins xs)The original code (~7.2s on my laptop).
import System.Random
import System.CPUTime
rainfall :: [Int] -> Int
rainfall xs = sum (zipWith (-) mins xs)| {-# LANGUAGE TypeSynonymInstances #-} | |
| import Data.Monoid | |
| import Data.Maybe | |
| -- How much water does a "histogram" hold? | |
| -- | |
| -- Inspired by Guy Steele's talk "Four Solutions to a Trivial Problem" | |
| -- https://www.youtube.com/watch?v=ftcIcn8AmSY |
| {-# LANGUAGE BangPatterns #-} | |
| module Main where | |
| import qualified Data.Text as Text | |
| import Data.Text (Text, pack) | |
| import Criterion.Main | |
| import Test.QuickCheck.Arbitrary | |
| import Test.QuickCheck | |
| import Data.List | |
| import qualified Data.Vector.Unboxed as U |
| {-# LANGUAGE ApplicativeDo #-} | |
| {-# LANGUAGE ConstrainedClassMethods #-} | |
| {-# LANGUAGE ConstraintKinds #-} | |
| {-# LANGUAGE DataKinds #-} | |
| {-# LANGUAGE DeriveFunctor #-} | |
| {-# LANGUAGE DeriveGeneric #-} | |
| {-# LANGUAGE FlexibleContexts #-} | |
| {-# LANGUAGE FlexibleInstances #-} | |
| {-# LANGUAGE IncoherentInstances #-} | |
| {-# LANGUAGE InstanceSigs #-} |
| {-# LANGUAGE DeriveFunctor, GADTs #-} | |
| import Control.Monad.Writer | |
| import Data.List (intercalate) | |
| import Data.Foldable (traverse_) | |
| data S m a where | |
| It :: String -> m a -> S m a | |
| Describe :: String -> S m a -> S m a | |
| Group :: [S m a] -> S m a | |
| BeforeEach :: m a -> S m (a -> b) -> S m b |
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| #!/usr/bin/env stack | |
| {- | |
| stack | |
| --resolver lts-8.4 | |
| --install-ghc | |
| runghc | |
| --package aeson | |
| --package aeson-casing | |
| --package base | |
| --package bytestring |
| {-# LANGUAGE MultiParamTypeClasses #-} | |
| {-# LANGUAGE FlexibleInstances #-} | |
| {-# LANGUAGE OverloadedStrings #-} | |
| {-# LANGUAGE DataKinds #-} | |
| {-# LANGUAGE DeriveGeneric #-} | |
| {-# LANGUAGE TypeOperators #-} | |
| module Sand where | |
| import Data.Aeson |
| <Project> | |
| <ItemGroup> | |
| <Solution Include="*.sln" /> | |
| <PublishProject Include="XXX.Mvc\XXX.Mvc.csproj" /> | |
| <TestProject Include="**\*.Test*.*proj" Exclude="XXX.Tests.Shared\XXX.Tests.Shared.csproj" /> | |
| </ItemGroup> | |
| <Target Name="Build"> | |
| <MSBuild Projects="@(Solution)" Targets="Restore" ContinueOnError="ErrorAndStop" UnloadProjectsOnCompletion="true" UseResultsCache="false" /> | |
| <MSBuild Projects="@(PublishProject)" Targets="Publish" Properties="Configuration=Release" ContinueOnError="ErrorAndContinue" /> |