This file contains hidden or 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 ConstraintKinds #-} | |
| {-# LANGUAGE ExistentialQuantification #-} | |
| {-# LANGUAGE ImplicitParams #-} | |
| {-# LANGUAGE LambdaCase #-} | |
| {-# LANGUAGE NamedFieldPuns #-} | |
| {-# LANGUAGE NumericUnderscores #-} | |
| {-# LANGUAGE RankNTypes #-} | |
| import Control.Concurrent.Async | |
| import Control.Concurrent.STM |
This file contains hidden or 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
| data Expr = Var String | Val Double | Expr :+ Expr | Expr :- Expr | IfZero Expr Expr Expr | Call String [Expr] | |
| data Fun = Fun String [String] Expr | |
| type VarEnv = [(String, Double)] | |
| type FunEnv = [(String, [Double] -> Double)] | |
| (!) :: Eq k => [(k, v)] -> k -> v | |
| (!) m k = let Just x = lookup k m in x |
This file contains hidden or 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 Control.Concurrent.Async (mapConcurrently_) | |
| import Control.Monad (unless) | |
| import Data.IORef (atomicModifyIORef, newIORef) | |
| import qualified Data.Set as Set | |
| data Tree a | |
| = Leaf a | |
| | Node (Tree a) (Tree a) | |
| deriving (Eq, Ord) |
This file contains hidden or 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
| lens :: (s -> a) -> (s -> b -> t) -> Lens s t a b | |
| lens get set next value = fmap (set value) . next . get $ value | |
| -- | A lens focusing on the first element in a pair | |
| _1 :: Lens (a, x) (b, x) a b | |
| _1 = lens fst (\(_, b) a -> (a, b)) | |
| -- | A lens focusing on the second element in a pair | |
| _2 :: Lens (x, a) (x, b) a b | |
| _2 = lens snd (\(a, _) b -> (a, b)) |
This file contains hidden or 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
| wai-app-static> [8 of 9] Compiling Network.Wai.Application.Static | |
| wai-app-static> <command line>: dlopen(/Users/kana/.stack/snapshots/x86_64-osx/def27b1ecacdb77f75881685fd96d2668745f161ecd98b3d0af4dbc635d00476/8.8.3/lib/x86_64-osx-ghc-8.8.3/libHSzlib-0.6.2.1-KKwzv9jEdPcA1wkhHMXBGy-ghc8.8.3.dylib, 5): Symbol not found: _deflateEnd | |
| wai-app-static> Referenced from: /Users/kana/.stack/snapshots/x86_64-osx/def27b1ecacdb77f75881685fd96d2668745f161ecd98b3d0af4dbc635d00476/8.8.3/lib/x86_64-osx-ghc-8.8.3/libHSzlib-0.6.2.1-KKwzv9jEdPcA1wkhHMXBGy-ghc8.8.3.dylib | |
| wai-app-static> Expected in: flat namespace | |
| wai-app-static> in /Users/kana/.stack/snapshots/x86_64-osx/def27b1ecacdb77f75881685fd96d2668745f161ecd98b3d0af4dbc635d00476/8.8.3/lib/x86_64-osx-ghc-8.8.3/libHSzlib-0.6.2.1-KKwzv9jEdPcA1wkhHMXBGy-ghc8.8.3.dylib | |
| Progress 2/6 | |
| -- While building package wai-app-static-3.1.7.1 (scroll up to its section to see the error) using: | |
| /Users/kana/.stack/setup-exe-cache/x86_64-osx/Cabal-simple_mPHDZzAJ_3. |
This file contains hidden or 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
| Configuring GHCi with the following packages: euler-x | |
| GHCi, version 8.8.3: https://www.haskell.org/ghc/ :? for help | |
| <command line>: dlopen(/Users/kana/.stack/snapshots/x86_64-osx/340f98f9ea009452f04076fd892bf461b0eeaa71d7b50138ccf14c8d26ee89cb/8.8.3/lib/x86_64-osx-ghc-8.8.3/libHSeuler-hs-2.0.1.0-5fgrMNMycsgDcG9RfOl90N-ghc8.8.3.dylib, 5): Symbol not found: _hediszm0zi12zi8zi1zmD5iURytPTh4AjFeSc5mMlw_DatabaseziRedisziTransactions_multiExecWithHash_closure | |
| Referenced from: /Users/kana/.stack/snapshots/x86_64-osx/340f98f9ea009452f04076fd892bf461b0eeaa71d7b50138ccf14c8d26ee89cb/8.8.3/lib/x86_64-osx-ghc-8.8.3/libHSeuler-hs-2.0.1.0-5fgrMNMycsgDcG9RfOl90N-ghc8.8.3.dylib | |
| Expected in: flat namespace | |
| in /Users/kana/.stack/snapshots/x86_64-osx/340f98f9ea009452f04076fd892bf461b0eeaa71d7b50138ccf14c8d26ee89cb/8.8.3/lib/x86_64-osx-ghc-8.8.3/libHSeuler-hs-2.0.1.0-5fgrMNMycsgDcG9RfOl90N-ghc8.8.3.dylib | |
| kana@Andreis-MacBook-Pro euler-x % |
This file contains hidden or 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 Control.DeepSeq (deepseq) | |
| import Control.Lens (ifiltered, itraversed) | |
| import Criterion (bench, bgroup, whnf) | |
| import Criterion.Main (defaultMain) | |
| import Data.Map (Map, filterWithKey, fromList, size, toList) | |
| import Data.Map.Lens (toMapOf) | |
| example :: Map Int Bool | |
| example = fromList [(i, even i) | i <- [10000, 9999 .. 0]] |
This file contains hidden or 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 #-} | |
| import Control.Concurrent (threadDelay) | |
| import Control.Concurrent.Async (async) | |
| import Control.Concurrent.STM (atomically, modifyTVar, newEmptyTMVar, newTVarIO, putTMVar, readTMVar, readTVar, readTVarIO, writeTVar) | |
| cachify :: IO a -> IO (IO a) | |
| cachify action = do | |
| cache <- newTVarIO Nothing | |
| pure do |
This file contains hidden or 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
| namespace nat_insertion_sort | |
| def insert (a : ℕ) : list ℕ → list ℕ | |
| | [] := [a] | |
| | (x::xs) := if a <= x then a::x::xs else x::insert xs | |
| def sort : list ℕ → list ℕ | |
| | [] := [] | |
| | (x::xs) := insert x (sort xs) | |
| #eval sort [3, 1, 2] |
This file contains hidden or 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
| data Tree = Leaf Int | Node Tree Tree | |
| f :: Tree -> Int | |
| f (Leaf x) = x | |
| f (Node a b) = f a + f b | |
| g :: Tree -> Int | |
| g x = go [x] 0 | |
| where | |
| go [] result = result |