lang
stringclasses
10 values
seed
stringlengths
5
2.12k
haskell
Var -> " variable." Fun -> " function." Data -> " datatype." Constr -> " constructor." Array -> "n array." ArgNum expected found -> "Incorrect number of arguments, found " ++ show found ++ " but was expecting " ++ show expected DimNum expected found -> "Incorrect number of dimensions, found " ++ show found ++ " but was expecting " ++ show expected Type expected found -> "Incorrect type, found " ++ show found ++ " but was expecting " ++ show expected
haskell
module Math.Equal(equal) where equal :: (Eq a, Num a, Ord a, Fractional a) => a -> a -> Bool equal a b | (abs (a - b)) <= 0.011 = True | otherwise = False
haskell
{-# LANGUAGE DataKinds #-} {-# LANGUAGE TypeOperators #-} module ApiType where import Data.Text import Data.Time (UTCTime) import Servant.API
haskell
module Fib where -- | Calculate Fibonacci numbers. -- -- >>> putStrLn "foo" -- foo
haskell
unlines $ [ "Wuss poppin' B?", "/start", "/say &(echo|gangsta) <text>", "/quiz", "/register"
haskell
ponziSchemeMagnitude :: PonziScheme -> Integer ponziSchemeMagnitude scheme = case scheme of Victim _ -> 1 Fraudster _ victims -> case victims of [] ->
haskell
ticksUpdateRate (NonZero x) = label "updating rate and ticking once returns current rate" $ deltaEq 0.005 (rate run) x where run = tick $ update x $ empty 5 1 constantRates :: Property constantRates = label "constant rates" $ \(NonZero x) -> forAll smallNumbers $ \t -> deltaEq 0.005 x $ rate (iterate (tick . update x) (empty 5 1) !! t) clearResetsRate :: Property clearResetsRate = label "reset rate" $ property (clearedRate == 0) where clearedRate = rate $ clear $ updatedRate updatedRate = tick $ update 10 $ empty 5 1
haskell
import qualified Data.ByteString.Lazy as L import Data.Int import qualified Control.Exception as E type ChunkSize = Maybe Int64 {- Gets a remote's configured chunk size. -} chunkSize :: RemoteConfig -> ChunkSize chunkSize m = case M.lookup "chunksize" m of Nothing -> Nothing Just v -> case readSize dataUnits v of Nothing -> error "bad chunksize"
haskell
-- catsup setup -- Simple .hs setup -- -- this is only a test import Distribution.Simple main = defaultMain
haskell
burgerEmoji :: Burger -> Text burgerEmoji _ = " 🍔 " toppingMenu :: [Topping]
haskell
module Main where import Dhall.JSON (Conversion(..)) import Test.Tasty (TestTree) import qualified Control.Exception as Exception import qualified Data.Aeson as Aeson import qualified Data.ByteString.Lazy import qualified Data.Text import qualified Data.Text.IO import qualified Dhall.Core as Core import qualified Dhall.Import import qualified Dhall.JSON import qualified Dhall.JSONToDhall as JSONToDhall
haskell
, D.vcat [ D.fillSep [D.cyan "import","Html"] , "" , D.fillSep [D.green "main","="] , D.indent 2 $ D.fillSep [D.cyan "Html" <> ".text",D.dullyellow "\"Hello!\""] ] , D.reflow $ "Try adding something like that!" , D.toSimpleNote $ "I recommend looking through https://guide.elm-lang.org for more advice on\ \ how to fill in `main` values." ]
haskell
fs <- runIO $ getFilesInDir dir describe ("successfully typechecks files in " ++ dir) $ do forM_ fs $ \f -> do it ((takeFileName f) ++ " typechecks.") $ do res <- parseFromFile (thrillParser <* eof) f shouldSucceed res
haskell
, "ugml (68) -> gyxo, ebii, jptl" , "gyxo (61)" , "cntj (57)" ] spec :: Spec spec = do describe "part 1" $ it "examples" $ day7a example `shouldBe` Just "tknk" describe "part 2" $ it "examples" $
haskell
module Main where import Linear import Maze import System.Environment import System.Random main :: IO () main = do
haskell
_ /\ _ = E mustBeType :: TT Relevance -> Ver () mustBeType ty = conv ty (V typeOfTypes) verify :: Program Relevance -> Either VerFailure () verify prog = runVer (builtins relOfType) $ verProg prog verProg :: Program Relevance -> Ver () verProg prog = do _ <- verTm R prog return () verDefs :: [Def Relevance] -> Ver () verDefs [] = return ()
haskell
let (bus, m) = firstBus minutes $ parseInput $ last xs in bus * m where minutes = read $ head xs extendedEuclid :: (Integral a) => a -> a -> (a, a, a) extendedEuclid 0 b = (b, 0, 1) extendedEuclid a b =
haskell
raw <- getEnv "MANDRILL_API_KEY" resp <- runMandrill (ApiKey $ Text.pack raw) $ let met = Metadata { _metadata_name = "hello" , _metadata_state = STATE_active , _metadata_view_template = "bla" } in Metadata.update met resp `shouldSatisfy` isRight test_add :: Spec test_add = describe "/metadata/add.json" $
haskell
} deriving (Show, Generic) instance FromJSON NtpConfiguration where parseJSON = genericParseJSON defaultOptions instance ToJSON NtpConfiguration where toJSON = genericToJSON defaultOptions
haskell
{-# OPTIONS_GHC -fno-warn-unused-imports #-} -- for Data.Semigroup ----------------------------------------------------------------------------- -- | -- Module : Diagrams.Transform -- Copyright : (c) 2011-15 diagrams-lib team (see LICENSE)
haskell
{-- snippet third --} third (a, b, c) = c {-- /snippet third --} {-- snippet complicated --} complicated (True, a, x:xs, 5) = (a, xs) {-- /snippet complicated --}
haskell
-- log 0 is -Infinity, that's right out -- log 1 is perfectly fine, but let's avoid it anyway for symmetry clipProb = min (1-epsilon) . max epsilon -- TODO: Currently, when finding the gradient at player X, we compute the -- objective function over all games in X's component. But actually the -- gradient for X only depends on the games X participated in, so we could -- compute the objective on a much smaller set of games without affecting the -- gradient. This should be more efficient by a pretty fair margin. For bonus -- points, only partition the game database once for each player and not once -- for each player and each iteration of gradient ascent.
haskell
data FundEx1 = FundConEx1 {z1 :: Integer, y1 :: String} data FundEx2 = FundConEx2 {z3 :: Integer -> String, z4 :: String} --add :: Int -> Int -> Int --add x y = x + y --func = Fund1 {}
haskell
readTodoFile filename = do contents <- readFile filename return $ parseTodoFile filename contents -- XXX: Move to some utility class expandUser :: FilePath -> IO FilePath -- "~" => "/home/foo" expandUser "~" = getHomeDirectory -- "~/bar" => "/home/foo/bar"
haskell
<gh_stars>10-100 module Animate.Preview.Mode where data Mode = Mode'Playback | Mode'Stepper deriving (Show, Eq)
haskell
Datatypes.Coq_nil (LntT.Id_pfc Datatypes.O)) (Datatypes.Coq_pair (Datatypes.Coq_cons (LntT.Var Datatypes.O) Datatypes.Coq_nil) (Datatypes.Coq_cons (LntT.Var Datatypes.O) Datatypes.Coq_nil))))) seq :: Datatypes.Coq_list (Datatypes.Coq_prod (Datatypes.Coq_prod (Datatypes.Coq_list (LntT.PropF Datatypes.Coq_nat)) (Datatypes.Coq_list (LntT.PropF Datatypes.Coq_nat))) LntT.Coq_dir) seq = Datatypes.Coq_cons (Datatypes.Coq_pair (Datatypes.Coq_pair (Datatypes.Coq_cons (LntT.Var Datatypes.O) Datatypes.Coq_nil) (Datatypes.Coq_cons (LntT.Var Datatypes.O) Datatypes.Coq_nil)) LntT.Coq_fwd) Datatypes.Coq_nil example2 :: DdT.Coq_derrec
haskell
translate :: Char -> Either Char Char translate 'G' = Right 'C' translate 'C' = Right 'G' translate 'T' = Right 'A' translate 'A' = Right 'U' translate c = Left c
haskell
withoutHeader :: Proxy (Get '[JSON] (Headers '[] Body)) withoutHeader = Proxy toApp :: (HasMock api '[]) => Proxy api -> IO Application toApp api = return $ serve api (mock api (Proxy :: Proxy '[])) with (toApp withHeader) $ do it "serves arbitrary response bodies" $ do
haskell
Nothing -> left $ ServantErr 400 "User not found" "" [] checkAuth :: Maybe Text -> EitherT ServantErr IO (JWT VerifiedJWT) checkAuth = maybe unauthorized (runCheck . decodeAndVerifySignature jwtSecret) where runCheck Nothing = unauthorized runCheck (Just verifiedJWT) = return verifiedJWT unauthorized = left $ ServantErr 401 "You are not authenticated. Please sign-in" "" [] api :: Proxy AppAPI api = Proxy
haskell
-- https://www.codewars.com/kata/609eee71109f860006c377d1/train/haskell lastSurvivor :: String -> [Int] -> Char lastSurvivor text indices = head survivors where survivors = foldl remove text indices :: String remove :: String -> Int -> String remove text 0 = tail text
haskell
map classifySingleVec . toRows where classifySingleVec :: Vector -> Label classifySingleVec vec = snd $ maximumBy (\x y -> fst x `compare` fst y) $ map `flip` param $ mapToFst $ \Class{ class_min = center, class_cov = cov } -> mahalanobis center cov vec infoStringForParam :: ClassificationParam -> String infoStringForParam = intercalate "\n"
haskell
partializeTargets cset us = (cset, fmap (partialize cset . U) us) ppBindings size vars vals = let nonZero 0 = Nothing nonZero n = Just n in Pretty.prettyPrint $ sizedPpVals (nonZero size) (zip vars vals)
haskell
<style> body { margin: 0; padding: 0; } </style> <script> // Force Strict-URL Routing for assets relative paths (function onload() { if (!window.location.href.endsWith("/")) { window.location.href += "/"; }
haskell
parseUrlPiece _ = Left "Invalid side (should be BUY or SELL)" data OrderType = LIMIT | MARKET
haskell
-- * Crypto , SL.OptimumCrypto , StandardCrypto -- * CannotForge , TOptimumCannotForge (..) , toptimumCheckCanForge -- * Type instances , ConsensusConfig (..)
haskell
someFunc = unsafePerformIO $ printHelp mainAct [] = do putStrLn "Needs a greeting!" printHelp exitFailure mainAct args = do let greeting = unwords args name <- lookupEnv "USER" putStrLn $ maybe "no user to greet!" (\name -> greeting ++ "" ++ name) name
haskell
import GHC.Generics import Data.Map (Map) type Dependency = Map StackName [StackName] -- list of nodes with outgoing edge targets data Stack = Stack {sStackId :: StackId, sStackName :: StackName, sExports :: [Export]} deriving Show newtype Stacks = Stacks { sStacks :: [Stack]} deriving Show newtype Export = Export { eName :: ExportName} deriving Show newtype StackName = StackName String deriving (Generic, Eq, Ord)
haskell
if (y`mod`3) == 0 then m * 20 else (m`div`2) * 39 + (m`mod`2) * 20 days :: [Int] -> Int days [y,m,d] = let yd = y2d (y - 1) md = m2d y (m - 1) dd = d - 1 in yd+md+dd
haskell
walkInside m old d = if inside then new else old where new = walk old d inside = Map.member new m square = Map.fromList [((x, y), toNum x y) | x <- [0..2], y <- [0..2]] where toNum x y = x + y * 3 + 1 diamond = Map.fromList $ row0 ++ row1 ++ row2 ++ row3 ++ row4 where row0 = [((2, 0), 1)] row1 = [((i, 1), i + 1) | i <- [1..3]] row2 = [((i, 2), i + 5) | i <- [0..4]] row3 = [((i, 3), i + 9) | i <- [1..3]]
haskell
-- n.b. ndays IS NOT diffDays to from (weekends and holidays don't count) top5sRuns :: Archive Top5s -> Map Symbol [Run] top5sRuns top5s = undefined -- there! -- 2. Now, let's do more focused runs. If a stock is hi-lo-hi-lo that's one -- thing but if it's hi-hi-hi-hi, that's quite another thing. We're going to -- focus runs on leaders or losers, then: leaders or losers by category top5sLeadersRuns, top5sLosersRuns :: Archive Top5s -> Map Symbol [Run]
haskell
import Pid import MPlayer import Test.Hspec
haskell
-- 2. Now we post the form with all of our credentials. let form' = form <> ["identity" := _email, "credential" := _password] Just code <- fmap (xcode . BC.unpack) <$> findRedirect authURL (fopts & params .~ gparams
haskell
PrepareSSH -> [ "_init_", methodArg m ] DockerChroot -> [ "_chroot_", methodArg m ] (DockerBuild x) -> [ "_docker_", show x, methodArg m ] Root -> [ methodArg m ] parseRecipes :: [String] -> (Recipes, Method) parseRecipes = \case ("_init_":arg:[]) -> (PrepareSSH, appMethod arg) ("_chroot_":arg:[]) -> (DockerChroot, appMethod arg)
haskell
-- 3. myFst = fst -- Match the function names to their types
haskell
data Buffer = Buffer { context :: (Integer, Integer), config :: Configuration, contents :: String, cursorPos :: Integer } deriving Show moveCursor' :: Buffer -> Integer -> Update ()
haskell
it "iso8859_4" $ test @"enc-pkg/encoding:iso8859_4" encString decString it "iso8859_10" $ test @"enc-pkg/encoding:iso8859_10" encString decString it "iso8859_13" $ test @"enc-pkg/encoding:iso8859_13" encString decString it "cp1257" $ test @"enc-pkg/encoding:cp1257" encString decString it "gb18030" $ test @"enc-pkg/encoding:gb18030" encString decString it "gb18030" $ test @"enc-pkg/encoding:gb18030" encString decString OneBit -> do it "koi8_r" $ test @"enc-pkg/encoding:koi8_r" encString decString it "koi8_u" $ test @"enc-pkg/encoding:koi8_u" encString decString it "iso8859_1" $ test @"enc-pkg/encoding:iso8859_1" encString decString it "iso8859_2" $ test @"enc-pkg/encoding:iso8859_2" encString decString
haskell
module ListZip where import Language.Haskell.Liquid.Synthesize.Error {-@ zip' :: xs: [a] -> {ys:[b] | len ys == len xs} -> {v:[(a, b)] | len v == len xs} @-} zip' :: [a] -> [b] -> [(a, b)] zip' x_S0 x_S1 = case x_S0 of [] -> [], b) (:) x_Sl x_Sm -> case x_S1 of [] -> error " Dead code! " (:) x_S14 x_S15 -> (:), b) (x_Sl, x_S14) (zip' x_Sm x_S15)
haskell
writeFiles schnorr6 writeFiles checkSigHashAllTx1 noJetSubst :: (TyC a, TyC b) => Simplicity.Elements.Dag.NoJetDag a b -> WrappedSimplicity a b noJetSubst = Simplicity.Elements.Dag.jetSubst example_hashBlock :: ExampleNoJets (Hash, Block) Hash
haskell
instance Convertible' a b => Convertible (NonEmpty a) [b] where convert (a:|as) = convert' a : fmap convert' as instance Convertible' a b => PartialConvertible [a] (NonEmpty b) where type ConversionError [a] (NonEmpty b) = SimpleConversionError convertAssert = \case [] -> Just SimpleConversionError _ -> Nothing unsafeConvert (a:as) = convert' a :| fmap convert' as ; {-# INLINE unsafeConvert #-}
haskell
import qualified Bool name1 = "Point'" data T1 a b = C4 a b d1 = () name4 = "mkPoint" name5 = "getX" d5 = d5_1 where d5_1 (Point.C4 v0 _) = cast v0
haskell
<gh_stars>10-100 -- !!! Exporting unknown constructor module M(T(K1,K2)) where data T = K1
haskell
<gh_stars>0 import Distribution.Simple import System.Process main = defaultMainWithHooks simpleUserHooks{ postBuild = gfPostBuild } where gfPostBuild _ _ _ _ = callCommand "gf -make AnnaEngQ.gf AnnaEngR.gf AnnaAct.gf"
haskell
-- -- module E'12'18 where
haskell
( tests ) where import Cardano.Prelude import Data.Aeson
haskell
import System.FilePath (FilePath, (</>), (<.>)) -------------------------------------------------------------------------------- -- PATHS -------------------------------------------------------------------------------- cssFilePath :: String -> FilePath cssFilePath cssName = "/static/css/" </> cssName <.> "css"
haskell
, swapTVar ) import Pregame.GhcPrim writeTVarIO :: TVar a -> a -> IO () writeTVarIO tvar a = atomically (writeTVar tvar a) modifyTVarIO :: TVar a -> (a -> a) -> IO () modifyTVarIO tvar f = atomically (modifyTVar tvar f) modifyTVarIO' :: TVar a -> (a -> a) -> IO ()
haskell
import qualified Text.Pretty.Note as N import Text.Pretty.Semantic import Hedgehog result :: String -> T.Text -> T.Text result file contents = case parseStmts (SourcePos name 1 1) (L.fromStrict contents) of Right res-> displayPlain $ Right <$> vsep (map pretty res) Left e -> displayPlain $ prettyErr e where name = T.pack file prettyErr = N.format (N.fileSpans [(name , contents)] N.defaultHighlight)
haskell
parseLine :: String -> [Float] parseLine s = map read $ words $ replace ',' ' ' s parseTriangle :: (Fractional a, Ord a) => [a] -> ((a, a), (a, a), (a, a)) parseTriangle xs = let (x1:y1:x2:y2:x3:y3:[]) = xs
haskell
module IHP.Breadcrumb.Types where import IHP.Prelude import Text.Blaze.Html (Html) import Text.Blaze.Html.Renderer.String (renderHtml) import ClassyPrelude
haskell
putStrLn $ intercalate "\n" $ map formatReference references formatReference reference = (Github.gitObjectSha $ Github.gitReferenceObject reference) ++ "\t" ++ (Github.gitReferenceRef reference)
haskell
import MathlibBench.Config -- A secret is a string of printable ASCII chars excluding DEL (ASCII char 127). -- This means it may contain characters between 32 and 126 (inclusive). newtype Secret = Secret { fromSecret :: ByteString }
haskell
citingDomain :: MState -> CitingUpdateUnit -> [Setting CitingUpdateUnit] citingDomain ms uu = do s <- [Own, Shared] t <- M.keys $ stPhis ms case s of Shared -> do c <- S.toList $ uuCites uu return $ SharedSetting t c
haskell
fibs1 = [ fib x | x <- [1 ..] ] fibs2' = 0 : 1 : cont fibs2' where cont [] = [] cont (a : b : cs) = a + b : cont (b : cs) -- or the super simple fibs2 = 1 : 1 : zipWith (+) fibs2 (tail fibs2) data Stream a = Cons a (Stream a) streamToList :: Stream a -> [a] streamToList (Cons x xs) = x : streamToList xs
haskell
import qualified Data.Text.Lazy.IO as LazyText import qualified Nix.Derivation as Nix import qualified MemoIO loadDerivation :: FilePath -> IO Nix.Derivation loadDerivation = MemoIO.memoIO go
haskell
SMkProduct :: Sing a -> Sing b -> Sing (MkProduct a b) ----- class Generic (a :: Type) where type Rep a :: Type from :: a -> Rep a to :: Rep a -> a class PGeneric (a :: Type) where type PFrom (x :: a) :: Rep a type PTo (x :: Rep a) :: a class SGeneric k where
haskell
pretty (Var n) = char 'v' <> int n -- --------------------------------------------------------------------------- v0, v1, v2, v3 :: Var v0 = Var 0 v1 = Var 1 v2 = Var 2 v3 = Var 3
haskell
++ concatMap (\a -> show a ++ " ") vars ++ "=" ++ "\n" ++ concatMap (\(name, tys) -> show name ++ " "
haskell
, toggler ) where import Control.Lens import Control.Monad.Fix import Control.Monad.IO.Class
haskell
(obj .:? "DisplayName") <*> (obj .:? "DomainJoinInfo") <*> fmap (fmap (fmap unBool')) (obj .:? "EnableDefaultInternetAccess") <*> (obj .:? "ImageArn") <*> (obj .:? "ImageName") <*> (obj .: "InstanceType") <*> (obj .:? "Name") <*> (obj .:? "VpcConfig") parseJSON _ = mempty -- | Constructor for 'AppStreamImageBuilder' containing required fields as -- arguments. appStreamImageBuilder :: Val Text -- ^ 'asibInstanceType' -> AppStreamImageBuilder
haskell
renderDot (Declaration t ats) = do indent renderDecType t renderAttributes ats finishCommand newline renderDot (Subgraph name content) = do indent tell "subgraph"
haskell
) where import Prelude hiding (seq) import Control.Monad (void) import Data.Text (Text) import qualified Data.Text as Text import qualified Data.Char as Char
haskell
where d = x `div` 100 d2 = d `mod` 10 foldBool :: a -> a -> Bool -> a foldBool x y bool = case bool of True -> x False -> y foldBool' :: a -> a -> Bool -> a foldBool' x y bool | bool == True = x | bool == False = y g :: (a -> b) -> (a, c) -> (b, c)
haskell
<> " flashMessages <- IHP.Controller.Session.getAndClearFlashMessages\n" <> " let viewContext = ViewContext {\n" <> " requestContext = ?requestContext,\n" <> " -- user = currentUserOrNothing,\n" <> " flashMessages,\n" <> " controllerContext = ?controllerContext,\n" <> " layout = let ?viewContext = viewContext in defaultLayout\n" <> " }\n" <> " pure viewContext\n" viewLayoutHs = "module " <> applicationName <> ".View.Layout (defaultLayout, Html) where\n" <> "\n"
haskell
<gh_stars>0 {-# LANGUAGE MultiParamTypeClasses, DeriveGeneric #-} module Main where import Flow.Net
haskell
-- for Farey of order n fordCircles :: Integer -> [(Float, Float, Float)] fordCircles = fmap fordCircle . farey fordCirclesScaled :: Float -> Integer -> [(Float, Float, Float)] fordCirclesScaled scale = fmap (fordCircleScaled scale) . farey midFirst :: (Eq a) => [a] -> [a] midFirst xs = nub (mid:xs) where mid = xs !! (length xs `div` 2)
haskell
Nothing -> (tileMatrix, edgeMap, found, tileMap) Just tile -> foldl (placeTile tileId coords) (tileMatrix, edgeMap, found, tileMap) (zip [STop, SRight, SBottom, SLeft] (tileToEdges tile)) placeTile :: Int -> (Int, Int) -> (TileMatrix, EdgeMap, HS.HashSet Int, TileMap) -> (Side, (Int, Int64)) -> (TileMatrix, EdgeMap, HS.HashSet Int, TileMap) placeTile tileId coords (tileMatrix, edgeMap, found, tileMap) (side, (edge, edgeHash)) = fromMaybe (tileMatrix, edgeMap, found, tileMap) (do tileIds <- HM.lookup edgeHash edgeMap nextTileId <- find (/= tileId) (HS.toList tileIds) isFound <- checkSet nextTileId found
haskell
processParser :: Parser Process processParser = nullParser <|> prefixParser <|> parallelParser -- null process nullParser :: Parser Process nullParser = do reserved "word" name <- identifier return $ Lexeme name prefixParser :: Parser Process
haskell
{-# language OverloadedStrings #-} {-# language FlexibleContexts #-} {-# language RankNTypes #-} {-# language ViewPatterns #-} module Web.Firefly.Handler ( route ) where import Web.Firefly.Types import Web.Firefly.Request import Web.Firefly.Response import Control.Monad -- | Run a handler on a matching route.
haskell
| TArrow (Type, Type) | TApp (Type, Type) deriving (Show{-,Read-}) data DataDecl
haskell
<gh_stars>0 -- | Este módulo define funções comuns da Tarefa 4 do trabalho prático. module Tarefa4_2019li1g044 where import LI11920 import Tarefa0_2019li1g044 import Tarefa1_2019li1g044 import Tarefa2_2019li1g044 import Tarefa3_2019li1g044
haskell
vectorCmEfs n = VS.foldl' (+) 0 $ VS.concatMap (\(!x) -> VS.enumFromStepN 1 1 x) $ VS.enumFromStepN 1 1 n {-# NOINLINE vectorCmEfs #-} flattenCmEfs :: Int -> Int flattenCmEfs n = VS.foldl' (+) 0 $ VS.flatten mk step Unknown $ VS.enumFromStepN 1 1 n where mk x = (x,1) step (x,k) | k>x = VS.Done | otherwise = VS.Yield k (x,k+1) {-# NOINLINE flattenCmEfs #-} -- concatMap / concatMap
haskell
= flip catch handleTLSHandshakeFailed $ flip catch handleIOException $ http request manager where handleIOException (e :: IOException) = throwIO $ FailedConnectionException (unpack $ decodeUtf8 $ host request) (port request) handleTLSHandshakeFailed (e :: TLS.HandshakeFailed) = throwIO $ FailedConnectionException (unpack $ decodeUtf8 $ host request)
haskell
import Test.QuickCheck import Web.HttpApiData import Cardano.Wallet.API.Types.UnitOfMeasure (MeasuredIn (..), UnitOfMeasure (..)) import Cardano.Wallet.Orphans.Aeson () -- V0 logic import Pos.Util.BackupPhrase (BackupPhrase (..)) import qualified Data.ByteArray as ByteArray
haskell
-------------------------------------------------------------------------------- -- | -- Module : Algorithms.Geometry.SmallestEnclosingBall.RandomizedIncrementalConstruction -- Copyright : (C) <NAME> -- License : see the LICENSE file
haskell
mode = (reserved "linear" >> return makeLinear) <|> (reserved "local" >> return makeLocal) <|> (reserved "active" >> return makeActive) <|> (reserved "shared" >> return makeShared) <|> (reserved "sharable" >> return makeSharable) <|> (reserved "unsafe" >> return makeUnsafe)
haskell
import Control.Lens import Control.Monad (mzero) import Data.Aeson import qualified Data.HashMap.Strict as HM import qualified Data.HashSet as HS import Data.Maybe (fromMaybe) import Data.Text (Text) import qualified Data.Text as T import System.Posix (fileExist) import qualified System.Log.Logger as LOG
haskell
config <- fmap mailConfig (ask :: (ReaderT a IO) a) liftIO $ forkIO $ ML.sendMailWithLogin' (server config) (fromInteger (port config)) (login config) (password config) mail from = Address (Just "Code Qualified") "<EMAIL>" to = [Address (Just "<NAME>") "<EMAIL>"] cc = [] bcc = []
haskell
instance Ord a => Eq (Set a) where set1 == set2 = toAscList set1 == toAscList set2 instance Semigroup (Set a) where set1 <> set2 = set1 `union` set2
haskell
<gh_stars>1000+ import StackTest import System.Directory import Control.Monad (unless) main :: IO () main = do removeDirIgnore "somename" stack ["new", "somename", "./template.hsfiles"] exists <- doesFileExist "somename/somename.cabal" unless exists $ error "does not exist"
haskell
(y:ys) -> r $ (toNaked y : ys) :| xs where (x:|xs) = r xs' r = NE.reverse . fmap reverse isParagraph = \case OrderedList _ _ -> False UnorderedList _ -> False Naked _ -> False
haskell
{-# LANGUAGE TypeApplications #-} module E where import A import B import C import D c :: F (a, C) -> Bool c = id e :: () -> Bool e = c . b @ C
haskell
main = defaultMain
haskell
{-# OPTIONS_GHC -Wall #-} {-# OPTIONS_GHC -Werror #-} -- #3261 module Foo where foo :: Int foo = ceiling 6.3
haskell
import Compiler.Syntax (Lit) data Pattern = PatVar String
haskell
type LineInfo = Int data Identifier = IdExpr IdentifierName TypeName LineInfo -- parsed - eval
haskell
module Day2.Types where data Policy = Policy Int Int Char type Password = String
haskell
import Level.DangerValue import Util data EnemySpawnWaveChoiceRule = MaxOneAnyTurretRule | MaxOneBombRule | MaxOneBubbleTurretRule | MaxOneFlyingRule | MaxTwoFlyingRule
haskell
import Servant import Server -- API for values of type 'a' -- indexed by values of type 'i' type APIFor a i = Get '[JSON] [Entity a] -- list 'a's :<|> ReqBody '[JSON] a :> Post '[JSON] (Maybe i) -- add an 'a' :<|> Capture "id" i :> ( Get '[JSON] (Entity a) -- view an 'a' given its "identifier" of type 'i' :<|> ReqBody '[JSON] a :> PutNoContent '[JSON] NoContent -- update an 'a' :<|> DeleteNoContent '[JSON] NoContent -- delete an 'a' ) serverFor ::
haskell
-- | Log the MidiHeader in the Table monad (cf. Writer). -- tellMidiHeader :: MidiHeader -> Table () tellMidiHeader (MidiHeader fmt tcount td) = localColumns midi_header_columns $ do tellRow $ \_ _ -> [ text "MIDI Format", ppFormat fmt ]
haskell
arg <- getArgs strM <- newEmptyMVar sock <- listenOn $ PortNumber (read (arg!!0) :: PortNumber) forkIO (do forkIO (forever $ do