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 LambdaCase #-} | |
{- | |
cabal v2-install --lib hxt | |
cabal v2-install --lib hxt-xpath | |
cabal v2-install --lib http-client | |
cabal v2-install --lib http-client-tls | |
-} | |
import Text.XML.HXT.Core (runX, readString, withParseHTML, withWarnings) |
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 GHC | |
import GHC.Paths | |
main = | |
do | |
putStrLn $ "libdir = " ++ libdir | |
(runGhc (Just libdir) $ execStmt "print $ 1+1" execOptions) >> pure () | |
putStrLn "We are done" |
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
λ> :{ | |
> second (x:y:xs) = y : second xs -- returns every second element of a list | |
> second _ = [] | |
> | |
> xs = [1,2,3,4] ++ second xs | |
> :} | |
λ> second [1,2,3,4] | |
[2,4] | |
λ> second $ second [1,2,3,4] | |
[4] |
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 Vector where | |
data Vector = Vector Int Int | |
add (Vector x0 y0) (Vector x1 y1) = Vector (x0+x1) (y0+y1) | |
inverse (Vector x0 y0) = Vector (-x0) (-y0) | |
subtract v0 = add v0 . inverse | |
-- the above is equivalent to `subtract v0 v1 = add v0 (inverse v1) |
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 Rank2Types, ScopedTypeVariables #-} | |
newtype StateT s m a = StateT { runStateT :: s -> m (a, s) } | |
newtype ReaderT r m a = ReaderT { runReaderT :: r -> m a } | |
newtype Identity a = Identity { runIdentity :: a } | |
{- class Monad m where | |
return :: a -> m a | |
(>>=) :: m a -> (a -> m b) -> m b -} | |
data MonadI m = MonadI { |
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
λ> :t +v join @((->) Int) | |
join @((->) Int) | |
:: forall a. Monad ((->) Int) => (Int -> Int -> a) -> Int -> 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
foldr @[] ( | |
\elm -> \case | |
(k, i):rest -> if (elm == k) then (k,i+1):rest else (elm, 1):(k, i):rest | |
[] -> [(elm,1)] | |
) [] "aaaabbbcca" |
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 -fforce-recomp #-} | |
module V where | |
data LExpr = Var String -- Variable | |
| App LExpr LExpr -- Funktionsapplikation | |
| Lam String LExpr -- Lambda-Abstraktion | |
newVar :: [String] -> String |
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
sealed trait Kind | |
case object B extends Kind | |
case object C extends Kind | |
sealed trait Test { | |
type K <: Kind | |
val kind: K | |
} |
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
-- show running queries (pre 9.2) | |
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query | |
FROM pg_stat_activity | |
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%' | |
ORDER BY query_start desc; | |
-- show running queries (9.2) | |
SELECT pid, age(clock_timestamp(), query_start), usename, query | |
FROM pg_stat_activity | |
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%' |
NewerOlder