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
$wbfStep :: EdgeVec -> CostVec -> Vector Dist | |
$wbfStep = | |
\ (w :: EdgeVec) (w1 :: CostVec) -> | |
let { Vector ipv ipv1 ipv2 ~ _ <- w1 `cast` ... } in | |
let { V_3 ipv3 ipv4 ipv5 ipv6 ~ _ <- w `cast` ... } in | |
let { Vector rb _ rb2 ~ _ <- ipv4 `cast` ... } in | |
let { Vector rb3 _ rb5 ~ _ <- ipv5 `cast` ... } in | |
let { Vector rb6 _ rb8 ~ _ <- ipv6 `cast` ... } in | |
runSTRep | |
(\ (@ s) (s :: State# s) -> |
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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
const int infinity = 2147483647; | |
struct edge_t { | |
int v1; | |
int v2; | |
int cost; |
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
*Prelude.Type> T::T (Any ((==) 1) '[3,2,1]) | |
True | |
it :: | |
T (Bool -> Constraint) | |
(Any | |
Nat (Nat == 1) ((':) Nat 3 ((':) Nat 2 ((':) Nat 1 ('[] Nat))))) | |
*Prelude.Type> T::T (Any ((==) 1) '[3,2]) | |
False | |
it :: | |
T (Bool -> Constraint) |
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
> :{ | |
let merge xs [] = xs | |
merge [] ys = ys | |
merge (x:xs) (y:ys) | x < y = x: merge xs (y:ys) | |
| otherwise = y: merge (x:xs) ys | |
:} | |
> :set -XNoMonomorphismRestriction | |
> let mergeAll = foldr1 merge | |
> take 20 $ mergeAll [[5..],[1..],[3..],[7..],[2..],[1..]] | |
[1,1,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,5,6,6] |
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
Prelude> class Pet a where kill :: a -> String | |
Prelude> data Dog = Dog deriving Show | |
Prelude> data Cat = Cat deriving Show | |
Prelude> instance Pet Dog where kill = const "dead" | |
Prelude> instance Pet Cat where kill = const "c_1|dead> + c_2|alive>" | |
Prelude> map kill [Cat, Cat] -- диспетчеризация времени компиляции | |
["c_1|dead> + c_2|alive>","c_1|dead> + c_2|alive>"] | |
Prelude> map kill [Dog, Dog] -- диспетчеризация времени компиляции | |
["dead","dead"] | |
Prelude> data PetBox where Box :: Pet a => a -> PetBox |
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
GHCi, version 7.4.1: http://www.haskell.org/ghc/ :? for help | |
Loading package ghc-prim ... linking ... done. | |
Loading package integer-gmp ... linking ... done. | |
Loading package base ... linking ... done. | |
Prelude> import Control.Exception | |
Prelude Control.Exception> import Data.Typeable | |
Prelude Control.Exception Data.Typeable> | |
newtype Foo = Foo (() -> IO ()) | |
Prelude Control.Exception Data.Typeable> :set -XSafe |
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
Prelude Control.Monad> :set -XDefaultSignatures | |
Prelude Control.Monad> | |
newtype Box a = Box a deriving Show | |
Prelude Control.Monad> | |
instance Monad Box where | |
return = Box | |
(Box x) >>= f = f x | |
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
structure S1 = struct | |
fun foo (x:{cells:int list, columns:int, rows:int}) = (#columns x, #rows x, #cells x) | |
end; | |
structure S2 = struct | |
fun foo (x:{cells:int list, columns:int, rows:int}) = (#columns x, #rows x, #cells x) | |
end; | |
S1.foo {columns = 1, rows = 2, cells = [1,2]}; | |
val it = (1,2,[1,2]) : int * int * int list |
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 -fstatic-argument-transformation #-} | |
module Main (main) where | |
import Criterion.Main | |
import Control.Monad | |
import Data.List | |
import Data.Functor.Identity | |
foldM' :: (Monad m) => (a -> b -> m a) -> a -> [b] -> m 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
mvmap f v = go $ M.length v where | |
go 0 = return () | |
go (n + 1) = update v n f >> go n |