lang
stringclasses
10 values
seed
stringlengths
5
2.12k
haskell
module P23a where run :: String -> Int run _ = 8 + 300 + 5000 + 20 + 7000 + 30 + 3 + 700 + 50 + 3 + 6 + 400
haskell
{-# htermination (snd :: Tup2 b a -> a) #-} import qualified Prelude data MyBool = MyTrue | MyFalse data List a = Cons a (List a) | Nil data Tup2 a b = Tup2 a b ; snd :: Tup2 a b -> b; snd (Tup2 vv y) = y;
haskell
exitText = "One day at a time." fenText :: G.Game -> String fenText game = unlines ["", C.writeFen game] newGame :: Parser State newGame = Parser (MC.string' "new game" $> (Play C.quickGame))
haskell
parseLine = readBoardingPass readNext :: Handle -> IO (Maybe BoardingPass) readNext handle = do done <- hIsEOF handle
haskell
{-# LANGUAGE CPP #-} {-# OPTIONS_GHC -DFOO="bar baz" #-} main = print FOO -- Test that GHC can compile option pragmas containing spaces. -- When a .hsc contains `#define FOO "bar baz"`, hsc2hs emits: -- -- {-# OPTIONS_GHC -optc-DFOO="bar baz" #-}
haskell
import Text.Printf (printf) import Language.Adder.Types -------------------------------------------------------------------------------- -- | Convert a sequence of x86 `Instructions` into the output assembly -------------------------------------------------------------------------------- asm :: [Instruction] -> Text -------------------------------------------------------------------------------- asm instrs = header <> instrsAsm (instrs) <> "\n" instrsAsm :: [Instruction] -> Text instrsAsm = L.intercalate "\n" . map instrAsm header :: Text
haskell
module BugExportHeadings ( -- * Foo foo -- * Bar , bar -- * Baz , baz -- * One
haskell
-- An alternative nested representation -- -- | An alternative nested representation for 'Value' that groups assets that -- share a 'PolicyId'. -- newtype ValueNestedRep = ValueNestedRep [ValueNestedBundle] deriving (Eq, Ord, Show) -- | A bundle within a 'ValueNestedRep' for a single 'PolicyId', or for the -- special case of bcc. -- data ValueNestedBundle = ValueNestedBundleBcc Quantity | ValueNestedBundle PolicyId (Map AssetName Quantity)
haskell
(CompInt x) == (CompInt y) = x == y (CompString x) == (CompString y) = x == y instance Ord Comparable where compare (CompInt x) (CompInt y) = compare x y compare (CompString x) (CompString y) = compare x y compare (CompInt x) (CompString y) = LT compare (CompString x) (CompInt y) = GT convert x = maybe (CompString x) CompInt (readMaybe (fromMaybe "" x)) toInt (CompInt x) = x toInt _ = 0
haskell
import qualified Pos.DHT.Model as DHT import Test.Pos.Helpers (binaryTest) spec :: Spec
haskell
import qualified Data.Set as S import Ganeti.Errors import Ganeti.JSON (GenericContainer(..), Container) import Ganeti.Objects import Ganeti.Types import Ganeti.Utils
haskell
-- | Definition of a chronomorphism as an hylomorphism. -- -- This recursion pattern subsumes histomorphisms, futumorphisms and dynamorphisms -- and can be seen as the natural hylomorphism generalization from composing an histomorphism after a futumorphism. -- Therefore, chronomorphisms can 'look back' when consuming a type and 'jump forward' when generating one, via it's fold/unfold operations, respectively. --
haskell
{- f (xs) { f (xs) {} ... while (1) { return f(es) ... ... xs = es; continue; } ... } } -} isTailRecursive f (CBind False [(_, Val t (ECall g _ _))] (CRet (ENew (Tuple 0 _) _ _))) | t == tUNIT = f == g
haskell
FugitiveMove t -> MultiSet.delete t ft Reveal t _ -> MultiSet.delete t ft DoubleMove move1 move2 -> applyMoveFugitiveTickets move2 (applyMoveFugitiveTickets move1 ft) applyMoveDoubles :: Move -> Int -> Int applyMoveDoubles (DoubleMove m1 m2) dm = applyMoveDoubles m2 (applyMoveDoubles m1 (dm-1)) applyMoveDoubles _ dm = dm
haskell
module Mod where data Mod instance Num Mod where
haskell
diTransform f = let Done _ r = test1 (traceShow f f) in TL.pack $ listToString $ r ++ [TL.unpack $ TL.stripEnd f]
haskell
p _ Nothing = "" cc :: [String] -> String cc [] = mempty cc a = " {" ++ intercalate ", " (filter (not . null) a) ++ "}" instance T.ToJSON MessageCopyOptions where toJSON MessageCopyOptions { new_caption = new_caption, replace_caption = replace_caption, send_copy = send_copy } = A.object [ "@type" A..= T.String "messageCopyOptions", "new_caption" A..= new_caption, "replace_caption" A..= replace_caption, "send_copy" A..= send_copy ] instance T.FromJSON MessageCopyOptions where parseJSON v@(T.Object obj) = do t <- obj A..: "@type" :: T.Parser String case t of
haskell
e'iter = poly1 (\t zero -> e位 (t --> t) (\step -> e位 t'nat (\nat -> (nat %:: t) .: zero .: step))) e'const :: Exp e'const = e位 t'nat (\nat -> e'succ .: e'zero) -- | basic iteration example -- >>> typecheck e'count == t'nat -- True
haskell
>>= \ (err, res) -> throwIfErr err >> fromGodotVariant res) {-# NOINLINE bindRemoteTransform_set_remote_node #-} -- | The [NodePath] to the remote node, relative to the RemoteTransform's position in the scene. bindRemoteTransform_set_remote_node :: MethodBind bindRemoteTransform_set_remote_node = unsafePerformIO $ withCString "RemoteTransform" $ \ clsNamePtr ->
haskell
import Distribution.Simple haq = defaultMain
haskell
import Hasmin.Parser.Dimension import Hasmin.Parser.PercentageLength import Hasmin.Types.Gradient import Hasmin.Utils radialgradient :: Parser Gradient radialgradient = functionParser $ do
haskell
context "Server Var" $ do it "requires a non-empty default" $ isRight validServerVar `shouldBe` True it "requires non-empty enums, when present" $ invalidServerVarEnum `shouldBe` Left InvalidEnum it "requires a non-empty description, when present" $ invalidServerVarDescription `shouldBe` Left InvalidDescriptionSV context "Server" $ do it "requires an URL" $ isRight validServer `shouldBe` True it "requires a non-empty description, when present" $ invalidServerDescription `shouldBe` Left InvalidDescriptionS it "requires valid server vars, when present" $ invalidServerVar `shouldBe` Left (InvalidServerVar InvalidDescriptionSV)
haskell
in_a_block x l = not(free x l) diff_blocks :: Int -> Int -> [Int] -> Bool diff_blocks x y xs = abs(posx-posy) /= abs(x-y) where posx = indexOf x xs -1 posy = indexOf y xs -1 first_of_block :: Int -> [Int] -> Bool first_of_block x l | indexOf x l == 0 = False | (prev == 0) = is_an_adjacency x next len | otherwise = (not (is_an_adjacency prev x len) && is_an_adjacency x next len) where prev = return_nth' ((indexOf x l) - 1) l
haskell
} deriving (Show) makeLenses ''Node
haskell
oscillator :: Int -> Vector Double -> StochasticOscillator oscillator l v = let o = oscV l v os = Vec.map snd o tp = mavg (WindowSize 3) os l' = fromIntegral l f (j, x) = (j+l', x) in StochasticOscillator { osc = o
haskell
import Control.Lens (over, _1, _2) import Data.Either.Validation import Grammar.Common import qualified Grammar.Greek.Morph.ShouldElide.Round as Round import Grammar.Greek.Morph.ShouldElide.Types import Grammar.Greek.Morph.Types import Grammar.Greek.Script.Types
haskell
-- Programming, part 1. We'll be developing a sort of functional image -- library together. This file is made up of explanations (like this) -- and some prepared code. Some definitions you'll have to fill in -- yourself, just like in the previous exercise sets. -- We'll use the JuicyPixels library to generate images. The library -- exposes the Codec.Picture module that has everything we need. import Codec.Picture -- Let's start by defining Colors and Pictures. -- A Color is just three numbers: the red, green and blue components. -- We use Ints for convenience even though the valid range is only
haskell
contents <- readFile "1.lvl" stdGen <- newStdGen let rows = words contents let initialState = Game { level = rows, initialLevel = rows, playerPos = playerInitialPos, playerVel = playerInitialVel, seconds = 0, gen = stdGen, paused = False, gameState = Playing, bounce = False, cameraPos = cameraInitialPos} print rows
haskell
main :: IO () main = hspec spec spec :: Spec spec = do describe "VirtualArrow.Indices.gallagherIndex" $ do it "should be 0 in case of oneDistrictProportionality" $
haskell
-- depending on the current 'temperature'. The temperature is gradually -- reduced according to an annealing schedule, making random jumps less likely -- as the algorithm progresses. simulatedAnnealing :: (Problem p s a) => Schedule -> p s a -> IO (Node s a) simulatedAnnealing schedule prob = go 0 (root prob) where go k current = let t = schedule k in if t == 0 then return current
haskell
module Foobar (foobar) where foobar :: Int foobar = 42
haskell
deriving (Show, Eq) data Adjective = Payer | Payee
haskell
let e2 = removeAnnotations (textToCheckedExpr e1) let e3 = toCoDBExpr e2 let e4 = fromCoDB e3 let errorMessage = layoutAsString $ "Expected:" <+> line <> indent 2 ( squotes (prettyVerbose e2) <> line <> squotes (prettyVerbose e4)) <> line <> "to be equal" <>
haskell
main = do let limit = 2000000 let primes = filter isPrime [1..limit] let primeSum = sum primes print primeSum
haskell
| ref < ct && rf `Map.member` mp = return $ mp Map.! rf | ref >= ct = throwHeapErrorWithStepInfoSTE (\ _ -> HeapLookupOutOfBounds) | otherwise {- invalid heap ref -} = throwHeapErrorWithStepInfoSTE(\ _ -> InvalidHeapLookup) --- this doesn't validate Heap and heap allocator correctness, VERY UNSAFE :) unsafeRunHSCM :: Natural -> Heap val -> HeapStepCounterM val m b -> m (b,CounterAndHeap val ) unsafeRunHSCM cnt hp (HSCM m) = State.runStateT m (CounterAndHeap 0 0 cnt hp)
haskell
case infer env ctx t of Left err -> Left (TypeErr i err) Right v -> Right (Map.insert x v env, ctx) runRepl i (env, ctx) (DefineCheck x a t) = if x `Map.member` env then Left (EnvErr i x) else case check env ctx a (NfS (Type 0)) of Left err -> case check env ctx a (NfS (Type 1)) of Left err -> Left (TypeErr i err) Right a -> case check env ctx t a of Left err -> Left (TypeErr i err)
haskell
readProb :: FilePath -> IO State readProb path = return . initState =<< BL.readFile path initState :: ByteString -> State initState = either error initialState . parseTask . BL.init
haskell
tuple = [(1, 'a', "asdf"), (2, 'b', "asdf")] -- CAUTION: fst, snd, zip only work on pairs fst tuple -- return its first element snd tuple -- return its second element
haskell
import Control.Monad import Foreign import Foreign.C import Foreign.Marshal.Utils import Foreign.Storable #include "pg_query.h" instance Storable PgQueryError where
haskell
double :: Int -> Int double x = x + x recSum :: Num a => [a] -> a recSum [] = 0 recSum (n:ns) = n + sum ns qsort :: Ord a => [a] -> [a] qsort [] = [] qsort (x:xs) = qsort smaller ++ [x] ++ qsort larger
haskell
-- | Compose given list of monadic functions withFold :: Monad m => [m a -> m a] -> m a -> m a withFold = foldr (.) id -- | Turn list into sequence of monadic computations that is then composed withFoldMap :: Monad m => (a -> m b -> m b) -> [a] -> m b -> m b withFoldMap f = withFold . map f
haskell
import Ivory.BSP.STM32L471.MemoryMap import qualified Ivory.BSP.STM32L471.Interrupt as L471 import Ivory.BSP.STM32.Peripheral.RTC rtc :: RTC rtc = mkRTC rtc_periph_base rccenable rccdisable -- L471.RTC_TAMP_STAMP L471.RTC_WKUP L471.RTC_ALARM
haskell
runPlayerAction phase playerId game act = do phaseIs phase game playerIs playerId game getPlayerAction (act playerId game) preSetupAction = runPlayerAction PreSetup setupAction = runPlayerAction Setup
haskell
let m = defaultMaterial let pos = RTCTuple.point 0.0 0.0 0.0 let eyev = RTCTuple.vector 0.0 0.0 (-1.0) let normalv = RTCTuple.vector 0.0 0.0 (-1.0) let light1 = pointLight (Color (1.0,1.0, 1.0 )) (RTCTuple.point 0.0 0.0 (-10.0)) let result = lighting m light1 pos eyev normalv it "result = Color (1.9,1.9,1.9)" $ (Color (1.9, 1.9, 1.9)) ==result `shouldBe` True
haskell
-- Reimplemente a fun莽茫o bin2Int utilizando foldr. type Bit = Int bin2IntFoldr :: [Bit] -> Int bin2IntFoldr = foldr (\ x y -> x + 2 * y ) 0
haskell
module Graphics.GL.AMD.SamplePositions ( -- * Extension Support glGetAMDSamplePositions, gl_AMD_sample_positions, -- * Enums pattern GL_SUBSAMPLE_DISTANCE_AMD, -- * Functions glSetMultisamplefvAMD ) where import Graphics.GL.ExtensionPredicates import Graphics.GL.Tokens
haskell
module CommandLine (askQuestion, askStr, askOption) where askQuestion :: (Read a) => String -> IO a askQuestion = askQuestion' read askStr :: String -> IO String
haskell
it "returns beckon module name" $ N.addBeckonPrefix "beckon.steel.answerPage" `shouldBe` "beckon.steel.answerPage" it "returns beckon module name" $ N.addBeckonPrefix "steel.answerPage" `shouldBe` "beckon.steel.answerPage" describe "getSrcFilePath" $ do it "returns a correct JS file path" $ N.getSrcFilePath Common.FileType.JavaScript "steel.answerPage" `shouldBe`
haskell
identity :: a -> a identity = Prelude.id type ParseError = Text type ParseResult = Either ParseError [ParsedBankRow] type StatementText = ByteString data Handle = Handle
haskell
-- Author: <NAME> <<EMAIL>> module KS.Clean.Old.Options ( OldOptions (..) ) where import KS.Clean.Types data OldOptions = OldOptions { optBeforeDate :: Maybe Date , optArchive :: ShouldArchive , optConfDir :: ConfDir }
haskell
Day10.part2 putStr "\n" putStrLn "-- Day 11 --" putStr "Day 11 Part 1 - Result: " Day11.part1 putStr "Day 11 Part 2 - Result: " Day11.part2 putStr "\n" putStrLn "-- Day 12 --" putStr "Day 12 Part 1 - Result: " Day12.part1 putStr "Day 12 Part 2 - Result: "
haskell
ircFormat' C_B = "\x02" ircFormat' Br = "\n" ircFormat' I = "\x1D" ircFormat' C_I = "\x1D" ircFormat' U = "\x1F" ircFormat' C_U = "\x1F" ircFormat' x = damnFormat' x
haskell
level2TestCases = [ ("Single claim should be the claim itself", ["#1 @ 1,3: 4x4"], 1) , ("Given test case", ["#1 @ 1,3: 4x4", "#2 @ 3,1: 4x4", "#3 @ 5,5: 2x2"], 3) ] level2Tests = TestLabel "Level 2" $ TestList (map (makeTestWithLines level2) level2TestCases)
haskell
primalPivot :: Tableau -> Either PivotError Tableau primalPivot (Tableau deref objective context) = do let isOptimal :: Bool isOptimal = Map.null (Map.filter (< 0) objective) when isOptimal (throwError IsOptimal) let entry :: VarName entry = let go :: VarName -- Objective variable
haskell
, ("lparen" , lparen) , ("nil" , nil) , ("of" , fo) , ("rbrack" , rbrack) , ("rparen" , rparen) , ("tick" , tick) , ("underscore" , underscore)
haskell
type Stop = Int data Move = DetectiveMove Detective Ticket Stop | NullMove Detective Stop | FugitiveMove Ticket | Reveal Ticket Stop | DoubleMove Move Move deriving (Show, Read, Eq) data Player = MrX | Detectives deriving (Show,Eq)
haskell
spec :: Spec spec = do describe "decodeUtf8" $ do it "is inverse to encodeUtf8" $ do property $ \xs -> (decodeUtf8 . encodeUtf8) xs `shouldBe` xs
haskell
comboTwo _ = [] palindromeProducts :: [[Integer]] -> [Integer] palindromeProducts l = filter isPalindrome (map product l)
haskell
, backend ) where import Control.Lens import Data.Aeson import Data.Text (Text) import Network.HTTP.Types.Header
haskell
,"LinkKeeper (lnkp) Command help" ,"----------(Commands)----------" ,"help | shows this page" ,"list | Lists stored links" ,"add (link text) | adds link to list" ,"open (link number) | opens link by number" ,"remove (link number) | removes link by number" ,"-----------------------------" ,""]
haskell
newCommand (n, d, a) = Cmd { cmd = n, desc = d, runner = a } commands' :: [(String, String, ActionRunner)] commands' = [ ( "->" , "Post a message for a new or existing User. Usage: <@user> -> <message>" , postRunner ) , ( "" , "Displays the User's Posts. Usage: <@user>"
haskell
module IR where import Data.Text.Prettyprint.Doc import Data.Text.Prettyprint.Doc.Internal import Data.Text.Prettyprint.Doc.Util import qualified Data.Set as S import qualified Control.Monad.State as ST import qualified Data.Map.Strict as M import qualified OrderedMap as OM import Data.List (elemIndex) import Control.Monad(guard)
haskell
data Nibbles = Nibbles {-# UNPACK #-} !Int -- ^ offset (zero based index of first nibble) -- -- prop> let (Nibbles o _ _) in 0 <= o -- prop> let (Nibbles o l d) in o + l <= 2 * length d -- {-# UNPACK #-} !Int -- ^ length -- -- prop> let (Nibbles _ l _) in 0 <= l
haskell
{-# Language TypeSynonymInstances, TypeFamilies, FlexibleInstances, GeneralizedNewtypeDeriving #-} module Plush.Run.ShellExec ( VarScope(..), VarMode(..), VarEntry, ShellState(), initialShellState,
haskell
-- disc :: Position -> R -> sh :~> Position disc (originX, originY, originZ) radiusMax _ix gen = do radius <- uniformR (0,radiusMax) gen theta <- uniformR (0, pi) gen phi <- uniformR (0, 2*pi) gen return ( originX + radius * sin theta * cos phi , originY + radius * sin theta * sin phi , originZ + radius * cos theta )
haskell
relBase (newXs, output) where newCursorPosition = if newValPosition == position then position else position + 2 newXs = take newValPosition xs ++ head input : drop (newValPosition + 1) xs newValPosition = xs !! arg1 -- a -> out
haskell
x <- atomically $ PQ.deleteMin pq putStrLn $ "x = " ++ show x -- prints 2 @ -} module Data.STM.PriorityQueue.Class ( PriorityQueue(..) ) where import Control.Concurrent.STM class PriorityQueue q where -- | /O(1)/. Creates empty priority queue. new :: (Ord k) => STM (q k v)
haskell
pure fa {-# INLINE (=<<&) #-} -- The void function implemented with Functor / Applicative or Monad is slow. -- GHC cannot optimize it, especially when using in IO monad, it could slow -- down function even more than 10 times (!). void :: m a -> m () void = unsafeCoerce ; {-# INLINE void #-} when , unless :: (Applicative m, Mempty a) => Bool -> m a -> m a when_ , unless_ :: (Applicative m) => Bool -> m a -> m () whenM , unlessM :: (Monad m , Mempty a) => m Bool -> m a -> m a whenM_, unlessM_ :: (Monad m ) => m Bool -> m a -> m () when p s = ifThenElse p s (pure mempty) ; {-# INLINE when #-}
haskell
--- ENVIRONMENT MANAGEMENT --- type EnvParser = StateT Env Parser parseEnv :: EnvParser a -> BS -> Either String (Env, BS) parseEnv f = toEither `o` parse $ runStateT f initialEnv where toEither (Fail{}) = Left "Header parsing failure" toEither (Partial _) = Left "Consumed all input while parsed header" toEither (Done r (_, env)) = Right (env, r)
haskell
Copyright : (c) 2020 <NAME> License : BSD3 Maintainer : <NAME> <<EMAIL>> Stability : experimental Portability : portable Language : Haskell2010 -}
haskell
import Test.Tasty names :: TestTree names =
haskell
isbn xs = verify $ mapMaybe parse xs where parse c | c == 'X' = Just 10 | isDigit c = Just $ digitToInt c | otherwise = Nothing verify :: [Int] -> Bool verify xs@[x1, x2, x3, x4, x5, x6, x7, x8, x9, x10] = (x1 * 10 + x2 * 9 + x3 * 8 + x4 * 7 + x5 * 6 + x6 * 5 + x7 * 4 + x8 * 3 + x9 * 2 + x10) `mod` 11 == 0 && all (< 10) (take 9 xs) verify _ = False
haskell
S2 :: { fs1 :: a } -> S a updS s x = s { fs1=x } ------------------ GADT data T a b where T1 :: { ft1 :: a, ft2 :: c, ft3 :: d } -> T a Int T2 :: { ft1 :: a, ft3 :: c } -> T a Int T3 :: T Int b f :: T a1 b -> a2 -> T a2 b f x v = x { ft1 = v } ------------------ Type family data family R a
haskell
module Alpaca.View.Layout ( renderWithLayout ) where import Data.Text.Lazy (Text) import Text.Blaze.Html5 as H import Text.Blaze.Html5.Attributes as A renderWithLayout :: Text -> Html -> Html renderWithLayout title body = docTypeHtml $ do H.head $ do H.title $ toHtml title H.body body
haskell
-- | Constraint representing the fact that the field @x@ can be get and set on -- the record type @r@ and has field type @a@. This constraint will be solved -- automatically, but manual instances may be provided as well. -- -- The function should satisfy the invariant: -- -- > uncurry ($) (hasField @x r) == r
haskell
scalar :: ScalarType s -> s -> LLVM.Constant scalar (SingleScalarType s) = single s scalar (VectorScalarType s) = vector s single :: SingleType s -> s -> LLVM.Constant single (NumSingleType s) = num s vector :: VectorType s -> s -> LLVM.Constant vector (VectorType _ s) (Vec ba#) = LLVM.Vector
haskell
-> a -> Int -> Int -> a -> a -> a -> vector (Complex a) gaussianPinwheel1 numR2Freqs periodR2 stdR2 sigma thetaFreq rFreq periodEnv stdTheta stdR = let a = 1 / (stdR2 * sqrt 2) in VG.concat . parMap rdeepseq (\(radialFreq, angularFreq) -> let pinwheel = centerHollowArray numR2Freqs $
haskell
singleton = Singleton (<:>) :: a -> NonEmptyList a -> NonEmptyList a x <:> xs = Cons x xs instance Functor NonEmptyList where fmap f (Singleton a) = Singleton (f a) fmap f (Cons x xs) = Cons (f x) (fmap f xs)
haskell
Maintainer : <EMAIL> Stability : experimental Portability : POSIX This is an experimental API. Nakadi-client provides a 'MonadNakadi' instance for the 'IO' monad accessing a global mutable configuration. This module exports the user-visible API for managing this global configuration.
haskell
import Ivory.BSP.STM32F412.SYSCFG.Peripheral import Ivory.BSP.STM32F412.SYSCFG.Regs import Ivory.BSP.STM32F412.RCC import Ivory.BSP.STM32F412.MemoryMap (syscfg_periph_base) syscfg :: SYSCFG syscfg = mkSYSCFG syscfg_periph_base rccenable rccdisable where rccenable = modifyReg rcc_reg_apb2enr $ setBit rcc_apb2enr_syscfgen
haskell
-- a member of the graph. maybeVertex :: k -> Maybe G.Vertex } -- | The node for the given key. Return Nothing if the key is not -- a member of the graph. maybeNode :: DAG k v -> k -> Maybe v maybeNode DAG{..} k = _1 . nodeDesc <$> maybeVertex k {-# INLINE maybeNode #-} -- | The edge list for the given key. Return Nothing if the key is not -- a member of the graph. maybeEdges :: DAG k v -> k -> Maybe [k] maybeEdges DAG{..} k = _3 . nodeDesc <$> maybeVertex k {-# INLINE maybeEdges #-}
haskell
newTask title taskTime "" tags = Task { _taskHeadingL = Heading title taskTime , _taskDescL = Nothing , _taskTagsL = Tags tags } newTask title taskTime desc tags = Task { _taskHeadingL = Heading title taskTime , _taskDescL = Just $ Desc desc , _taskTagsL = Tags tags } completeTask :: Time -> Task -> Task completeTask t = taskHeadingL . taskTimeL . timeEndL %~ (<|> Just t)
haskell
query conn lookupTargets (Only websiteID) where lookupTargets = "SELECT TargetID, UserID, WebsiteID, Selector, Hash, Content " <> "FROM Targets " <> "WHERE websiteID = ?"
haskell
import qualified Lib.Client.Translation.Translation as ClientTranslation import qualified Lib.Model.Data as Data import Graphics.UI.Threepenny.Core import qualified Graphics.UI.Threepenny as UI data Picker = Picker { _container :: Element , _selection :: Event ()
haskell
factorial :: (Integral a) => a -> a factorial 0 = 1 factorial n = n * factorial (n-1) calcBmis :: (RealFloat a) => [(a,a)] -> [a] calcBmis xs = [bmi w h | (w,h) <- xs]
haskell
generateInputFile :: forall arch abi i o. (InSymbol arch abi ~ i, U.Universe i, Show i) => FilePath -> FSTGenerator arch abi -> IO () generateInputFile fp fst = Sys.withFile fp Sys.WriteMode $ \file ->
haskell
module WiredTiger.Raw.Context where import qualified Data.Map.Strict as Map import Language.C.Inline.Context import Language.C.Types import WiredTiger.Raw.Types wiredtigerCtx :: Context wiredtigerCtx = mempty { ctxTypesTable = Map.fromList
haskell
, magnify' ) where import Universum import Control.Monad.Identity (Identity) import Control.Monad.Trans.Except (ExceptT, mapExceptT) import Lens.Micro.Mtl ((.=)) import Lens.Micro as L import Lens.Micro.Mtl as LM import Lens.Micro.Mtl.Internal as LMI -- I don't know how to call these operators
haskell
`shouldBe` (Just mockItem, [[GetItem existingItemId]]) it "should return Nothing, if the Item does not belong to user" $ runTest (getItemBelongingToUserId existingItemId 456 mockEnv) `shouldBe` (Nothing, [[GetItem existingItemId]]) it "should return Nothing, if the Item does not exist" $ runTest (getItemBelongingToUserId 123 existingItemUserId mockEnv)
haskell
let masses = map read input :: [Int] let partOne = sum (map fuel masses) let partTwo = sum (map revisedFuel masses) print partOne print partTwo fuel :: Int -> Int fuel m = m `div` 3 - 2 -- Why greater than 5? Because 5 `div` - 2 = 0, and the puzzle tells us to -- treat values lower than 0 as 0 revisedFuel :: Int -> Int revisedFuel m
haskell
-- Stability : provisional -- Portability : portable -- -- This module corresponds to chapter 6 (AL Contexts and the ALC API) of the -- OpenAL Specification and Reference (version 1.1). --
haskell
trominoTilingLinks :: Links trominoTilingLinks = (items, [], options) where items = monomino ++ squares monomino = [ it "m" ] squares = [ it $ show r ++ show c | r <- [0..7], c <- [0..7] ] -- m 00 -- m 01 -- .. -- 00 01 02 -- 00 10 20 options = monominoes ++ trominoes
haskell
module Andromeda.Simulator ( module X ) where import Andromeda.Simulator.Types as X import Andromeda.Simulator.Actions as X import Andromeda.Simulator.Runtime as X import Andromeda.Simulator.Internal.SimulationCompiler as X
haskell
deriveSafeStore ''UUID -- orphans from filesystem-path instance Binary FilePath where put = Binary.put . F.encodeString get = F.decodeString <$> Binary.get instance SafeCopy FilePath where version = 1 kind = base errorTypeName _ = "Filesystem.Path.FilePath" putCopy = contain . safePut . F.encodeString getCopy = contain $ F.decodeString <$> safeGet
haskell
shouldBe (encodeDigestWith b $ f s) h -- | Test that Nix-like base32 encoding roundtrips prop_nixBase32Roundtrip :: Property prop_nixBase32Roundtrip = forAllShrink nonEmptyString genericShrink $ \x -> pure (encodeUtf8 x) === (B32.decode . B32.encode . encodeUtf8 $ x) -- | API variants prop_nixBase16Roundtrip :: StorePathHashPart -> Property prop_nixBase16Roundtrip x = pure (coerce x) === decodeWith Base16 (encodeWith Base16 $ coerce x) -- | Hash encoding conversion ground-truth. -- Similiar to nix/tests/hash.sh spec_nixhash :: Spec spec_nixhash = do
haskell
-- (Cons p1 (Cons p4 (Cons p2 (Cons p3 Nil)))) } @-} -- testAlternate3 = trivial -- {-@ testAlternate4 :: { -- alternate Nil (Cons p8 (Cons p9 Nil)) = -- (Cons p8 (Cons p9 Nil)) } @-} -- testAlternate4 = trivial
haskell
g2i :: GoodsTile -> String g2i (GoodsTile (Dice i)) = " " ++ show i ++ " " --Maybe Goods to Initials mg2i :: Maybe GoodsTile -> String mg2i Nothing = " " mg2i (Just g) = g2i g
haskell
data Method = DELETE | GET | POST | PUT deriving (Eq, Ord, Read, Show) -- | Braintree Request Parameters data BraintreeParameter = BTDict [(ByteString, BraintreeParameter)] | BTList [BraintreeParameter] | BTBool Bool | BTInt Int
haskell
module Luna.Std where import Luna.Prelude import Data.Map (Map) import qualified Data.Map as Map
haskell
import qualified Data.Binary.Get as Binary import qualified Data.ByteString.Lazy as BS import qualified Data.ByteString.Lazy.Builder as BS import qualified Data.Text.Lazy as L import qualified Data.Text.Lazy.Encoding as L import qualified Network.Socket as N hiding ( recv ) import qualified Network.Socket.ByteString.Lazy as N