I would actually use the installer script:
sudo curl -sSL https://get.haskellstack.org/ | sh
but an older version is on official sources as well (better to the upgrade after)
sudo apt install haskell-stack
stack upgrade
| type Probability = double | |
| type Distribution<'a> = ('a * Probability) list | |
| type Event<'a> = 'a -> bool | |
| let printDistribution (v : Distribution<'a>) = | |
| let negate x = -x | |
| v |> List.sortBy (snd >> negate) |> List.iter (fun (a,p) -> printfn "%A: %.2f%%" a (p * 100.0)) | |
| let sure (a : 'a) : Distribution<'a> = | |
| [a, 1.0] |
| type List<'i,'r> = Nil | Cons of 'i*'r | |
| type FixList<'i> = FixList of List<'i,FixList<'i>> | |
| let rec fmap (f : 'a -> 'b) (l : List<'i,'a>) : List<'i,'b> = | |
| match l with | |
| | Nil -> Nil | |
| | Cons (x, tail) -> Cons (x, f tail) | |
| // you can express hylo directly without using ana and cata (by either following the |
| module SimpleDep | |
| basic : (b : Bool) -> if b then String else Int | |
| basic True = "it's true" | |
| basic False = 0 | |
| ------------- | |
| data WhatIsIt = AString | AInt |
| {-# LANGUAGE GADTs #-} | |
| {-# LANGUAGE TypeFamilies #-} | |
| {-# LANGUAGE DataKinds #-} | |
| {-# LANGUAGE KindSignatures #-} | |
| module DepFun where | |
| data Nat = NatZ | NatS Nat | |
| type family Codom (n :: Nat) where |
| // Projektion | |
| type Key = int | |
| type Projection<'ev,'st,'res> = | |
| { | |
| init : Key -> 'st | |
| fold : 'st -> 'ev -> 'st | |
| final : 'st -> 'res | |
| } |
| {-# LANGUAGE PartialTypeSignatures #-} | |
| {-# LANGUAGE KindSignatures #-} | |
| {-# LANGUAGE DataKinds #-} | |
| {-# LANGUAGE GADTs #-} | |
| module FinVec where | |
| -- simple representation of naturals | |
| -- DataKinds lifts this to the type-level |
| {-# LANGUAGE InstanceSigs #-} | |
| module ReaderM where | |
| import Control.Monad.Reader | |
| import Control.Monad.State.Strict | |
| import Data.Functor.Identity | |
| data Config = Config { nr :: Int } | |
| main :: IO () |
| #!/usr/bin/env stack | |
| -- stack --resolver lts-9.5 script --package scotty | |
| {-# LANGUAGE OverloadedStrings #-} | |
| import Web.Scotty | |
| import Data.Monoid (mconcat) | |
| main = scotty 3000 $ do |
| module Main where | |
| import Control.Concurrent (threadDelay, MVar, newEmptyMVar, putMVar, tryTakeMVar) | |
| import Data.Maybe (isJust) | |
| import System.IO (hSetBuffering, BufferMode(NoBuffering), stdout) | |
| import System.Posix.Signals (installHandler, Handler(Catch), sigINT, sigTERM) | |