lang
stringclasses
10 values
seed
stringlengths
5
2.12k
haskell
import Data.IP import Network.DNS hiding (lookup) import Database.Persist import Database.Persist.Sqlite (SqliteConf) import Database.Persist.Zookeeper (ZookeeperConf) instance PersistField IP where toPersistValue (IPv4 ip) = toPersistValue $ fromIPv4 ip toPersistValue (IPv6 ip) = toPersistValue $ fromIPv6 ip fromPersistValue value = do v <- fromPersistValue value
haskell
fresh = lift . fresh instance Fresh m => Fresh (Lazy.StateT s m) where fresh = lift . fresh instance Fresh m => Fresh (Strict.StateT s m) where fresh = lift . fresh instance (Monoid w, Fresh m) => Fresh (Lazy.WriterT w m) where fresh = lift . fresh instance (Monoid w, Fresh m) => Fresh (Strict.WriterT w m) where
haskell
spec :: Spec spec = do describe "looking up keys" $ do it "should return true when a key exists" $ let tokens = [Token "foo" Nothing] in key "foo" tokens `shouldBe` True it "should return false when a key does not exist" $
haskell
parseArgs args = do let (flags, rest, errs) = GO.getOpt (GO.ReturnInOrder (\s -> Remainder s)) arglist args desc <- theDesc flags return $ fromJust $ ((combine desc flags) <|> (tryLens (preview listBuffersDummy) flags >> (ExecBuffers <$> tryLens (preview pid) flags)) <|> (pure ExecShowHelp)) -- |File Format for output:
haskell
-- | Narrowing down the max rank by making a guess that is guided by the number of higher rank cards in the feedback. -- Guess higher rank if the answer contains higher rank cards and vice versa. -- -- Once max rank is found, it prepares to guess the min rank with the knowledge of the known max bound. nextGuess (currentGuess, currentState@(FindingMax maxRankGuess estMinRank history level result)) (correctCards, _, _, higherRanks, _)
haskell
module HaskellWorks.Data.Bits.FixedBitSize ( FixedBitSize(..) ) where import Data.Word import HaskellWorks.Data.Positioning -- | Class of values that have a fix bit size class FixedBitSize a where -- | Get the bit size of a value of given type. -- -- >>> fixedBitSize (undefined :: Word8) -- 8 fixedBitSize :: a -> Count
haskell
import HLearn.Models.Classifiers.NearestNeighbor import HLearn.Models.Classifiers.Perceptron import HLearn.Models.Classifiers.Experimental.Boosting.FiniteBoost import HLearn.Models.Classifiers.Experimental.Boosting.MonoidBoost import HLearn.Models.Regression.PowerLaw
haskell
{-# LANGUAGE PartialTypeSignatures #-} module SkipMany where data GenParser tok st a = GenParser tok st a skipMany' :: GenParser tok st a -> GenParser tok st () skipMany' = undefined
haskell
getters <- makeFieldGetters dataTypes return resolvedModule { getModuleExpressions = getModuleExpressions resolvedModule <> getters
haskell
gradLogNormalObservedVote demProbs (demVote, turnoutCounts) = let Normal m' v' = mconcat $ fmap (\(t,Normal m v) -> Normal (t*m) (v*m))$ zip turnoutCounts demProbs np = zip turnoutCounts demProbs dv = fmap (\(n, p) -> let n' = realToFrac n in n' * (1 - 2 * p)) np dm = turnoutCounts dmv = zip dm dv a1 = negate (1 / v) -- d (log v) a2 = (realToFrac demVote - m) a3 = (a2 * a2) / (2 * v * v) a4 = (a2 / v) in fmap (\(dm, dv) -> (a1 + a3) * dv + a4 * realToFrac dm) dmv
haskell
readEnvironment :: IO Environment readEnvironment = do environment0 <- decodeFileEither environmentName :: IO (Either ParseException Environment) return $ case environment0 of Right v -> v Left _ -> emptyEnvironment writeEnvironment :: Environment -> IO Environment writeEnvironment environment = do encodeFile environmentName environment return environment
haskell
mero_runtime_build_time <- peekCAString =<< [C.exp| const char* { m0_build_info_get()->bi_time } |] return $ printf (intercalate "\n" [ "Halon %s (Git revision: %s)" , "Authored on: %s" , "Built against:" , "Mero: %s (Git revision: %s) (Configure flags: %s)" , "Built on: %s" , "Running against:" , "Mero: %s (Git revision: %s) (Configure flags: %s)"
haskell
import TestUtil import Language.Fortran.Parser.Fortran77 import Language.Fortran.Lexer.FixedForm (initParseState) import Language.Fortran.ParserMonad (FortranVersion(..), evalParse, fromParseResultUnsafe) import Language.Fortran.AST import Language.Fortran.Analysis import Language.Fortran.Analysis.BBlocks
haskell
<gh_stars>0 main = map (+1) [1,2,3,4,5]
haskell
gen <- create arr <- newArrayData n let write ix = unsafeWriteArrayData arr (Sugar.toIndex sh ix) . fromElt =<< f ix gen iter sh write (>>) (return ()) return (arr, undefined) in adata `seq` Array (fromElt sh) adata
haskell
( titleToNumber ) where titleToNumber :: [Excel] -> Int titleToNumber (x:xs) | null xs = a | otherwise = a * 26 ^ length xs + titleToNumber xs
haskell
hasTVPreferredFocus = prop "hasTVPreferredFocus" -- Platform: IOS tvParallaxProperties :: Has c "tvParallaxProperties" => TvParallaxProperties -> Props c handler tvParallaxProperties = prop "tvParallaxProperties" instance Has TouchableHighlight "activeOpacity" instance Has TouchableHighlight "onHideUnderlay"
haskell
import Data.Maybe(fromJust) import GHC.Generics(Generic) import Clash.Prelude(NFDataX, mealy) conName :: M.Map TH.Name TH.Name -> TH.Name -> TH.Name
haskell
wrapTruncate go pFilePath off pFuseFileInfo = handleAsFuseError $ do filePath <- peekFilePathOrEmpty pFilePath mfh <- getFH pFuseFileInfo go filePath mfh off wrapOpen :: (FilePath -> OpenMode -> OpenFileFlags -> IO (Either Errno fh)) -> C.COpen wrapOpen go pFilePath pFuseFileInfo = handleAsFuseError $ do filePath <- peekFilePath pFilePath (openFileFlags, openMode) <- peekOpenFileFlagsAndMode pFuseFileInfo go filePath openMode openFileFlags >>= \case Left errno -> pure errno Right fh -> do
haskell
) where import GitHub.Login.Client (GitHubLoginClient) import GitHub.Login.Device as GitHub import GitHub.Login.Test.Helper (shouldResponseAs) import Test.Tasty import Test.Tasty.Hspec specWith :: GitHubLoginClient c => c -> IO TestTree specWith client = testSpec "GitHub.Login.Device" $ do
haskell
("2 + 5", Constant 7), ("10 - 5", Constant 5), ("5 * 2", Constant 10), ("20 / 2", Constant 10), ("-1.0", Constant (-1)),
haskell
renderRuneLit :: Render Go.RuneLit renderRuneLit x = case x of Go.RuneLit_UnicodeValue y -> mappend "'" . renderUnicodeValue y . mappend "'" Go.RuneLit_ByteValue y -> mappend "'" . renderByteValue y . mappend "'" renderUnicodeValue :: Render Go.UnicodeValue renderUnicodeValue x = case x of Go.UnicodeValue_UnicodeChar y -> renderUnicodeChar y Go.UnicodeValue_LittleUValue y -> renderLittleUValue y Go.UnicodeValue_BigUValue y -> renderBigUValue y
haskell
list :: Default a => [Term a] -> Term a list = defaultTerm . ExpressionList listType :: Type -> Type listType = TypeList
haskell
import Control.DeepSeq import Control.Lens import Data.Bifunctor import Data.Ext import Data.Geometry.Point import Data.Geometry.Properties import Data.Geometry.Transformation import Data.Geometry.Vector import qualified Data.Geometry.Vector as V import qualified Data.List.NonEmpty as NE import qualified Data.Range as R import qualified Data.Semigroup.Foldable as F import qualified Data.Vector.Fixed as FV
haskell
module T7969a where data T = MkT
haskell
withLocalKadenamintNetwork 3 $ \root -> \case [n0, n1, _n2] -> timelineCoinContract root n0 n1 _ -> impossible withKadenamintNode :: MonadIO m => KadenamintNode -> m () withKadenamintNode kn = liftIO $ do let tn = _kadenamintNode_tendermint kn home = tn ^. tendermintNode_home
haskell
normalizePath f = let f' = map (\x -> if x == '\\' then '/' else x) f in if "./" `isPrefixOf` f' then drop 2 f'
haskell
-- | /O(m)/ where /m/ is the number of feature values. Computes the -- frequency of the given label from the given conditional prob. table. labelCount :: Num n => CPT -> String -> n labelCount cpt c = sum $ map fromIntegral (M.elems (cpt M.! c)) -- | /O(l m)/ Calculate the number of training instances from a CPT. dataLength :: Num n => CPT -> n dataLength = fromIntegral . sum . map (sum . M.elems) . M.elems
haskell
import Data.Text (Text) import GHC.Generics data Card = Card { cardId :: Text , name :: Text , cardSet :: Maybe Text , img :: Maybe Text , imgGold :: Maybe Text } deriving (Show, Generic) instance FromJSON Card where
haskell
import qualified Thrift (ProtocolExnType(..)) import Thrift.Types import Thrift.Serializable import Thrift.Arbitraries data HsFoo = HsFoo
haskell
unless should $ do liftIO GLFW.pollEvents >> locally action go glfwMainLoopWithState :: GLFW.Window -> Program' () -> Program r () glfwMainLoopWithState = undefined createGLFWVulkanInstance :: String -> Program r VkInstance createGLFWVulkanInstance progName = do -- get required extension names from GLFW glfwReqExts <- liftIO GLFW.getRequiredInstanceExtensions createVulkanInstance
haskell
five= \f x -> f.f.f.f.f$x six :: Church x six= \f x-> f.f.f.f.f.f$x seven :: Church x seven= \f x-> f.f.f.f.f.f.f$x eight :: Church x eight= \f x-> f.f.f.f.f.f.f.f$x nine :: Church x nine= \f x-> f.f.f.f.f.f.f.f.f$x ten :: Church x
haskell
------------------------- -- | Maps to 'bool'. instance Default (Value Bool) where {-# INLINE def #-}
haskell
parse :: String -> [Command] parse str = map toCommand $ chunksOf 2 $ words str where toCommand [dir, dist] = (toDirective dir, read dist) toDirective "forward" = Forward toDirective "down" = Down toDirective "up" = Up solve part commands = horiz * depth
haskell
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud" ((joinWith '-' . splitOn ' ') text) `shouldBe` "Lorem-ipsum-dolor-sit-amet,-consectetur-adipiscing-elit,-sed-do-eiusmod-tempor-incididunt-ut-labore-et-dolore-magna-aliqua.-Ut-enim-ad-minim-veniam,-quis-nostrud" where checkSort :: [Int] -> Bool checkSort [] = True
haskell
let (bw,bh) = rectangleDim (uiBounds info) w = if fromIntegral iw > bw then bw else fromIntegral iw h = if fromIntegral ih > bh then bh else fromIntegral ih in mkRectangle (rectangleTopLeft (uiBounds info)) w h _ -> uiBounds info }
haskell
-- create a new IORef stringRef <- newIORef $ "" string1 <- readIORef stringRef print string1 -- change the value inside stringRef writeIORef stringRef "A"
haskell
tabulateS :: Int -> Stream (Of Int) IO r -> Stream (Of Text) IO r tabulateS cols str = mapsM S.mconcat $ S.chunksOf cols $ S.map withTab str sumAndTabS :: Int -> Stream (Of Int) IO r -> IO Int sumAndTabS cols =
haskell
module Crypto.PubKey.ECC.Generate where import Crypto.Random (CPRG) import Crypto.Types.PubKey.ECC import Crypto.Types.PubKey.ECDSA import Crypto.Number.Generate import Crypto.PubKey.ECC.Prim -- | Generate Q given d. --
haskell
import qualified Data.ByteString.Char8 as C import Data.IP import Data.Serialize (decode) import Data.TCP data Packet = Packet { ipv4Header :: IPv4Header, tcpHeader :: TCPHeader, body :: C.ByteString } deriving Show parseByteString :: C.ByteString -> Packet parseByteString bs = do let ipBs = stripLinkLayerHeader bs
haskell
class Puz p where code :: p -> String instance Puz (Point 2 Float) where -- code p = show (p ^. unsafeCoord 1) ++ " " ++ show (p ^. unsafeCoord 2) code p = unwords $ map (show . (flip view p) . unsafeCoord) [1, 2] instance Puz PuzPath where code (Start p) = " start " ++ code p code (LineTo path p) = code path ++ "\n " ++ "line to " ++ code p code (ArcTo path left wide p) = code path ++ "\n " ++ if left then "left " else "" ++ if wide then "wide " else "" ++ "arc to " ++ code p instance Puz PuzModifier where
haskell
module Models.User where type UserId = Int type FirstName = String type LastName = String
haskell
Type where PoolerDenseF 'RoBERTa gradient device dataType inputEmbedDim = NamedModel (GLinearF 'WithBias gradient device dataType inputEmbedDim inputEmbedDim) type family PoolerActivationF (style :: TransformerStyle) :: Type where PoolerActivationF 'RoBERTa = Tanh instance ( HasForward
haskell
(_testTasksDb_tasks tasksDb) testTask (\_ -> work . unWrappedColumnar) wId allTestTasks :: Connection -> IO [TestTask] allTestTasks c = runBeamPostgres c $ runSelectReturningList $ select $ all_ (_testTasksDb_tasks tasksDb) justOneTestTask :: Connection -> IO (Maybe TestTask) justOneTestTask c = runBeamPostgres c $ runSelectReturningOne $ select $ all_ (_testTasksDb_tasks tasksDb)
haskell
it "Next day for Friday is Saturday" $ do (nextDay Friday) `shouldBe` Saturday it "Next day for Saturday is Sunday" $ do (nextDay Saturday) `shouldBe` Sunday it "Next day for Sunday is Monday" $ do (nextDay Sunday) `shouldBe` Monday afterDaysSpec :: SpecWith () afterDaysSpec = describe "Block1_Task1.afterDays" $ do it "Negative number of days is forbidden" $ do
haskell
module Arkham.Types.AssetId where import ClassyPrelude import Data.Aeson import Data.UUID newtype AssetId = AssetId { unAssetId :: UUID } deriving newtype (Show, Eq, ToJSON, FromJSON, ToJSONKey, FromJSONKey, Hashable) newtype StoryAssetId = StoryAssetId { unStoryAssetId :: AssetId } deriving newtype (Show, Eq, ToJSON, FromJSON, ToJSONKey, FromJSONKey, Hashable) newtype DamageableAssetId = DamageableAssetId { unDamageableAssetId :: AssetId } deriving newtype (Show, Eq, ToJSON, FromJSON, ToJSONKey, FromJSONKey, Hashable)
haskell
import Concordium.Client.Cli import Test.Hspec logSpec :: Spec logSpec = describe "log" $ do prettyMsgSpec prettyMsgSpec :: Spec prettyMsgSpec = describe "prettyMsg" $ do specify "empty without punctuation" $
haskell
{-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE TypeSynonymInstances #-} {-# LANGUAGE TypeOperators #-} {-# LANGUAGE TypeFamilies #-} {-# OPTIONS_GHC -fno-warn-orphans #-} module Generics.Deriving.Instances (
haskell
main :: IO () main = do input <- getContents let evs = readEvents (lines input)
haskell
import Data.List main = do str <- readFile "Problem0022.txt" print $ problem22Value str problem22Value :: String -> Int problem22Value str = sum $ getNameScores $ sort $ lines str getNameScores :: [String] -> [Int] getNameScores names = getNameScores' 1 names
haskell
-} scaledNode :: Topic -> Diagram B scaledNode t = box <> centerXY txt where txt :: Diagram B txt = texterific $ topicName t (th,tw) = (height txt, width txt) sf = 1.5 box = roundedRect (tw * sf) (th * sf) 0.2
haskell
------------------------------------------------------------------------ -- Examples to test eval -- 4! again. et1 = runEval "{ X1 := 1; \ \ while (> val(X0) 0) do { \ \ X1 := (* val(X1) val(X0)); X0 := (- val(X0) 1) }}" {- should have result: skip Locs(!=0): X[1]=24 -} et2 = runEval "let x = 2 in (+ 10 x)"
haskell
| WholeCart deriving (Generic, Show, Eq) data Action = AmountOff Integer Target | PercentOff Integer Target | FreeProduct Slug | ReferralUsed String -- eh why not deriving (Generic, Show, Eq) data Rule = Rule Expression [Action] deriving (Generic, Show, Eq)
haskell
& applyRotorBackward rotor3 & applyRotorBackward rotor2 & applyRotorBackward rotor1 & applyPlugboard plugboard
haskell
rule_Comprehension :: Rule rule_Comprehension = "relation-comprehension{RelationAsMatrix}" `namedRule` theRule where theRule (Comprehension body gensOrConds) = do (gocBefore, (pat, rel), gocAfter) <- matchFirst gensOrConds $ \ goc -> case goc of Generator (GenInExpr pat@Single{} expr) -> return (pat, matchDefs [opToSet, opToMSet] expr) _ -> na "rule_Comprehension" let upd val old = lambdaToFunction pat old val TypeRelation{} <- typeOf rel Relation_AsMatrix <- representationOf rel [m] <- downX1 rel mDom <- domainOf m let (mIndices, _) = getIndices mDom -- we need something like: -- Q i in rel . f(i)
haskell
and0 (b:bs) = b && and0(bs) concat0 :: [[a]] -> [a] concat0 [] = [] concat0 (a : as) | null as = a | otherwise = a ++ concat0 as
haskell
(.||) :: (a -> Bool) -> (a -> Bool) -> a -> Bool (.||) f1 f2 a = f1 a || f2 a -- copied from https://hackage.haskell.org/package/extra-1.7.10/docs/Data-List-Extra.html (!?) :: [a] -> Int -> Maybe a xs !? n | n < 0 = Nothing | otherwise = foldr (\x r k -> case k of
haskell
import Transformations.Substitution (Substitution, apply) import Trees.Tree {-| A state over some type a. -} newtype State a = State a deriving (Eq,Ord,Generic) {-| Show instance for states. -} instance (Show a) => Show (State a) where
haskell
--------------------------- below are for tests utility -------- comment_rem :: BC.ByteString -> BC.ByteString comment_rem "" = "" comment_rem x = let h = BS.head x t = BS.tail x th = BS.head t in case ( h , th ) of ( 47 ,47 ) -> "" otherwise -> BS.cons h (comment_rem t)
haskell
) where import LOGL.Application.Context import LOGL.Mesh import Graphics.GLUtil.ShaderProgram import Codec.Wavefront import Control.Monad.Reader import Control.Monad.IO.Class
haskell
fakeSecret = "fakesecret1" spec :: Spec spec = do describe "signRequest" $ do context "When missing headers" $ do it "Returns 'Nothing' when missing a date header" $ do (signRequest fakeAccess fakeSecret fakeBadGetRequest) `shouldBe` Nothing context "When given valid input data" $ do it "Returns 'Just (Request Text)'" $ do pendingWith "Requires fuller implementation"
haskell
<gh_stars>10-100 module A(main,a) where import B import C(c) main = print (a 42) a x = b x + c x
haskell
start = "sibling" : -- comment ["commented"]
haskell
{-# INLINE pushE #-} sliceB :: MapBuffer a -> Int -> Int -> [a] sliceB (MB pos vec) start num = -- V.toList $ V.slice (pos+start) num vec let ix1 = pos+start top = snd $ M.split (ix1-1) vec in map snd . M.toAscList . fst $ M.split (ix1+num) top {-# INLINE sliceB #-}
haskell
= Header "Authorization" String :> ReqBody '[ SafeJSON] KnowledgeModelChangeDTO :> "caches" :> "knowledge-model" :> Post '[ SafeJSON] (Headers '[ Header "x-trace-uuid" String] KnowledgeModel) list_knowledgeModel_POST :: Maybe String -> KnowledgeModelChangeDTO -> BaseContextM (Headers '[ Header "x-trace-uuid" String] KnowledgeModel) list_knowledgeModel_POST mServiceToken reqDto = runInUnauthService $ addTraceUuidHeader =<< do checkServiceToken mServiceToken mKm <- getFromCache (reqDto ^. events) (reqDto ^. packageId) (reqDto ^. tagUuids) case mKm of Just km -> return km
haskell
% gray(N,C) :- C is the N-bit Gray code Can you apply the method of "result caching" in order to make the predicate more efficient, when it is to be used repeatedly? -} gray :: Int -> [String] gray 0 = [""] gray nb = map (\x -> '0':x) prev ++ map (\x -> '1':x) prev where prev = gray (nb - 1)
haskell
{- This is a way to only expose methods that helps one to construct the ADT and not expose the details behind the ADT. In Haskell , this type of initialization is called as Smart Constructors.
haskell
instance FromJSON Algorithm where parseJSON (String "HS256") = return HS256 parseJSON (String "RS256") = return RS256 parseJSON _ = mzero instance ToJSON StringOrURI where
haskell
, CleanerError (..) ) where import Text.ParserCombinators.Parsec import Text.Parsec.Utils (parseString) testString :: String testString = " \n\ \ a) ungenannt, ohne Namensnennung: \n\ \ein anonymer Verfasser, Brief; \n\
haskell
We support feching daily closing prices for all cryptocurrencies supported by AlphaVantage. Use the `-c` flag to specify which commodities are cryptocurrencies. You can pass the flag multiple times or specify them as a comma-separated list. For the listed cryptocurrencies, we will hit AlphaVantage's Daily Crypto Prices API route instead of the normal Stock Prices route. API LIMITS AlphaVantage's API limits users to 5 requests per minute. We respect this limit by waiting for 60 seconds after every 5 commities we process. You can ignore the rate-limiting by using the `-n` flag, but requests are more
haskell
(([Bool], [Bool]), (IntTF, IntTF, IntTF, IntTF, IntTF, IntTF), (Bool, Bool, Bool, Bool, Bool, Bool, Bool)) oracle_aux_simulate l = run_classical_generic (\u v -> o1_ORACLE_aux l (2^((length u)-1)) (u,v)) -- | A specialized 'show' for oracle auxiliary data. show_oracle_details :: Show a => (([Bool], [Bool]), (a,a,a,a,a,a), (Bool, Bool, Bool, Bool, Bool, Bool, Bool)) -> String show_oracle_details ((u,v),(uint,vint,u17,v17,u3,v3),(uF,vF,uH,vH,t_uv,t_uHvH,t_u3v3)) = (showBits u) ++ " " ++ (showBits v) ++ " " ++ showBits [uF,vF,uH,vH,t_uv,t_uHvH,t_u3v3] ++ " " ++ show [uint,vint,u17,v17,u3,v3]
haskell
putInfo "cleaning files" liftIO $ removeFiles "build" ["*.o", "*.a"] phony "build_cpp" $ do putInfo "building cpp files" dir <- liftIO getCurrentDirectory csrcFiles <- liftIO . listDirectory $ dir </> "csrc" let cppFiles = filter (isExtensionOf "cpp") csrcFiles cppFilesO = map (overFileName $ (-<.> "o")) cppFiles _ <- need $ map (flip replaceDirectory "build") cppFilesO need ["buildLib"] overFileName :: (String -> String) -> FilePath -> FilePath overFileName f p = replaceFileName p . f . takeFileName $ p
haskell
cardBeats :: Card -> Card -> Bool cardBeats givenCard c = ((suit givenCard) == (suit c)) && (rankBeats (rank givenCard) (rank c)) aceOfSpades = Card Ace Spades tenOfHearts = Card (Numeric 10) Hearts queenOfHearts = undefined jackOfClub = undefined
haskell
readFileAsk :: a -> b -> a readFileAsk askFoo fileName = askFoo fakePutStr :: (Monad m) => String -> m() fakePutStr x = do return () fakePrint :: (Monad m, Show a) => a -> m()
haskell
sym2 c = [c] escape _ b _ = b fun i _ a _ = i ++ a single s = "child{" ++ s ++ "}" split s _ a = "child{" ++ s ++ "}" ++ a
haskell
import Lambda.Util ---------------------------------------------------------------------- -- gointoCaseRoute ---------------------------------------------------------------------- gointoCaseRoute :: Term -> [(PM, Term)] -> Lambda Term gointoCaseRoute x ((pm,t):pairs) = do if x == convert pm then (*:) t else case pairs of [] -> do e <- restore x throwEvalError $ strMsg $ "CASE: unexhausted pattern: "++ show e _ -> gointoCaseRoute x pairs
haskell
dupChan_ = dupChan forkIO_ = forkIO class MonadSecureClient m where runSecureClient_ :: HostName -> PortNumber -> String -> ClientApp a -> m a instance MonadSecureClient IO where runSecureClient_ = runSecureClient
haskell
<gh_stars>1-10 {-# LANGUAGE DeriveAnyClass #-} module Auth.Models ( CreateUser(..)
haskell
import SDLTricksCube.Launch ( launch, launch_ ) type Log = String -> IO () main :: IO () main = do args <- getArgs launch_ (info, warn, err) args where info = log' "INFO" warn = log' "WARN" err = log' "ERROR" log' x = putStrLn . printf "__android_log_write: %s: %s" x -- imageBase64 = BS.readFile "assets/nefeli.png.base64"
haskell
, printBase = 10 } main :: IO () main = do timestamp <- getCurrentTime let dirname = "smt_logs_" ++ show timestamp createDirectory dirname withCurrentDirectory dirname $ do benchmarkEnergyEstimate Energy.energyEstimateHighLevel
haskell
lastSpoken = prefix `zip` [1..] & Map.fromList -- number -> turn spoken in locate (length input & fromIntegral) (last input) lastSpoken where locate :: Integer -> Integer -> Map.Map Integer Integer -> Integer locate thisTurn aboutToSay lastSpoken | thisTurn == n = aboutToSay | otherwise = let previously = Map.lookup aboutToSay lastSpoken nextToSay = case previously of Nothing -> 0 Just lastTurn -> thisTurn - lastTurn in locate (thisTurn + 1) nextToSay (Map.insert aboutToSay thisTurn lastSpoken)
haskell
= case Map.lookup name conf of Just p -> updateProgram (Just p{programArgs=(words args)}) conf' Nothing -> updateProgram (Just $ Program name name (words args) EmptyLocation) conf' -- |Update this program's entry in the configuration. No changes if -- you pass in Nothing. updateProgram :: Maybe Program -> ProgramConfiguration -> ProgramConfiguration updateProgram (Just p@Program{programName=n}) (ProgramConfiguration conf) = ProgramConfiguration $ Map.insert n p conf updateProgram Nothing conf = conf -- |Runs the given program. rawSystemProgram :: Int -- ^Verbosity -> Program -- ^The program to run
haskell
module Diverta2019.CSpec (spec) where import Data.ByteString (ByteString) import Test.Hspec (Spec, it, shouldBe) import Text.Heredoc (str) import Diverta2019.C (main) import Test (runWith) spec :: Spec spec = do it "Example 1" $ do let input, output :: ByteString
haskell
entity: P2PPicksAccount constructors: - name: P2PPicksAccount fields: - name: p2ppicksOwner type: text reference:
haskell
, "column$are$separated$by$at$least$one$space." , "Further,$allow$for$each$word$in$a$column$to$be$either$left$" , "justified,$right$justified,$or$center$justified$within$its$column." ] cols :: [[Text]] cols = transpose $ ((++) <*>
haskell
[] $ \s _ -> Right $ Variable s termInfo "bin_op" = TermInfo ["lefthand expr of bin op", "bin op", "righthand expr of bin op"] $ \_ (Right left:Left operator:Right right:_) -> Right $ BinOp operator left right termInfo "number" = TermInfo [] $ \s _ -> Right . Number $ read s termInfo "boolean" = TermInfo
haskell
, _crBranch :: Maybe BranchName , _crWorkflowNumber :: WorkflowNumber , _crComment :: Maybe Comment , _crClaimType :: ClaimTypeName , _crDetails :: Maybe Details , _crReason :: Maybe Reason , _crId :: RecordId , _crDate :: UTCTime } deriving (Show)
haskell
# ("angle", rotateAngle) data Scale = SUniformScale Double | SScaleAxis Vector deriving(Eq, Show, Ord, Read, Data, Typeable, Generic) instance Default Scale
haskell
gen <- newStdGen let (prob, _) = randomR (min,max) gen :: (Float, StdGen) return prob simulateReturns :: Float -> Int -> Float -> Float -> Float -> IO [Float] simulateReturns sigma kbar gamma_kbar b m0 = do volatility <- simulateVolatility sigma kbar gamma_kbar b m0
haskell
-- No documentation found for TopLevel "VkExportSemaphoreCreateInfoKHR" type VkExportSemaphoreCreateInfoKHR = VkExportSemaphoreCreateInfo -- No documentation found for TopLevel "VkExportSemaphoreCreateInfoKHR" pattern VkExportSemaphoreCreateInfoKHR :: ("sType" ::: VkStructureType) -> ("pNext" ::: Ptr ()) -> ("handleTypes" ::: VkExternalSemaphoreHandleTypeFlags) -> VkExportSemaphoreCreateInfoKHR pattern VkExportSemaphoreCreateInfoKHR vkSType vkPNext vkHandleTypes = VkExportSemaphoreCreateInfo vkSType vkPNext vkHandleTypes -- No documentation found for TopLevel "VK_STRUCTURE_TYPE_EXPORT_SEMAPHORE_CREATE_INFO_KHR" pattern VK_STRUCTURE_TYPE_EXPORT_SEMAPHORE_CREATE_INFO_KHR :: VkStructureType pattern VK_STRUCTURE_TYPE_EXPORT_SEMAPHORE_CREATE_INFO_KHR = VK_STRUCTURE_TYPE_EXPORT_SEMAPHORE_CREATE_INFO -- No documentation found for TopLevel "VK_SEMAPHORE_IMPORT_TEMPORARY_BIT_KHR" pattern VK_SEMAPHORE_IMPORT_TEMPORARY_BIT_KHR :: VkSemaphoreImportFlagBits pattern VK_SEMAPHORE_IMPORT_TEMPORARY_BIT_KHR = VK_SEMAPHORE_IMPORT_TEMPORARY_BIT
haskell
import Prelude import Futhark.Representation.ExplicitMemory (Prog) import qualified Futhark.CodeGen.ImpCode.OpenCL as OpenCL import qualified Futhark.CodeGen.ImpGen.Kernels as ImpGenKernels import Futhark.CodeGen.ImpGen.Kernels.ToOpenCL import Futhark.MonadFreshNames
haskell
(MonadDOM m) => SVGFECompositeElement -> m SVGAnimatedNumber getK2 self = liftDOM ((self ^. js "k2") >>= fromJSValUnchecked) -- | <https://developer.mozilla.org/en-US/docs/Web/API/SVGFECompositeElement.k3 Mozilla SVGFECompositeElement.k3 documentation> getK3 :: (MonadDOM m) => SVGFECompositeElement -> m SVGAnimatedNumber getK3 self = liftDOM ((self ^. js "k3") >>= fromJSValUnchecked) -- | <https://developer.mozilla.org/en-US/docs/Web/API/SVGFECompositeElement.k4 Mozilla SVGFECompositeElement.k4 documentation> getK4 ::
haskell
newTreeInfo = if (isMax treeInfo) then treeInfo { alpha = (max score (alpha treeInfo))} else treeInfo { beta = (min score (beta treeInfo))} in if pruneCondition then movePath else calculateBestMove (isMax treeInfo) movePath (nextLevelMinimax node newTreeInfo) nextLevelMinimax :: a -> TreeInfo a -> MovePath a
haskell
littleEndian :: Bool littleEndian = (decode . runPut $ putWord16host 42 :: Word8) == 42 main :: IO () main | littleEndian = putStrLn "LittleEndian"
haskell
module Network.API.PagerDuty.EventV1Lenses ( _Link, _Image, teServiceKey, teIncidentKey, teDescription, teDetails, teClient, teClientURL, teContexts, _Acknowledge, _Resolve, updateType, updateServiceKey, updateIncidentKey, updateDescription, updateDetails ) where import Control.Lens (makeLenses, makePrisms) import Network.API.PagerDuty.EventV1
haskell
infixl 8 <^.>, <^..>, <^?> -- | Gets name from deployment full info. dfiName :: Getter DeploymentFullInfo DeploymentName dfiName = field @"deployment" . field @"name"
haskell
, pulse , rmsGain ) where import DeltaSigma.Type import DeltaSigma.GeneralUtility calculateSNR :: Bin -> Bin -> [Double] -> Double calculateSNR f nsig hwfft = dbp (s / n) where norm xs = sum $ fmap (** 2) xs s = norm $ fmap (hwfft !!) [f-nsig .. f+nsig] n = norm $ fmap (hwfft !!) ([0 .. f-nsig-1] ++ [f+nsig+1 .. length hwfft - 1])
haskell
return $ RefreshResult (Token "secret-foo-token") Nothing oneTimeRefresh :: IO () oneTimeRefresh = runStderrLoggingT $ do tokenFoo <- createTokenStoreFoo liftIO $ threadDelay (10 ^ 6 + 10 ^ 5) (Right token) <- liftIO . atomically $ readTVar tokenFoo liftIO $ token @?= Token "secret-foo-token" main :: IO () main = do
haskell
normalForm :: LC IdInt -> LC IdInt normalForm e@(Var _) = e normalForm (Lam x e) = Lam x (normalForm e) normalForm (App f a) = case weekHeadNormalForm f of Lam x b -> normalForm (substitute x a b) f' -> App (normalForm f') (normalForm a) -- | Computes week head normal form only for Application weekHeadNormalForm :: LC IdInt -> LC IdInt weekHeadNormalForm e@(Var _) = e weekHeadNormalForm e@(Lam _ _) = e weekHeadNormalForm (App f a) =
haskell
latDiff = (diff a c) lngDiff = (diff b d) latDiffToMi :: Lat -> Mi latDiffToMi = (* 69)