Skip to content

Instantly share code, notes, and snippets.

View boris-stepanov's full-sized avatar

Stepanov Boris boris-stepanov

View GitHub Profile
-- stack ghc logger.hs --resolver lts-18.5 -- -O2
-- htop shows 600M leak even when tchans are empty
import Prelude hiding (read)
import Control.Monad
import Control.Concurrent
import Control.Concurrent.STM.TChan
import Control.Concurrent.STM
c :: Int
@boris-stepanov
boris-stepanov / patterns.hs
Created April 27, 2020 20:30
patterns + wildcards
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE RecordWildCards #-}
pattern Point :: Int -> Int
pattern Point{x} = x
{-# COMPLETE Point #-}
foo :: Int
foo = let x = 0 in Point{..}
data WrapAny where
WrapAny :: a -> WrapAny
withAny :: (constraints => a -> b) -> WrapAny -> WrapAny
withAny f (WrapAny x) = -- WrapAny (f x) if satisfying and types matched or just (WrapAny x)
foo :: Char -> Int
foo = fromEnum
bar :: Num a => a -> a
#!/usr/bin/env stack
--stack runghc --package singletons --package text --package filepath -- -ddump-splices
{-# LANGUAGE BlockArguments #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE EmptyCase #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE GeneralisedNewtypeDeriving #-}
{-# LANGUAGE KindSignatures #-}
diff --git a/System/FileLock.hs b/System/FileLock.hs
index e7fbbbc..fdc3b7f 100644
--- a/System/FileLock.hs
+++ b/System/FileLock.hs
@@ -86,8 +81,17 @@ unlockFile (Lock l ref) = do
-- | Perform some action with a lock held. Blocks until the lock is available.
withFileLock :: FilePath -> SharedExclusive -> (FileLock -> IO a) -> IO a
-withFileLock path mode = E.bracket (lockFile path mode) unlockFile
+withFileLock path mode =
'stty' is not recognized as an internal or external command,
operable program or batch file.
2019-10-03 17:35:11.004799: [debug] Checking for project config at: C:\build\SRC\stack.yaml
2019-10-03 17:35:11.049799: [debug] Loading project config file stack.yaml
"tryLockFile C:\\sr\\pantry\\pantry.sqlite3.pantry-write-lock Exclusive"
"tryLockFile succeded C:\\sr\\pantry\\pantry.sqlite3.pantry-write-lock"
"unlockFile C:\\sr\\pantry\\pantry.sqlite3.pantry-write-lock"
"tryLockFile C:\\sr\\stack.sqlite3.pantry-write-lock Exclusive"
"tryLockFile succeded C:\\sr\\stack.sqlite3.pantry-write-lock"
"unlockFile C:\\sr\\stack.sqlite3.pantry-write-lock"
Host Name: B166906F01EB
OS Name: Microsoft Windows Server 2019 Standard
OS Version: 10.0.17763 N/A Build 17763
OS Manufacturer: Microsoft Corporation
OS Configuration: Standalone Server
OS Build Type: Multiprocessor Free
Registered Owner: N/A
Registered Organization: N/A
Product ID: 00431-40000-00000-AA732
Original Install Date: 4/3/2019, 11:54:17 PM
@boris-stepanov
boris-stepanov / Setup.hs
Created September 10, 2019 20:21
Setup.hs with Thrift support
{-# LANGUAGE NoImplicitPrelude #-}
--{-# LANGUAGE TupleSections #-}
{-# OPTIONS_GHC -Wall -Wcompat -Wincomplete-uni-patterns -Wincomplete-record-updates -Wmissing-exported-signatures -Wmissing-home-modules -Widentities -Wredundant-constraints #-}
module Main where
import Distribution.Simple
import Distribution.Simple.Glob
import Distribution.Simple.Setup
--import Distribution.Simple.PreProcess
stack test --verbose [0:21:01]
Version 1.9.1, Git revision f9d0042c141660e1d38f797e1d426be4a99b2a3c (6168 commits) x86_64 hpack-0.31.0
2018-10-22 00:21:04.887076: [debug] Checking for project config at: /home/haskell/stack/stack.yaml
2018-10-22 00:21:04.887294: [debug] Loading project config file stack.yaml
2018-10-22 00:21:04.888721: [debug] Decoding build plan from: /home/haskell/.stack/build-plan/lts-11.22.yaml
2018-10-22 00:21:04.888782: [debug] Trying to decode /home/haskell/.stack/build-plan-cache/lts-11.22.cache
2018-10-22 00:21:04.891632: [debug] Success decoding /home/haskell/.stack/build-plan-cache/lts-11.22.cache
2018-10-22 00:21:04.895524: [debug] Run process: /sbin/ldconfig -p
2018-10-22 00:21:04.897145: [debug] Process finished in 2ms: /sbin/ldconfig -p
2018-10-22 00:21:04.898075: [debug] Did not find shared library libtinfo.so.5