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
import Control.Monad | |
import qualified Graphics.UI.Threepenny as UI | |
import Graphics.UI.Threepenny.Core | |
{----------------------------------------------------------------------------- | |
Main | |
------------------------------------------------------------------------------} | |
main :: IO () |
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
(* A few list functions written in different styles *) | |
fun len lst = | |
let fun loop acc [] = acc | |
| loop acc (_::xs) = loop (acc+1) xs | |
in loop 0 lst end | |
fun lenw lst = | |
let val cnt = ref 0 | |
val next = ref lst |
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
(* Moscow ML handle the first three tests correct. *) | |
fun csnd x y = y | |
local val r = ref "WRONG" in | |
val test1 = csnd (r := "OK"; ()) (!r); | |
end | |
local | |
val r = ref "WRONG" |
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
structure Dyn :> Dyn = | |
struct | |
type t = unit -> unit | |
fun new () = | |
let val r = ref NONE | |
in { into = fn x => fn () => r := SOME x, | |
out = fn f => (f(); !r before r := NONE)} | |
end | |
end |
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
Warning: Setting DYLD_LIBRARY_PATH can break dynamic linking. | |
You should probably unset it. | |
Warning: /Library/Frameworks/Mono.framework detected | |
This can be picked up by CMake's build system and likely cause the build to | |
fail. You may need to move this file out of the way to compile CMake. | |
Warning: Unbrewed .pc files were found in /usr/local/lib/pkgconfig. | |
If you didn't put them there on purpose they could cause problems when | |
building Homebrew formulae, and may need to be deleted. | |
Unexpected .pc files: |
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
{- | |
Benchmarking of simple random number generation using criterion. | |
Compile with the command: ghc -O3 -W --make -fforce-recomp -rtsopts Genrandom.hs -o Genrandom | |
To run the BOOM benchmark you need to set a bigger stack. For instance: | |
$ ./Genrandom BOOM +RTS -K256M -RTS | |
-} |
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 Lorem where | |
import Control.Monad(replicateM_) | |
import System.Environment(getArgs) | |
import qualified System.IO as SIO | |
import qualified Data.Char as C | |
import qualified Data.ByteString.Char8 as BC |
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 AccExp where | |
import qualified Data.Array.Accelerate as A | |
import Data.Array.Accelerate (Z(..), (:.)(..),(!)) | |
import qualified Data.Array.Accelerate.Interpreter as AI | |
pows :: A.Exp Double -> Int -> A.Acc(A.Vector Double) | |
pows u n = | |
A.generate (A.index1$ A.constant $ n+1) (\ix -> let i = A.unindex1 ix in u^i) |
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
-- Benchmark template for TiPL 2012, for testing map implementations | |
-- Compile with the command: ghc -O3 -W --make mapbench.hs -o mapbench | |
import qualified Criterion.Main as C | |
isPrime :: Integral a => a -> Bool | |
isPrime n = null [factor | factor <- [2..floor $ sqrt $ fromIntegral n] | |
, n `mod` factor == 0] | |
numbers = [2,3..] |
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 GADTs #-} | |
data Expr t where | |
Con :: Int -> Expr Int | |
Add :: Expr Int -> Expr Int -> Expr Int | |
Mult :: Expr Int -> Expr Int -> Expr Int | |
IsZ :: Expr Int -> Expr Bool | |
If :: Expr Bool -> Expr t -> Expr t -> Expr t | |
And :: Expr Bool -> Expr Bool -> Expr Bool | |
Or :: Expr Bool -> Expr Bool -> Expr Bool |