Skip to content

Instantly share code, notes, and snippets.

# read
- generic universe of syntax
- Type-directed (optimising) compilation https://dl.acm.org/doi/10.1145/249069.231414
- co-effect systems https://www.doc.ic.ac.uk/~dorchard/publ/coeffects-icfp14.pdf
- (ornamentation)
- (co-de-Bruijn indices)
- find more optimisations
- Jacco
- GHC
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE RankNTypes #-}
module NamedArguments where
import Control.Monad.Trans.Maybe
import Control.Monad.IO.Class (liftIO)
prog x = do
print "hi"
runMaybeT $ do
Right y <- return x
liftIO $ print y -- will only be executed if x matched the pattern `Right y`
print "bye"
module ZebraPuzzle (Resident(..), Solution(..), solve) where
import Prelude hiding (product, not, and, (&&))
import Data.List (find)
import Data.Maybe (fromJust)
import Data.Ix (Ix, range)
import qualified Data.Array as A
import Control.Monad.Trans.State.Lazy (StateT)
import System.IO.Unsafe (unsafePerformIO)
mheinzel@mh-tp-ubu:~/projects/haskellbook-berlin/session-notes/Marathon/gloss-demo$ stack repl
Warning: File listed in gloss-demo.cabal file does not exist: README.md
Warning: File listed in gloss-demo.cabal file does not exist: README.md
gloss-demo-0.1.0.0: configure (lib + exe)
Configuring gloss-demo-0.1.0.0...
gloss-demo-0.1.0.0: initial-build-steps (lib + exe)
Warning: File listed in gloss-demo.cabal file does not exist: README.md
The following GHC options are incompatible with GHCi and have not been passed to it: -threaded
Configuring GHCi with the following packages: gloss-demo
Using main module: 1. Package `gloss-demo' component exe:gloss-demo-exe with main-is file: /home/shared/projects/haskellbook-berlin/session-notes/Marathon/gloss-demo/app/Main.hs
@mheinzel
mheinzel / ElementCounts.hs
Last active November 3, 2016 07:54
Counting letters
import qualified Data.Map.Strict as M
import Data.Map.Strict (Map)
import Data.Tuple (swap)
import Data.List
-- task: map each element to how often it already occured before
-- count "abbcccghabc" -> [1,1,2,1,2,3,1,1,2,3,4]
-- useful helper function:
@mheinzel
mheinzel / MonadFoo.hs
Created August 6, 2016 01:54
Playing around with Reader and Function monad
{-# LANGUAGE InstanceSigs #-}
{-# LANGUAGE TypeOperators #-}
-- First, a simple Reader Monad
newtype Reader r a = Reader { runReader :: (r -> a) }
instance Functor (Reader r) where
fmap :: (a -> b) -> Reader r a -> Reader r b
fmap f (Reader g) = Reader (f . g)
@mheinzel
mheinzel / TestBotListAllMoves.hs
Last active January 29, 2016 12:31 — forked from lksnmnn/FENBoard_Moves.hs
Chess: FEN-Boards and possible moves
----------------------------------------------------------------------------
-- Test für die Funktion botListAllMoves :: String -> String -> [String]
--
-- Lizenz: MIT
-- Berlin, 25.01.2016
----------------------------------------------------------------------------
import Data.List (sort)
import ChessBot (botListAllMoves)