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 QuasiQuotes #-} | |
> {-# LANGUAGE EmptyDataDecls #-} | |
> import Control.Comonad | |
> import Language.Haskell.Codo | |
> data Input a | |
> data Output 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
Consider a data type representing syntax trees. | |
> data Expr = BinOp Expr Expr | Unop Expr | |
> data Stmt = Seq Stmt Stmt | Assign String Expr | |
Let's say I want this in a module, but I also want to be able to arbitrarily extend this AST type | |
in modules that import it. So, I add an extra constructor and a type parameter | |
to all the data type definitions: | |
> data Expr ext = BinOp (Expr ext) (Expr ext) | Unop (Expr ext) | Ext ext |
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
* https://www.haskell.org/ghc/docs/7.8.2/html/users_guide/prof-compiler-options.html | |
GHC profiling options | |
* http://lambdor.net/?p=258 | |
Describes how to install profile libraries | |
* http://www.haskell.org/pipermail/haskell-cafe/2009-April/060482.html |
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
instance (Arbitrary a) => Arbitrary (Matrix a) where | |
-- NB: for square matrices | |
arbitrary = sized (\n -> do xs <- vectorOf (n*n) arbitrary | |
return $ matrix n n (\(i, j) -> xs !! ((i-1)*n + (j-1)))) |
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
define :sequence do |xs,tp| | |
xs.each do |ys| | |
in_thread do | |
if (ys[0] == :zawa || ys[0] == :tb303 || ys[0] == :pulse || ys[0] == :s) then | |
synth = ys[0] | |
zs = ys[1..-1] | |
else | |
synth = :tri | |
zs = ys | |
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
{- | |
Proof of concept for adding linearity constraints on the communication-patterns | |
of Cloud Haskell. | |
Uses the 'effect-monad' package for embedding effect systems in Haskell types: | |
cabal install effect-monad | |
-} |
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 CatToMon where | |
open import Data.Product | |
open import Data.Sum | |
open import Data.Unit | |
open import Data.Empty | |
open import Level | |
open import Relation.Binary.PropositionalEquality | |
open import Relation.Nullary.Decidable | |
open import Relation.Binary |
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
class Pretty t where | |
type ExtraInfo t | |
pprint :: FortranVersion -> t -> ExtraInfo t -> Doc | |
instance Pretty (Expression a) where | |
type ExtraInfo (Expression a) = () | |
pprint v e () = ... | |
instance Pretty (Block a) where | |
type ExtraInfo (Block a) = Int -- indent level |
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 Category where | |
open import Level | |
open import Relation.Binary.PropositionalEquality | |
open Level | |
record Category {lobj : Level} {larr : Level} : Set (suc (lobj ⊔ larr)) where | |
field obj : Set lobj | |
arr : (src : obj) -> (trg : obj) -> Set larr |
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
% Highlight comments in darkgreen | |
\definecolor{darkgreen}{rgb}{0,0.5,0} | |
\newcommand{\commenthighlight}{\color{darkgreen}\quad-{}- } | |
\let\onelinecomment=\commenthighlight | |
% Highlight constructors in darkblue | |
\definecolor{darkblue}{rgb}{0,0,0.5} | |
\renewcommand{\Conid}[1]{\textcolor{darkblue}{\textit{#1}}} |
OlderNewer