lang
stringclasses
10 values
seed
stringlengths
5
2.12k
haskell
| Comment Text | Exit deriving(Show, Eq) tokenizeCode :: Text -> [Text] tokenizeCode = split $ \c -> c == '。' || c == '、' || c == '「' || c == '」' parseCode :: Text -> Inst parseCode str
haskell
fromJSValUnchecked) -- | <https://developer.mozilla.org/en-US/docs/Web/API/SVGTextContentElement.lengthAdjust Mozilla SVGTextContentElement.lengthAdjust documentation> getLengthAdjust :: (MonadDOM m, IsSVGTextContentElement self) => self -> m SVGAnimatedEnumeration getLengthAdjust self = liftDOM (((toSVGTextContentElement self) ^. js "lengthAdjust") >>= fromJSValUnchecked)
haskell
-- -> (k -> j -> (i, i)) -> ((k -> j -> i -> e) -> k -> j -> i -> e) -- -> k -> j -> i -> e -- flexible3 bounds1 bounds2 bounds3 f = (!) flex where -- flex = A.listArray bounds1 -- [ down2 (bounds2 i) (bounds3 i) (f (flex !) i)
haskell
toBaseStmtForm (SExp a e) = do s <- toBaseExpr e addStmt $ SExp a s toBaseStmtForm (Cond a cond b) = do sCond <- toBaseExpr cond (_, inner) <- catch $ toBaseStmtForm b
haskell
forall t effs. ( Member (Embed IO) effs, Members [Error UserError, Warn UserError] effs, FromJSON t, ToJSON t, TransitionValid t ) => FilePath -> Sem (WriteGraph t ': effs) ~> Sem effs runWriteGraphIO dir = runInputConst (IsDual False) . runWriteGraphIODualizeable dir runWriteGraphIO' ::
haskell
numIncreases :: Ord a => [a] -> Int numIncreases = length . filter (LT ==) . ap (zipWith compare) tail windows :: (Num a) => [a] -> [a] windows = map (sum . take 3) . tails part1 :: [Integer] -> String part1 = show . numIncreases
haskell
translateT :: Program -> Runner () translateT p = tellHead >> translateProgram p >> tellTail tellHead :: Runner () tellHead = tell "declare i32 @printf(i8*, ...)\n" >> tell "@formatString = private constant [4 x i8] c\"%d\\0A\\00\"\n" >>
haskell
repoId = let prefixLen = length section - suffixLen suffixLen = length repoSectionSuffix in take prefixLen section repoSectionSuffix :: String repoSectionSuffix = "-repo" repoRemotePathK :: String repoRemotePathK = "remote_path" repoRemoteSshKeyK :: String repoRemoteSshKeyK = "ssh_priv_key_file" repoRemoteSshHostK :: String repoRemoteSshHostK = "ssh_remote_host"
haskell
module Lib ( someFunc ) where -------------------------------------------------------------------------------- import Test.TWebDriver.Commands -------------------------------------------------------------------------------- myS :: WD () myS = click =<< findElem $(mkXPath "//a/button/descendant::a[contains(text(), 'wow')]") {-
haskell
) where import Universum import Pos.Core (Address) -- | A class which have the method to generate a new address class Monad m => MonadAddresses m where type AddrData m :: * -- | Generate new address using given 'AddrData' (e.g. password + -- account id). getNewAddress :: AddrData m -> m Address
haskell
fibs' :: [Integer] fibs' = take 20 fibs -- Question 2 fibs'' :: [Integer] fibs'' = takeWhile (<100) fibs
haskell
AppRoles (..) ) where import Data.Aeson import qualified Data.HashMap.Strict as HM import Data.Text
haskell
import GHC.Generics data IssueIDTO = IssueIDTO { _issueIDTONumber :: Int , _issueIDTOTitle :: String , _issueIDTOBody :: String } deriving (Show, Eq, Generic)
haskell
-- https://www.codewars.com/kata/57fae964d80daa229d000126 module Kata where remove :: String -> String remove "" = "" remove "!" = "" remove (x:xs) = x:(remove xs)
haskell
bfsEval :: [Int] bfsEval = reverse r where (r, _, _) = bfs ([1], visit, graph !! 1) bfs :: BreadcrumbB -> BreadcrumbB bfs b@(_, _, []) = b
haskell
tupElemTyName :: Int -> Q Name tupElemTyName i = newName $ printf "t%d" i -- | Generate a single constructor for the 'TabTuple' type. mkTupleCons :: Name -> (Int -> Name) -> (Type -> Type) -> Int -> Q Con mkTupleCons tupTyName conName elemTyCons width = do tupElemTyNames <- mapM tupElemTyName [1..width] let tyVarBinders = map PlainTV tupElemTyNames -- (t1, ..., t<n>) tupTy = foldl' AppT (TupleT width)
haskell
import Data.ByteString.Lazy as S import Data.Bits as B import Data.List as L import Data.Binary.Get as G import Data.Char import Data.Int import Data.Word import Methods import ImpossibleImports import Memory g'bool :: Get Bool
haskell
-- Unit unit :: Float -> (Float, [Char]) unit v = (v, "") -- Bind
haskell
import Clash.Prelude import GHC.TypeLits.Extra import Data.Kind (Type) import Data.Proxy import Data.Singletons hiding (type (+)) data IIndex (f :: TyFun Nat Type) :: Type type instance Apply IIndex l = Index ((2^l)+1) popCountT = tdfold (Proxy :: Proxy IIndex) fromIntegral (const add)
haskell
module Formal where import Data.List newtype FPS v c = FPS { eval :: [v] -> c } fpsSum :: (Num c) => FPS v c -> FPS v c -> FPS v c
haskell
data Key = Key { next :: (Key, Integer)
haskell
data Expr = Expr { exprField :: Text , exprSelector :: SelectorExp } deriving (Show, Eq) data PageExp = PageExp { pageUrlFilter :: Text , pageExprs :: [Expr] } deriving (Show, Eq) type PageName = Text
haskell
-> Bool -> Fay CodeMirror -- ^ A new code mirror. newCodeMirror = ffi "CodeMirror(%1,{mode:%2,value:%3,autofocus:%4,indentWithTabs:false,tabSize:4})" -- | Get the current editor content. getMirrorValue :: CodeMirror -> Fay String getMirrorValue = ffi "%1['getValue']()" -- | Set the current editor content.
haskell
where numTypes = ["~int2", "~int4", "~int8", "~numeric", "~float4", "~float8"] isDbValue = T.isPrefixOf "~" isComparableType = isDbValue symInClass T.Num sym = sym `elem` numTypes
haskell
------------------------------------------------------------ import MonadIO.NamedHandle ( HEncoding( NoEncoding ), ℍ, handle ) import MonadIO.OpenFile ( FileOpenMode( FileR ), openFile ) -------------------------------------------------------------------------------- type 𝔹𝕊 = ByteString class MkInputStream α where mkIStream ∷ ∀ ε μ .
haskell
module Language.Tiger.Expr where
haskell
import Control.Concurrent expensive = f (500 :: Int) where f 0 = stop f n = do r <- atom $ getStdRandom (randomR (0,99::Int)) r `seq` f $! n-1 main = do m <- newEmptyMVar forkIO (do runTIO $ map (\x->expensive) [1..500] putMVar m ())
haskell
let result = input --> gate putStrLn $ show input ++ " -> " ++ show result data Neuron = Neuron { weight :: Vector R, bias :: R
haskell
import Test.QuickCheck import Test.Tasty import Test.Tasty.Hspec as HS import Data.List import Data.Ord import qualified Test.Fluidity.EVM.Data.BytecodeSpec as BytecodeSpec import qualified Test.Fluidity.EVM.Core.SystemSpec as SystemSpec
haskell
eAccessToken <- liftIO $ runEncryptM appEncryptionSettings $ decryptText twitchCredentialsAccessToken case eAccessToken of Left _ -> sendStatusJSON status401 ("Unable to retrieve access token" :: Text) Right accessToken -> do eResponse <- twitchRequest
haskell
describe "Part1" $ do it ("returns 67384529 for " ++ input) $ do part1 input `shouldBe` "67384529" -- describe "Part2" $ do -- it ("returns 149245887792 for " ++ input) $ do
haskell
infixr 5 :-: data List a = Empty | Cons { listHead :: a, listTail :: List a} deriving (Show, Read, Eq, Ord) data List1 a = Empty1 | a :-: (List1 a) deriving (Show, Read, Eq, Ord) infixr 5 ^++ (^++) :: List1 a -> List1 a -> List1 a Empty1 ^++ ys = ys (x :-: xs) ^++ ys = x :-: (xs ^++ ys)
haskell
-- | Full data type definition for -- CodeDeployDeploymentGroupOnPremisesTagSetListObject. See -- 'codeDeployDeploymentGroupOnPremisesTagSetListObject' for a more -- convenient constructor. data CodeDeployDeploymentGroupOnPremisesTagSetListObject = CodeDeployDeploymentGroupOnPremisesTagSetListObject { _codeDeployDeploymentGroupOnPremisesTagSetListObjectOnPremisesTagGroup :: Maybe [CodeDeployDeploymentGroupTagFilter] } deriving (Show, Eq) instance ToJSON CodeDeployDeploymentGroupOnPremisesTagSetListObject where toJSON CodeDeployDeploymentGroupOnPremisesTagSetListObject{..} = object $ catMaybes [ fmap (("OnPremisesTagGroup",) . toJSON) _codeDeployDeploymentGroupOnPremisesTagSetListObjectOnPremisesTagGroup
haskell
l <- generateArray 0.0 1.0 m <- generateArray 0.0 1.0 let ls = map (\x -> (x - 0.5)*0.1) $ take 100 $ l let ms = map (\x -> (x - 0.5)*0.1) $ take 100 $ m let point = predict_point_from_sources ls ms (3.4,5.6) print point let uvgrid = sample_uv_grid 5 5.0 ls ms print uvgrid
haskell
module Data.String.Strip (strip) where import Data.Char -- | This is haddock documentation. Explain here that this function trims spaces. -- If you run stack haddock from the terminal, the docs are in .stack-work/dist/somenumber/doc/html/projectname/doc-index.html strip :: String -> String strip = dropWhile isSpace . reverse . dropWhile isSpace . reverse
haskell
import Data.ByteString (ByteString) import Data.ByteString.Builder (lazyByteString) import qualified Data.ByteString.Lazy as L import Data.Enumerator (Iteratee, consume) import Network.Wai import Network.Wai.Handler.Webkit
haskell
module ListsPalindrome where isPalindrome :: (Eq a) => [a] -> Bool isPalindrome xs = xs == (reverse xs)
haskell
module Main where import CLI main :: IO () main = do path <- getArgs runFs path
haskell
-- | Convenience function for @first@ with a @Kleisli@ arrow. firstM ∷ Monad m ⇒ (a → m c) → (a, b) → m (c, b) firstM = unkleislify first -- | Convenience function for @second@ with a @Kleisli@ arrow. secondM ∷ Monad m ⇒ (b → m c) → (a, b) → m (a, c) secondM = unkleislify second -- | Convenience function for @(***)@ on 'Kleisli' arrows.
haskell
module B (idd) where idd :: Int idd = 100000242418429
haskell
=> ThmTactic HOLThm cls thry -> thm -> Tactic cls thry _CONJUNCTS_THEN' ttac cth g = do th1 <- ruleCONJUNCT1 cth th2 <- ruleCONJUNCT2 cth (ttac th1 `_THEN` ttac th2) g ruleIMPLICATE :: BoolCtxt thry => HOLTerm -> HOL cls thry HOLThm ruleIMPLICATE (Neg t') = ruleCONV (convRAND convBETA) $ ruleAP_THM defNOT t' ruleIMPLICATE _ = throwM $! HOLExhaustiveWarning "ruleIMPLICATE" tacRIGHT_REVERSIBLE :: BoolCtxt thry => Tactic cls thry tacRIGHT_REVERSIBLE = _FIRST [ tacCONJ
haskell
import Icicle.Common.Fresh import Icicle.Core.Program.Program import Icicle.Core.Stream.Stream import qualified Icicle.Core.Exp.Simp as S import qualified Icicle.Core.Exp.Exp as C
haskell
requestLine = (,,) <$> (method <* B.skipSpace) <*> (B.takeTill B.isSpace <* B.skipSpace) <*> httpVersion where method = "GET" <|> "POST" httpVersion = "HTTP/" *> ((,) <$> (int <* B.char '.') <*> int) responseLine = (,,) <$> (httpVersion <* B.skipSpace) <*> (int <* B.skipSpace) <*> bodyLine
haskell
-- fmap a -> fa -> fb -> f f b addOne :: Num a => a -> [a] addOne x = [x, 1] func1 :: Num a => (a -> [a]) -> [a] -> [[a]] func1 f l = f <$> l result = func1 addOne [1,2,3] bind' :: Monad m => ( a -> m b ) -> m a -> m b bind' f = join . fmap f -- liftA :: Applicative f => (a -> b) -> f a -> f b
haskell
print $ part1 (read timestamp) buses print $ part2 buses splitBy :: Char -> String -> [String] splitBy _ "" = [] splitBy c (',' : s) = splitBy c s splitBy c s = let (a, b) = span (/= c) s in a : splitBy c b part1 :: Int -> [String] -> Int part1 timestamp buses' = uncurry (*) $ minimum $ zip (map (\b -> b - mod timestamp b) buses) buses where buses = map read $ filter (/= "x") buses'
haskell
data Action = AttackTo Target | Iso Command deriving (Show) data Target = ToPlayer | ToEnemy deriving (Show) data CommandList = CommandList { _index :: Int, _listSize :: Int, _commandMap :: IM.IntMap Command } deriving (Show) index :: Lens' CommandList Int index = lens _index (\f x -> f { _index = x }) listSize :: Lens' CommandList Int listSize = lens _listSize (\f x -> f { _listSize = x }) commandMap :: Lens' CommandList (IM.IntMap Command) commandMap = lens _commandMap (\f x -> f { _commandMap = x })
haskell
import Data.Vinyl import GHC.Exts import GHC.Generics import GHC.TypeNats import Generics.OneLiner import Numeric.Backprop as B import Numeric.LinearAlgebra.Static.Backprop () import Numeric.Opto.Update hiding ((<.>)) import qualified Data.Functor.Contravariant as Co import qualified Data.Vector.Generic as VG
haskell
(startYear, endYear) = (1901,2000) startOffset = 1 -- Jan 1 1901 was a Tuesday targetDay = 6 -- searching for Sundays monthLengths = [31,28,31,30,31,30,31,31,30,31,30,31] monthLengthsLeap = 31:29:(drop 2 monthLengths) (yearlyOffset, yearlyOffsetLeap) = (1,2) --map ((`mod` 7) . sum) [monthLengths, monthLengthsLeap] isLeap y = y `rem` 4 == 0 && (y `rem` 100 /= 0 || y `rem` 400 == 0)
haskell
primHashMap :: M.Map Identifier (T.Text,Hash) primHashMap = M.fromList (zip allPrimNames vs) where ns = map unIdentifier allPrimNames hs = map mkHash ns vs = zip ns hs primSizeMap :: M.Map Identifier Size primSizeMap = M.fromList $ zip ns sz where ns = map primToText allPrims
haskell
{- liftIO (modifyIORef' ref (\(w',s) -> ( trace ("\nwtell " ++ show w' ++ " " ++ show w) w'<>w , s))) -} (w', s) <- readIORef ref writeIORef ref (w' <> w, s) return ((), x) {-# INLINE tell #-}
haskell
module Ch2 where triple x = x * 3 waxOn = x * 5 where x = y ^ 2 y = z + 8 z = 7
haskell
module Main where import Control.Monad import HGet.Internal.CLI (cliConfig) import HGet.Internal.UI (runUI) main :: IO () main = do config <- cliConfig void runUI
haskell
-- "Crypto.Saltine.Core.Auth" -- -- The 'auth' function authenticates a message 'ByteString' using a -- secret key. The function returns an authenticator. The 'verify' -- function checks if it's passed a correct authenticator of a message -- under the given secret key.
haskell
describe "Testing whether an example of an LCirc has coherent semantics" $ do it "compatible lgraph node composition" $ do let n1 = mkNodes [1, 2, 3 :: NodeId] n2 = mkNodes [4, 5, 6 :: NodeId] m12 = Map.fromList $ [(5, \c-> if (c == 5) then 1 else c), (4, \c-> if c == 4 then 2 else c)] compNodes n1 n2 m12 `shouldBe` (mkNodes [1, 2, 3, 6]) it "compatible lgraph edge composition" $ do let e1 = edges circuitEx
haskell
import Data.Text.Lazy (Text) layoutCss :: Text layoutCss = render $ do body ? minHeight (px 2000) element ".jumbotron" ? (textAlign $ alignSide sideCenter) element "#gmail" ? (marginLeft $ px 10)
haskell
module RebindHR where import Prelude hiding ( (>>=) ) import Data.Typeable data Exp = Int Int | Plus Exp Exp | Bool Bool data TExp a where TInt :: Int -> TExp Int TPlus :: TExp Int -> TExp Int -> TExp Int TBool :: Bool -> TExp Bool (>>=) :: ((forall t. Typeable t => TExp t -> Maybe r) -> Maybe r) -> (forall t. Typeable t => TExp t -> Maybe r) -> Maybe r x >>= y = x y
haskell
import Control.Effect import Control.Effect.Monad import Prelude hiding (Monad(..)) putStrLn' = Wrap . putStrLn printer = do putStrLn' "Hello" putStrLn' "I am really regular IO monad"
haskell
) where import Prelude () import SDP.SafePrelude import SDP.Zip default () --------------------------------------------------------------------------------
haskell
do base_nm <- symName (str ++ "_base") off_nm <- symName (str ++ "_offset") base <- freshConstant sym base_nm BaseNatRepr offs <- freshConstant sym off_nm (BaseBVRepr knownNat) return (Value (LLVMPointer base offs)) isPtr ptr True return ptr -- | Generate a fresh value for a general purpose register. freshGP :: GPReg -> GPRegUse t -> Spec Pre (Value t)
haskell
firstLit (ALit l _ : _) = l firstLit (_ : as) = firstLit as k2cStringAlts b e (ALit l c : as) = (if b then text "else " else empty) <> text "if (strEq (" <> k2cExp e <> text "," <> k2cExp (ELit l) <> text ")) {" $$ nest 4 (k2cNestIfCmd c) $$ text "}" $$ k2cStringAlts True e as k2cStringAlts _ e [AWild c] = text "else {" $$ nest 4 (k2cNestIfCmd c) $$ text "}" k2cFloatAlts b e (ALit l c : as)
haskell
Portability : GHC -} {-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE CPP #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE QuasiQuotes #-} module Language.Fortran.Inline.Utils where import qualified Language.C.Inline as C
haskell
import Protolude import Test.Tasty (defaultMain, testGroup) import qualified Spec.Day_3 as Day_3 main :: IO () main =
haskell
html $ mconcat ["<html><body>" ,"<h1> Heading </h1>" ,"</body></html>" ]
haskell
factFromJSON :: (?q::SMTQuery) => DFSession -> J.Value -> IO Fact factFromJSON df f@(J.Object vs) = case H.toList vs of [(rname, v)] -> rowFromJSON df (unpack rname) v _ -> err $ "Invalid JSON fact: " ++ show f factFromJSON _ f = err $ "Invalid JSON fact: " ++ show f rowFromJSON :: DFSession -> String -> J.Value -> IO Fact rowFromJSON DFSession{..} rname val = do let Relation{..} = fromJust $ find ((== rname) . name) dfRels let ?q = dfQ
haskell
data Split PlutusTx.makeLift ''SplitDatum PlutusTx.unstableMakeIsData ''SplitDatum instance Scripts.ValidatorTypes Split where type RedeemerType Split = () type DatumType Split = SplitDatum splitValidator :: Scripts.TypedValidator Split splitValidator =
haskell
it "calculates the square of an arbitrary integer" $ property $ \(n :: Integer) -> square n == n * n it "calculates the square of an arbitrary double" $ property $ \(n :: Double) -> square n == n * n describe "ggT" $ do it "calculates the gcd of 15 and 10" $ ggT 15 10 `shouldBe` 5 it "calculates the gcd of two arbitrary integer" $ property $ \(a :: Integer) (b :: Integer) -> ggT a b == gcd a b
haskell
let x = xp `mod` a in let y = yp `mod` b in Divides.chineseRemainder a b x y < a * b proposition10 :: Primitive.Natural.Natural -> Primitive.Natural.Natural -> Primitive.Natural.Natural -> Primitive.Natural.Natural -> Bool
haskell
major7Chord :: Chord major7Chord = buildChord [0, 4, 7, 11] type Duration = Int data Progression = Progression { chords :: [((Chord, Int), Duration)] , key :: Double , tempo :: Double } applyProgression :: Progression -> WaveFn -> WaveFn applyProgression prog wave t | t == 0 = (applyChord pitch' wave chord') t
haskell
import Test.Tasty import qualified Test.Tasty.SmallCheck as SC import qualified Codec.Packstream.Coding as PSC import Test.SCInstances unitTests :: TestTree
haskell
import Data.IntMap import Yesod import Dispatch () import Foundation main :: IO () main = do tstore <- atomically $ newTVar empty tident <- atomically $ newTVar 0 warpEnv $ App tident tstore
haskell
elementFromPoint self x y = liftDOM (((toDocumentOrShadowRoot self) ^. jsf "elementFromPoint" [toJSVal x, toJSVal y]) >>= fromJSVal) -- | <https://developer.mozilla.org/en-US/docs/Web/API/DocumentOrShadowRoot.elementFromPoint Mozilla DocumentOrShadowRoot.elementFromPoint documentation> elementFromPoint_ :: (MonadDOM m, IsDocumentOrShadowRoot self) => self -> Double -> Double -> m () elementFromPoint_ self x y = liftDOM (void ((toDocumentOrShadowRoot self) ^. jsf "elementFromPoint"
haskell
} instance Default XvfbConfig where def = XvfbConfig Nothing defaultWdOptions :: FilePath -> FilePath -> WdOptions defaultWdOptions toolsRoot runRoot = WdOptions toolsRoot runRoot (const False) def OnException Normal data WdSession = WdSession { wdLabels :: [String] , wdWebDriver :: (Handle, Handle, ProcessHandle, FilePath, FilePath, Maybe XvfbSession) , wdOptions :: WdOptions , wdSessionMap :: MVar [(Browser, W.WDSession)]
haskell
{ stCheckpoints = initCheckpoints , stSystemState = Sys.initState , stLast = Sys.initState } getCheckpoints = stCheckpoints <$> getState getSystemState = stSystemState <$> getState getLast = stLast <$> getState setCheckpoints x = updateState (\st -> st { stCheckpoints = x }) :: Control () setSystemState x = updateState (\st -> st { stSystemState = x }) :: Control ()
haskell
multM m1 m2 | l1 /= l2 = error "matrizes incompatíveis" | otherwise = [[prodInterno l c | c<-transpose m2] | l<-m1] where l1 = snd $ lengthM m1 l2 = fst $ lengthM m2
haskell
mkSubscriptionScheduleAddInvoiceItem subscriptionScheduleAddInvoiceItemPrice = SubscriptionScheduleAddInvoiceItem { subscriptionScheduleAddInvoiceItemPrice = subscriptionScheduleAddInvoiceItemPrice, subscriptionScheduleAddInvoiceItemQuantity = GHC.Maybe.Nothing, subscriptionScheduleAddInvoiceItemTaxRates = GHC.Maybe.Nothing }
haskell
dt2Str :: DataType -> String dt2Str StdLogic = "SL" dt2Str StdLogicVector = "SL Vec" dt2Str StdULogic = "SUL" dt2Str StdULogicVector = "SUL Vec"
haskell
main :: IO () main = hspec spec spec :: Spec spec = do describe "SystemF" SF.spec describe "Transformations" Tr.spec describe "FromPlutusIR" FP.spec
haskell
---------------------------------- StateT ------------------------------------ newtype StateT s m a = StateT{runStateT :: s -> m (a,s)} instance Monad m => Functor (StateT s m) where fmap f (StateT fa) = StateT $ \s -> do (xa, sx) <- fa s return (f xa, sx) instance Monad m => Applicative (StateT s m) where pure x = StateT $ \s -> return (x, s) StateT ff <*> StateT fa = StateT $ \s -> do
haskell
-- test that a failed acquire doesn't fail the other requests ref <- newIORef False env <- testEnv impl $ \st -> st { failAcquire = throwIO (DataSourceError "acquire") , failRelease = writeIORef ref True } x <- runHaxl env $ (dataFetch (FailAfter 0) + wombatsMany) `Haxl.catch` \DataSourceError{} -> wombats assertEqual "badDataSourceTest1" 3 x
haskell
(mrow :: Maybe (Double,I.Int64)) <- H.single $ [H.q|SELECT * FROM data WHERE field1=?|] num case mrow of Just (field1,field2) -> let newfield2 = field2 * 2 + 1 in H.unit $ [H.q|UPDATE data SET field2=? WHERE field1=?|] newfield2 field1
haskell
cachedIdem f i a = do s <- get case Set.member a s of True -> return i False -> do b <- f a s' <- get put (Set.insert a s') return b
haskell
, velocity = Vel (0, 0) , mass = 1 } earth :: Body
haskell
prism' SpendsPK ( \case SpendsPK o -> Just o _ -> Nothing ) -- * Picking apart 'OutConstraint's data PaysScriptConstraint where PaysScriptConstraint :: PaysScriptConstrs a => L.TypedValidator a ->
haskell
module Atom.Language.Atom ( -- * Code -- | Module: "Language.Atom.Code" Config (..), defaults, Clock (..), defaultClock, writeC, cType, RuleCoverage, -- * Compilation -- | Module: "Language.Atom.Compile" compile, reportSchedule, Schedule, -- * Common -- | Module: "Language.Atom.Common" Timer, timer, startTimer, startTimerIf, timerDone, oneShotRise, oneShotFall, debounce, lookupTable, linear, hysteresis, Channel (..), channel, writeChannel, readChannel,
haskell
module Lib ( someFunc, ) where someFunc :: IO () someFunc = putStrLn "HELLO LUKE WORLD!!!!!!!!!!"
haskell
getCategories, search, download ) where import Network.Curl import qualified Types.Category as Category import qualified Types.Torrent as Torrent import qualified Data.Map.Strict as Map import qualified Data.Aeson as Json import qualified Data.ByteString.Lazy.Char8 as C
haskell
import Servant (NoContent (NoContent)) import Cardano.BM.Data.Trace (Trace) import Cardano.Node.Follower (NodeFollowerEffect) import Cardano.Node.RandomTx import Cardano.Node.Types import Cardano.Protocol.ChainEffect as CE import Cardano.Protocol.FollowerEffect as FE import qualified Cardano.Protocol.Socket.Client as Client import qualified Cardano.Protocol.Socket.Server as Server import Ledger (Block, Slot (Slot), Tx)
haskell
shrinkCompiled :: CompiledCode a -> CompiledCode a shrinkCompiled = shrinkCompiledSp defaultShrinkParams shrinkCompiledSp :: ShrinkParams -> CompiledCode a -> CompiledCode a shrinkCompiledSp sp comped = let asScript = fromCompiledCode comped script@(Script prog') = shrinkScriptSp sp asScript prog = programMapNames fakeNameDeBruijn prog' scriptBc = toStrict $ serialise script in case comped of
haskell
import Test.Hspec import Test.QuickCheck main :: IO () main = hspec $ do describe "fun1'" $ do it "should behave just like fun1" $ property $ \xs -> (fun1' xs) == (fun1 xs) describe "fun2'" $ do it "should behave just like fun2" $ property $ forAll (arbitrary :: Gen (Positive Integer))
haskell
dissembler, hypocrite, sophist, Pharisee, Jesuit, Mawworm, Pecksniff, <NAME>, Tartuffe, Janus, serpent, snake in the grass, cockatrice, Judas, wolf in sheep's clothing, jilt, shuffler, stool pigeon *liar story-teller, perjurer, false witness, menteur a triple etage, Scapin, bunko steerer , carpetbagger , capper , faker, fraud, four flusher, horse coper, ringer, spieler, straw bidder *imposter pretender, soi-disant, humbug, adventurer, Cagliostro, <NAME>, ass in lion's skin , actor
haskell
import Safe (headMay, lastMay) import Network.Wreq (redirects) import Control.Lens import Natas.Natas import Natas.Parse solution :: Solution solution = do let req = getLevel' 22 (parentUri 22 ++ "/?revelio") (redirects .~ 0)
haskell
module Graphics.GL.SGIS.TextureLOD, module Graphics.GL.SGIS.TextureSelect ) where import Graphics.GL.SGIS.DetailTexture import Graphics.GL.SGIS.FogFunction import Graphics.GL.SGIS.GenerateMipmap
haskell
toDigits :: Integer -> [Integer] toDigits = map (toInteger . digitToInt) . show factorial :: Integer -> Integer factorial n = product [1..n]
haskell
import Lucid (Html, ToHtml (toHtml), br_, pre_) import Prettyprinter.Render.Util.SimpleDocTree (SimpleDocTree (..)) renderHtml :: SimpleDocTree (Html () -> Html ()) -> Html () renderHtml = let go = \case STEmpty -> pure ()
haskell
tests :: TestTree tests = testGroup "Tests" [unitTests] unitTests :: TestTree unitTests = testGroup "D22P1 Unit tests" [ testCase "gives correct answer to the original problem" $ do [0,3,6,9,2,5,8,1,4,7] @=? shuffled 10 1 [ DealWithIncrement 7, DealIntoNewStack, DealIntoNewStack ] [9,2,5,8,1,4,7,0,3,6] @=? shuffled 10 1 [ DealIntoNewStack, Cut (-2), DealWithIncrement 7, Cut 8, Cut (-4), DealWithIncrement 7, Cut 3, DealWithIncrement 9, DealWithIncrement 3, Cut (-1) ]
haskell
with :: Verified p a -> (forall s. Reifies s (Verified p a) => Lift p a s) -> a with d v = reify d (lower . asProxyOf v) where asProxyOf :: f s -> Proxy s -> f s asProxyOf x _ = x using :: forall p a b. VerifiableConstraint p => Verified p a -> (p a => b) -> b using d m = reify d $ \(_ :: Proxy s) ->
haskell
numbs = mkRegex "^:[0-9]{4}$" hgtIn = mkRegex "^[0-9]+in$" hgtCm = mkRegex "^[0-9]+cm$" hairC = mkRegex "#[0-9,[a-f]{6}"
haskell
import qualified SuperWeatherProvider import qualified SuperWeatherReporter -- | This is an actual application where we use -- our concrete implementation of `WeatherProvider`. main :: IO () main = do
haskell
-- DFT function is expressed as a multiplication of a transformation matrix with -- the input vector. The matrix is never manifested, and the resulting code is -- a doubly-nested loop where the matrix elements appear in the innermost -- calculation. dftRun = connectStdIO $ return . (dft :: DPull (Complex Double) -> _) --------------------------------------------------------------------------------
haskell
| otherwise = isAbba (b:c:d:rest) (found || matches && not inBraces) inBraces where matches = a == d && b == c && a /= b isAba :: String -> Bool