emacs/haskell development environment
This is my emacs/haskell development environment.
Intero seems to work better with Stack than Dante.
Last Modified : 2017 Oct 26 (Thu) 08:21:13 by Harold Carr.
This is my emacs/haskell development environment.
Intero seems to work better with Stack than Dante.
Last Modified : 2017 Oct 26 (Thu) 08:21:13 by Harold Carr.
This exposition focuses on a blockchain technique often used in a block: Merkle Trees.
setup:
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ViewPatterns #-}
module Block where
import ClassyPrelude as CP hiding ((<|))
import Control.Monad.ST.Strict (runST)
import Crypto.Hash.SHA256 as C (hash)
import Data.ByteString.Char8 as BS (pack, replicate)
import Data.Char (chr)
import Data.Map.Strict as M
import Data.Sequence as S
import Data.STRef.Strict
import Test.Hspec
import Test.RandomStrings (randomASCII, randomWord)
{-# ANN module ("HLint: ignore Eta reduce"::String) #-}
{-# ANN module ("HLint: ignore Reduce duplication"::String) #-}
For this exposition, a block will be defined as:
data Block = Block
{ header :: ! BlockHeader
, txs :: ! Transactions
} deriving (Eq, Show)
This post develops a simple blockchain with the goal of understanding the basics of the chain.
setup:
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
module Chain where
import ClassyPrelude as CP
import Crypto.Hash.SHA256 as C (hash)
import Data.ByteString as BS (concat)
import Data.ByteString.Char8 as BS (pack)
import qualified Prelude as P (tail)
import Data.Sequence as S
import Test.Hspec
The most straigtforward part of a blockchain is the chain itself, a sequence of blocks:
type Blockchain = Seq Block
Slides for my May 27, 2017 LambdaConf talk on recursion schemes.
This presentation is unique in that shows “list only” versions of a number of recursions schemes. This makes it easier to understand for beginners (because it avoids the need to talk about Fix
).
I gave a talk at Lambda Lounge Utah on “Programming and Math”.
I gave a slightly different version of this talk at LambdaConf a couple of months earler.
Over the years I occasionally reimplemented my rdf-triple-browser, first in GWT, then Java/Swing and then last summer in Haskell using Threepenny-gui (which I will call ‘TPG’ for the rest of this article). The hardest part for me was understanding how to connect to external events.
The documentation says newEvent :: IO (Event a, Handler a)
“Create a new event. Also returns a function that triggers an event occurrence.” What is doesn’t say it that calling the returned Handler
causes the specific returned Event
to happen.
I got lost in the documentation about Handler
, going off on dead ends with register
. Even the TAs at last summer’s Utrecht Haskell Summer School could not figure it out (although, to be fair, they did not spend that much time on it, they were concentrating on course questions).
Fortunately, Max Taldykin, on stackoverflow, provided a small program that lead me to discover the “magic” of how to use what is returned via newEvent
. Below I show an even smaller program that shows how it is wired.
My talk at Java one on InfiniBand communication infrastructure.
Erik Meijer points out a typo (or conceptual error) in an FPComplete article that calls JSON a protocol and HTTP a format.
The PEPT remoting architecture considers:
a transport to be something that moves bits from one location to another
a transport is something where the program does not manipulate header bits
e.g., most apps do not touch TCP/IP header bits, they just write/read from the TCP/IP streams
a remoting protocol is something where, besides moving bits, the program will manipulate the header bits
e.g., HTTP is a protocol for REST
e.g., HTTP is a transport for SOAP (in general)
a remoting format is
a serial encoding of the application data
a serial encoding of protocol and/or transport headers
e.g., JSON is a common application format for REST
e.g., XML is both the application format and the protocol format for SOAP
e.g., CDR is both the application format and the protocol format for CORBA IIOP
There are, of course, special cases, but the above taxonomy provides a useful separation of concerns.
One of the tools I use for drawing graphs is dot
from Graphviz. Recently I was drawing a series of diagrams that have mostly identical parts. It was error-prone and a pain to keep the identical parts in sync between the multiple *.dot
files. I found Haskell’s Data.GraphViz package to be the solution.
The documentation for that package is great, but it needs a few more examples. The purpose of this post is to add examples to the pool.
For writing articles on Haskell, rather than showing ghci
input/output like:
Prelude> map (*2) [1..10]
[2,4,6,8,10,12,14,16,18,20]
I do the following:
My presentation at JavaOne 2013.
ABSTRACT
The JAX-WS standard includes APIs for using POJOs or XML for remote messages. But it does not include APIs for letting the user control the transport. This BoF discusses adding pluggable transport APIs to the JAX-WS standard.
This BoF shows a candidate pluggable transport mechanism for JAX-WS that enables one to use other transports besides HTTP. In particular, it shows the benefits of using WebSockets and InfiniBand transports for SOAP message exchanges.
I have a large digitized music collection, primarily encoded in lossless FLAC. Great for listening at home. But lossy MP3 is best for mobile devices, in terms of size and the ability of players to handle encoding formats.
So I wrote a script to make parallel MP3 tree of my canonical music collection (which also includes FLAC, WAV, AIFF, MP3, …).
I wrote it in Haskell, with the help of the Shelly shell scripting DSL and ffmpeg
.