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 TypeFamilies #-} | |
{-# LANGUAGE DataKinds #-} | |
{-# LANGUAGE FunctionalDependencies #-} | |
{-# LANGUAGE ScopedTypeVariables #-} | |
{-# LANGUAGE TypeApplications #-} | |
{-# LANGUAGE RankNTypes #-} | |
{-# LANGUAGE TypeOperators #-} | |
{-# LANGUAGE ConstraintKinds #-} | |
{-# LANGUAGE FlexibleInstances #-} | |
{-# LANGUAGE MultiParamTypeClasses #-} |
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 OverloadedStrings #-} | |
{-# OPTIONS_GHC -fno-warn-incomplete-patterns #-} | |
module Main where | |
import qualified Data.ByteString.Char8 as BS8 | |
import qualified Data.ByteString.Lazy as BSL | |
import qualified Data.ByteString.FastBuilder as Builder | |
-- import qualified Data.ByteString.Builder.Extra as Builder | |
import Data.ByteString.Char8 (ByteString) | |
import Data.Monoid ((<>)) |
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 StandaloneDeriving #-} | |
{-# LANGUAGE FlexibleInstances #-} | |
{-# LANGUAGE TypeFamilies #-} | |
{-# LANGUAGE DataKinds #-} | |
{-# LANGUAGE KindSignatures #-} | |
{-# LANGUAGE TemplateHaskell #-} | |
{-# LANGUAGE ExistentialQuantification #-} | |
{-# LANGUAGE TypeSynonymInstances #-} | |
{-# LANGUAGE OverloadedStrings #-} | |
{-# LANGUAGE ScopedTypeVariables #-} |
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 Control.Concurrent.Async | |
import Control.Concurrent.STM | |
import Control.Exception | |
import Control.Monad | |
import qualified Data.Map as Map | |
import Data.Map (Map) | |
import System.IO.Unsafe | |
-- | Version1 - starts async only when it's evaluated | |
-- Composable |
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 TypeFamilies #-} | |
{-# LANGUAGE FlexibleInstances #-} | |
{-# LANGUAGE UndecidableInstances #-} | |
import Data.Time | |
type family TimeDiff a where | |
TimeDiff UTCTime = NominalDiffTime | |
TimeDiff a = 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
module l1 | |
data UL : Nat -> UniqueType -> UniqueType where | |
Nil : {a:UniqueType} -> UL Z a | |
(::) : {a:UniqueType} -> a -> UL k a -> UL (S k) a | |
data UNat : UniqueType where | |
UZ : UNat | |
US : UNat -> UNat |
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 TypeApplications #-} | |
{-# LANGUAGE UndecidableInstances #-} | |
{-# LANGUAGE KindSignatures #-} | |
{-# LANGUAGE GADTs #-} | |
{-# LANGUAGE DataKinds #-} | |
{-# LANGUAGE MultiParamTypeClasses #-} | |
{-# LANGUAGE FlexibleInstances #-} | |
{-# LANGUAGE FunctionalDependencies #-} | |
import Data.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
{-# LANGUAGE ForeignFunctionInterface #-} | |
import Foreign | |
import Foreign.C | |
foreign import ccall "wrapper" cwrap :: (CInt -> IO CInt) -> IO (FunPtr (CInt -> IO CInt)) | |
foreign import ccall "inside" inside :: FunPtr (CInt -> IO CInt) -> IO () | |
foreign import ccall "another" another :: IO () | |
waiting :: CInt -> IO CInt |
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
data ExceptionInfo = ExceptionIf ThreadId SomeException -- constructor should be hidden | |
throwToEnclosed :: Exception e => ThreadId -> e -> IO () | |
throwToEnclosed to ex = | |
throwTo =<< ExceptionInfo <$> myThreadId <*> pure (SomeException ex) | |
enclosed :: [ThreadId] -> IO a -> IO a | |
enclosed allowed f = mask $ \release -> do | |
result <- newEmptyMVar |
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 MultiParamTypeClasses #-} | |
{-# LANGUAGE FunctionalDependencies #-} | |
{-# LANGUAGE TypeOperators #-} | |
{-# LANGUAGE TypeFamilies #-} | |
{-# LANGUAGE ExplicitNamespaces #-} | |
{-# LANGUAGE DataKinds #-} | |
{-# LANGUAGE FlexibleInstances #-} | |
{-# LANGUAGE FlexibleContexts #-} | |
{-# LANGUAGE UndecidableInstances #-} | |
module Foo where |