Total (non-error-throwing) lambda-calculus evaluators.
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
(CCall (CCallSpec (StaticTarget NoSourceText "integer_gmp_powm_word" (Just integer-gmp) True) CCallConv PlayRisky),(# State# RealWorld, Word# #)) | |
(CCall (CCallSpec (StaticTarget NoSourceText "integer_gmp_powm" (Just integer-gmp) True) CCallConv PlayRisky),(# State# RealWorld, Int# #)) | |
(CCall (CCallSpec (StaticTarget NoSourceText "integer_gmp_powm1" (Just integer-gmp) True) CCallConv PlayRisky),(# State# RealWorld, Word# #)) | |
(CCall (CCallSpec (StaticTarget NoSourceText "integer_gmp_powm_sec" (Just integer-gmp) True) CCallConv PlayRisky),(# State# RealWorld, Int# #)) | |
(CCall (CCallSpec (StaticTarget NoSourceText "integer_gmp_invert_word" (Just integer-gmp) True) CCallConv PlayRisky),(# State# RealWorld, Word# #)) | |
(CCall (CCallSpec (StaticTarget NoSourceText "integer_gmp_invert" (Just integer-gmp) True) CCallConv PlayRisky),(# State# RealWorld, Int# #)) | |
(CCall (CCallSpec (StaticTarget NoSourceText "__int_encodeDouble" (Just integer-gmp) True) CCallConv PlayRisky),(# State# RealWorld, Double# #)) | |
(CCall (CCallSpec |
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
(CCall (CCallSpec (StaticTarget NoSourceText "integer_gmp_powm_word" (Just integer-gmp) True) CCallConv PlayRisky),(# State# RealWorld, Word# #)) | |
(CCall (CCallSpec (StaticTarget NoSourceText "integer_gmp_powm" (Just integer-gmp) True) CCallConv PlayRisky),(# State# RealWorld, Int# #)) | |
(CCall (CCallSpec (StaticTarget NoSourceText "integer_gmp_powm1" (Just integer-gmp) True) CCallConv PlayRisky),(# State# RealWorld, Word# #)) | |
(CCall (CCallSpec (StaticTarget NoSourceText "integer_gmp_powm_sec" (Just integer-gmp) True) CCallConv PlayRisky),(# State# RealWorld, Int# #)) | |
(CCall (CCallSpec (StaticTarget NoSourceText "integer_gmp_invert_word" (Just integer-gmp) True) CCallConv PlayRisky),(# State# RealWorld, Word# #)) | |
(CCall (CCallSpec (StaticTarget NoSourceText "integer_gmp_invert" (Just integer-gmp) True) CCallConv PlayRisky),(# State# RealWorld, Int# #)) | |
(CCall (CCallSpec (StaticTarget NoSourceText "__int_encodeDouble" (Just integer-gmp) True) CCallConv PlayRisky),(# State# RealWorld, Double# #)) | |
(CCall (CCallSpec |
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
[2 of 2] Compiling Main ( hask-tok3.hs, hask-tok3.o ) | |
==================== Tidy Core ==================== | |
Result size of Tidy Core | |
= {terms: 2,614, types: 3,717, coercions: 1,413, joins: 31/63} | |
-- RHS size: {terms: 16, types: 9, coercions: 0, joins: 0/0} | |
Main.$WPoint [InlPrag=INLINE[2]] :: Int -> Int -> Int -> Point | |
[GblId[DataConWrapper], | |
Arity=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
-- | Our main engine for naming a value, then we can prove properties about a named value. | |
{-# LANGUAGE ExistentialQuantification #-} -- Used for SomeNamed. | |
{-# LANGUAGE PatternSynonyms #-} -- Used for the Name pattern. | |
{-# LANGUAGE ViewPatterns #-} -- Used for the Name pattern. | |
{-# LANGUAGE RankNTypes #-} -- Used for withName. | |
module Named ( Named, pattern Name, forgetName, withName, someNamed, SomeNamed(..) ) where | |
-- | Give a generated type-level name to any value. |
This is a small experiment to see whether one can:
- Lex a file efficiently, retaining line/column and indentation information.
- Consuming no or little memory (aside from the input size itself), and
- Still have the flexibility to perform zero-cost operations like folds (counting tokens), doing nothing (a simple pass), or printing. SAX-style.
This proves that one could, e.g., run in ST and write to a mutable Storable vector. Allowing the caller to process the set of tokens later. But the cost/calculation of figuring out line/col/indentation of each token has already been figured out.
The input file is war-and-peace.txt which is 6MB. Simply reading the file takes 27ms. Counting all words (non-space) in the file takes 36ms. So let's say about 9ms, in the absense of more rigorous gauge-based benchmarking. There are 1,132,619 "words" in the file.
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, LambdaCase #-} | |
import Control.Monad | |
-- Model the problem with a simple GADT: | |
data Foo a where | |
GetInput :: Foo String | |
WriteOutput :: String -> Foo () | |
Pure :: a -> Foo a |
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
{-# OPTIONS_GHC -fno-warn-type-defaults #-} | |
{-# LANGUAGE TypeFamilies #-} | |
{-# LANGUAGE GADTs #-} | |
{-# LANGUAGE ExtendedDefaultRules #-} | |
{-# LANGUAGE LambdaCase #-} | |
{-# LANGUAGE OverloadedStrings #-} | |
{-# LANGUAGE TypeApplications #-} | |
{-# LANGUAGE TypeOperators #-} | |
{-# LANGUAGE ScopedTypeVariables #-} | |
{-# LANGUAGE StandaloneDeriving #-} |
Change the mx.chrisdone.com mentions to your own domain.
Spin up a Droplet on DigitalOcean with docker-machine.
$ time docker-machine create \
--driver digitalocean \
--digitalocean-access-token $(cat ~/.do-token) \
--digitalocean-monitoring \
--digitalocean-region "lon1" \
--digitalocean-size "s-1vcpu-1gb" \
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 currency-less integral monetary value which cannot be further | |
-- subdivided. E.g. cent, penny, satoshi. | |
-- | |
-- For lack of a better name: | |
-- <https://money.stackexchange.com/questions/85562/generic-name-for-the-smallest-unit-of-currency> | |
newtype IntegralMoney = IntegralMoney Int | |
deriving (Eq, Ord, Integral, Num, Enum, Real, Show) | |
instance PersistFieldSql IntegralMoney where | |
sqlType _ = SqlString | |
instance PersistField IntegralMoney where |