lang
stringclasses
10 values
seed
stringlengths
5
2.12k
haskell
module Visualization where foo :: Int foo = 1
haskell
exactly_chinese n xs = let good m = let r = foldb plusmod $ map (unit m) xs in r === encode_mod m n in all good $ take (mods $ length xs) primes unit :: forall a. Boolean a => Int -> a -> [a] unit m x = not x : x : replicate (m-2) false
haskell
parseNumber = do digits <- reverse <$> some parseNumeral (pure . (`div` 10) $ foldr ((*10) .* (+)) 0 digits) <?> "tibetan integer" -- | Parse a single digit parseNumeral :: (Integral a, MonadParsec e s m, Token s ~ Char) => m a parseNumeral = foldr (<|>) (parseDigit '༠' 0) $ zipWith parseDigit "༠༡༢༣༤༥༦༧༨༩" [0..9]
haskell
--import MAlonzo.Code.Qcode (exportSqrt) import MAlonzo.Code.Qnats (exportFunc) main :: IO () --main = putStrLn . show $ exportSqrt (-3.0) main = print $ exportFunc (2)
haskell
-- This nests everything that happens next underneath a context that has -- logging functionality. `bracket` accepts a function to open up some -- resource, a function to call that cleans up that resource, and finally -- a block of code to run. bracket mkLogEnv closeScribes $ \le -> do -- This is our core datatype; our `App` that houses our logging hook, -- configuration information, etc. We can finally construct it here now -- that we have a logging environment ready (`le`) let app = App
haskell
-- where -- xs :: [ MyType ] -- xs = cantorEnumeration -- @ -- -- = Recursive example -- -- This should work nicely even with simple inductive types: -- -- @
haskell
test_factorial = testGroup "factorial (regressions)" [ testCase (show n) $ factorial n @?= product [1 .. n] | n <- [10, 100, 1000, 5000, 10000, 50000] ] prop_fastFactorial :: NonNegative Integer -> Property prop_fastFactorial (NonNegative n) =
haskell
rollbarCfg = configRollbar instance HasLoggingCfg Config where loggingCfg = configLogging --- --- --- type AppT m = AppT' FileServerDemoError m type AppT' e m = ReaderT Config (ExceptT e (LoggingJSONT m))
haskell
testProducer' :: Producer a => Int -> [a] -> ByteString -> IO () testProducer' idx (hd:[]) b = do let dsz = defaultSize hd (b1,b2) = bSplitAt dsz b x = one b1 idx x `shouldBe` hd Data.ByteString.Lazy.null b2 `shouldBe` True return () testProducer' idx (hd:tl) b = do let dsz = defaultSize hd (b1,b2) = bSplitAt dsz b x = one b1 idx
haskell
readLotsOfHex :: [BC.ByteString] -> Maybe [Some Geometry] readLotsOfHex bs = runGeosM $ do r <- S.createReader x <- traverse (S.readHex r) bs traverse convertGeometryFromRaw x writeHex :: Geometry a -> BC.ByteString
haskell
-- -- js_WebGPUColorWriteMaskAlpha -- :: JSVal js_WebGPUColorWriteMaskAlpha :: JSVal js_WebGPUColorWriteMaskAlpha = jsNull
haskell
KeycodeDown -> nextMenuItemST KeycodeUp -> prevMenuItemST KeycodeReturn -> doMenuActionST _ -> return () handleGameEvent d = do g <- get case keysymKeycode $ keyboardEventKeysym d of KeycodeLeft -> put $ g {snakeDir = V2 (-1) 0} KeycodeRight -> put $ g {snakeDir = V2 1 0} KeycodeDown -> put $ g {snakeDir = V2 0 1}
haskell
-- Problem 60 -- hbalTreeNodes -- Construct height-balanced binary trees with a given number of nodes hbalTreeNodes :: a -> Int -> [Tree a] hbalTreeNodes x n = concatMap filterTrees [minHeight .. maxHeight] where
haskell
-- | Instantiates a generic expression with the given type arguments. term :: TypeEnv -> Term Type -> [Type] -> K (Term Type) term tenv t args = foldlM go t args where go (Generic _name x expr _origin) arg = Substitute.term tenv x arg expr go _ _ = do
haskell
------------ PART A ------------ partA :: Input -> Int partA = uncurry (*) . foldl' go (0, 0) where go (h, v) (d, x) = case d of
haskell
{- When the plugin is disabled, this won't compile and will instead trigger the error "Couldn't match type H with L". When the plugin is enable with NO Defer flag, it will not compile and instead give the more meaningful error "Forbidden Flow from Secret (H) to Public (L)." When the plugin is enabled with Defer flag, it will just trigger
haskell
isExpr = isJust . exprPrism isEqn = isJust . eqnPrism exprs :: Foldable t => t (Lang x) -> [x] exprs = catMaybes . map exprPrism . toList equations :: Foldable t => t (Lang x) -> [Equation x] equations = catMaybes . map eqnPrism . toList
haskell
import Ouroboros.Consensus.NodeId import Ouroboros.Consensus.Protocol.Abstract import Ouroboros.Consensus.Protocol.PBFT import Ouroboros.Consensus.Util.Random import Ouroboros.Network.Chain (Chain) import Test.Dynamic.General import Test.Dynamic.Util import Test.Util.Orphans.Arbitrary () import Test.Util.Range
haskell
, membershipStudentId :: StudentId } deriving (Generic) newtype MembershipId = MembershipId { unMembershipId :: Int } deriving newtype (Eq, Show, ToJSON, FromJSON) deriving stock (Generic) #ifdef USE_DERIVING_VIA deriving via (ApiOptions ('Just "membership") Membership) instance (ToJSON Membership) deriving via (ApiOptions ('Just "membership") Membership) instance (FromJSON Membership)
haskell
import Control.Lens (makeLenses) import qualified Data.Sequence as Seq import QCommon.SearchPathT import QCommon.FileLinkT import Types makeLenses ''FSGlobals initialFSGlobals :: FSGlobals initialFSGlobals = FSGlobals { _fsGameDir = "" , _fsUserDir = ""
haskell
typeCheckType (L _ (T.RecordType fields)) = do fieldmap <- foldrM (\field e -> (flip (:) e) <$> typeCheckField field) [] fields id <- getUniqueEff #id pure $ TRecord fieldmap id typeCheckType (L _ (T.ArrayType typeid)) = do ty <- lookupTypeIdEff typeid
haskell
{-# LANGUAGE JavaScriptFFI #-} -- | An implementation of the NodeJS HMAC API, as documented -- <https://nodejs.org/api/crypto.html#crypto_class_hmac here>. module GHCJS.Node.Crypto.HMAC ( module GHCJS.Node.Crypto.HMAC -- FIXME: specific export list ) where import GHCJS.Array import GHCJS.Foreign.Callback import GHCJS.Types -- FIXME: implement crypto.createHmac -- FIXME: implement <HMAC>.digest
haskell
import FreeType.Core.Types.Types import FreeType.Support.System.Types #include "ft2build.h" #include FT_FREETYPE_H
haskell
module Data.Sv.Syntax.Sv ( Sv (Sv, _separatorSv, _maybeHeader, _records, _finalNewlines) , HasSv (sv, maybeHeader, traverseHeader, finalNewlines) , HasRecords (records, traverseNewlines, traverseRecords) , mkSv , emptySv , recordList , Header (Header, _headerRecord) , HasHeader (header, headerRecord, headerNewline) , noHeader
haskell
sFalse :: L.SBool False sFalse = L.SFalse hheadNonEmpty :: Int hheadNonEmpty = L.hhead (L.HCons 1 L.HNil) inotTrue :: L.SBool False inotTrue = L.inot (L.STrue :: L.SBool True)
haskell
) where import Prelude hiding ((*), recip, (/),(^)) import Numeric.Algebra.Class import Numeric.Algebra.Unital infixr 8 ^
haskell
module Tiling.A295229Spec (main, spec) where import Test.Hspec import Tiling.A295229 (a295229) main :: IO () main = hspec spec spec :: Spec spec = describe "A295229" $ it "correctly computes the first 10 elements" $ take 10 (map a295229 [1..]) `shouldBe` expectedValue where expectedValue = [1, 6, 84, 8548, 4203520, 8590557312, 70368815480832, 2305843028004192256, 302231454912728264605696, 158456325028538104598816096256]
haskell
import Data.Char (intToDigit) import qualified Data.Map.Strict as M hiding ((!)) import Data.Maybe import qualified Data.Vector as V import Numeric (showIntAtBase) import System.Environment import Text.ParserCombinators.Parsec (!) = (V.!) (!?) = (V.!?) data IMP = Stack StackOp | Arithmetic ArithOp | Heap HeapOp
haskell
reflectEnumInfo _ = P'.EnumInfo (P'.makePNF (P'.pack ".hadoop.hdfs.datanode.ReceivedDeletedBlockInfoProto.BlockStatus") ["Hadoop", "Protos"] ["DatanodeProtocolProtos", "ReceivedDeletedBlockInfoProto"] "BlockStatus")
haskell
, exampleFlatSlotId ) where import Cardano.Prelude import Cardano.Chain.Slotting ( EpochIndex(..) , EpochSlots(..) , SlotId(..)
haskell
-- | Okasaki's simple representation of a pairing heap, but with -- a size index. data Heap n a where E :: Heap 'Z a T :: a -> HVec n a -> Heap ('S n) a -- Coercing a heap could destroy the heap property, so we declare both -- type parameters nominal. type role Heap nominal nominal -- | A vector of heaps whose sizes sum to the index. data HVec n a where HNil :: HVec 'Z a
haskell
| tag <- (lookupInfo env arg) -- banged args need to be tagged, or require eval = not (isTaggedInfo tag) flatten_arg_tag (TagTagged) = TagProper flatten_arg_tag (TagProper ) = TagProper flatten_arg_tag (TagTuple _) = TagDunno -- See Note [Constructor TagSigs] flatten_arg_tag (TagDunno) = TagDunno collectExportInfo :: [GenStgTopBinding 'InferTaggedBinders] -> NameEnv TagSig
haskell
| cabalVersion > currentVersion -> let output | quiet config = name | otherwise = name ++ " current: " ++ showVersion currentVersion ++ " latest: " ++ showVersion cabalVersion in putStrLn output _ -> return () -- -- Look up cabal's repository cache --
haskell
-- Copyright : (c) <NAME> <<EMAIL>>, -- <NAME> <<EMAIL>>, -- <NAME> <<EMAIL>> -- License : LGPL (see COPYING) -- Maintainer : <NAME> <<EMAIL>>, -- <NAME> <<EMAIL>> -- Stability : unstable -- Portability : unportable
haskell
type N = Integer instance MonadFail Identity where fail = error len :: [a] -> N len xs = toInteger $ length xs dec :: N -> N dec a = a - 1
haskell
module Glean.Glass.Regression.Python (main) where import Test.HUnit import Glean.Regression.Test
haskell
import Test.Hspec import Test.QuickCheck import Control.Monad.Trans.Reader import Control.Monad.Trans.State import MonadTransformers.ChapterExercises.WriteTheCode spec :: Spec spec = do
haskell
-- atB (below), I get a type error: -- -- Couldn't match expected type `Basis a1' against inferred type `()' -- Expected type: a1 :-* (s :> Two s) -- Inferred type: s :-* (s :> Two s) -- In the first argument of `atB', namely `derivative v' -- -- I think this type error is a GHC bug, but I'm not sure. -- atB :: (AdditiveGroup b, HasTrie a) => Maybe (a :->: b) -> a -> b -- -- atB :: (AdditiveGroup b, HasBasis a, HasTrie (Basis a)) => -- -- Maybe (Basis a :->: b) -> Basis a -> b -- l `atB` b = maybe zeroV (`untrie` b) l
haskell
(.) = inNew2 $ \ g f -> \ a -> let f' = f a g' = g (copoint f') in g' . f' #if 0 type OkCart k = OpCon (Prod k) (Sat (Ok (Local k))) instance OpCon (:*) (Sat (Ok k)) => OpCon (:*) (Sat (OkLocal k)) where inOp :: (Sat (OkLocal k) a, Sat (OkLocal k) b) |- Sat (OkLocal k) (a :* b) inOp = Entail (Sub Dict) -- <+ okProd @k @a @b -- Could not deduce (Copointed (k (a, b)))
haskell
{-# LANGUAGE TypeFamilies #-} module T7892 where class C (f :: * -> *) where type F (f :: *) :: *
haskell
module ShouldFail where a :: Num a => (Bool -> [a]) -> [a] a x = x True ++ [1] y :: b -> () y = const () -- Typechecks ok
haskell
corners :: (Additive v, Traversable v) => BoundingBox v p -> [v p] corners (AABB minC maxC) = sequenceA $ liftI2 (\a b -> [a, b]) minC maxC
haskell
then pong s else eval (clean s) where clean = drop 1 . dropWhile (/= ':') . drop 1 ping x = "PING :" `isPrefixOf` x pong x = write "PONG" (':' : drop 6 x) eval :: String -> Net () eval "!quit" = write "QUIT" ":Exiting" >> io exitSuccess eval x | "!id " `isPrefixOf` x = privmsg (drop 4 x) eval _ = return () privmsg :: String -> Net () privmsg s = write "PRIVMSG" (chan ++ " :" ++ s)
haskell
cIndex = 0, cName = Man, cOccupy = occupy x0 y0, cPosition = (fromIntegral x0, fromIntegral y0), cRandomGenerator = mkStdGen 0, cSpeed = 4.0,
haskell
) where import AlgebraicStructures.Base import Data.List import GHC.Integer identity :: Eq a => (a -> a -> a) -> [a] -> Maybe a identity (+) d = find (\e -> all (\a -> e + a == a && a + e == a) d) d multIdentity :: Eq a => (a -> a -> a) -> (a -> a -> a) -> [a] -> Maybe a multIdentity (+) (*) d = (\d' -> identity (*) d') =<< (fmap (\e -> filter (/= e) d) (identity (+) d)) generate :: Eq a => (a -> a -> a) -> a -> [a]
haskell
\\aFeature\DC2\DLE\n\ \\fFEATURE_NONE\DLE\NUL\DC2\ESC\n\ \\ETBFEATURE_PROTO3_OPTIONAL\DLE\SOHBW\n\ \\FScom.google.protobuf.compilerB\fPluginProtosZ)google.golang.org/protobuf/types/pluginpbJ\249C\n\ \\a\DC2\ENQ.\NUL\182\SOH\SOH\n\ \\202\DC1\n\ \\SOH\f\DC2\ETX.\NUL\DC22\193\f Protocol Buffers - Google's data interchange format\n\ \ Copyright 2008 Google Inc. All rights reserved.\n\ \ https://developers.google.com/protocol-buffers/\n\
haskell
{-#LANGUAGE QuasiQuotes#-} module Language.Thesaurus.RogetLite.Incuriosity where import Language.Thesaurus incuriosity :: ThProg incuriosity = [thesaurus| # Ideas ## Incuriosity noun: * incuriosity incuriousness, insouciance , indifference verb: * be incurious have no curiosity , take no interest in , mind one's own business
haskell
} deriving Generic instance ToJSON LateralBreakageMember where toJSON = genericToJSON JsonUtils.dropUnderscore data DetectedBreakageSpan = DetectedBreakageSpan { _first_commit_id :: Int , _jobs_delimited :: Text , _job_count :: Int , _min_run_length :: Int , _max_run_length :: Int , _modal_run_length :: Int
haskell
import qualified Data.Set as S import qualified Data.Text as T import Advent.Y2020.Day6.DeclarationForm answerP :: Parser Answer answerP = do ans <- takeWhile1 (not . isSpace) <* endOfLine pure $ S.fromList $ T.unpack ans groupAnswersP :: Parser Group groupAnswersP = do
haskell
import Data.Binary (Binary(..)) import GHC.Generics (Generic) import Bitcoin.Types (Message(..)) data Verack = Verack deriving (Show, Generic)
haskell
, BehaviorU , Event(..) , liftBehavior , dv ) where import Prelude hiding ((.), id) import Control.Arrow import Control.Category import Data.Function (fix, (&)) import Data.Semigroup import Data.Profunctor -- | delta value to be applied on each input dv :: Float
haskell
import qualified Prelude import Text.Show.Pretty (Value (..), parseValue) import qualified Test.Pos.Util.Base16 as B16 type HexDump = LByteString type HexDumpDiff = [LineDiff] renderHexDumpDiff :: HexDumpDiff -> String renderHexDumpDiff = Prelude.unlines . fmap renderLineDiff
haskell
instance Delta (Throws e) (Throws e) throwChecked :: e -> Ef (Throws e ': ms) c a throwChecked = Send . Throw catchChecked :: forall ms c a e. (Monad c, Functor (Messages ms)) => Ef (Throws e ': ms) c a -> (e -> Ef ms c a) -> Ef ms c a catchChecked act h = handleThrows act where handleThrows :: Ef (Throws e ': ms) c a -> Ef ms c a handleThrows = transform id go
haskell
it "sets the weight correctly" $ do let rope = Node 11 (Leaf "hello ") (Leaf "world") (length' $ insert rope 5 " wicked") `shouldBe` length "hello wicked world" (length' $ insert rope 9 "d go") `shouldBe` length "hello word gold" (length' $ insert rope 6 "great ") `shouldBe` length "hello great world" it "stress tests" $ do let r1 = Leaf "hello" let r2 = insert r1 5 " world" let r3 = insert r2 5 " wicked" let r4 = insert r3 0 "well, " let r5 = insert r4 24 "." toString r5 `shouldBe` "well, hello wicked world."
haskell
import Text.Printf import System.FilePath type NonTermIdent = Int data Symbol = NonTerm NonTermIdent | Term TerminalData deriving (Show,Eq,Ord) type Grammar = Map Int [(Double,Song)] type Song = [Symbol] start :: Symbol start = NonTerm 0
haskell
-- | Constructor for 'SageMakerMonitoringScheduleScheduleConfig' containing -- required fields as arguments. sageMakerMonitoringScheduleScheduleConfig :: Val Text -- ^ 'smmsscScheduleExpression' -> SageMakerMonitoringScheduleScheduleConfig sageMakerMonitoringScheduleScheduleConfig scheduleExpressionarg = SageMakerMonitoringScheduleScheduleConfig { _sageMakerMonitoringScheduleScheduleConfigScheduleExpression = scheduleExpressionarg
haskell
module Language.UntypedPlutusCore.Core.Instance.Pretty () where import Language.UntypedPlutusCore.Core.Instance.Pretty.Classic () import Language.UntypedPlutusCore.Core.Instance.Pretty.Plc () import Language.UntypedPlutusCore.Core.Instance.Pretty.Readable ()
haskell
-- slim screenlock tool -- unclutter to hide mouse pointer -- urxvt terminal -- xcalib invert colors -- xmobar bar -- pass password manager
haskell
withDropPrefix :: String -> Options -> Options withDropPrefix prefix o = o { fieldLabelModifier = fieldLabelModifier o . (stripPrefix prefix >>= flip fromMaybe) } withDropConstructorPrefix :: String -> Options -> Options withDropConstructorPrefix prefix o = o { constructorTagModifier = constructorTagModifier o . (stripPrefix prefix >>= flip fromMaybe) }
haskell
bench "2" $ nfIO $ sqlFromGql 2, bench "5" $ nfIO $ sqlFromGql 5 ] ] sqlFromGql repeatedQ = do let gFilter = "checkDate: { isNotIn: [ \"2012-07-21\" ], isBetween: {start: \"1991-08-21\", end: \"2077-01-01\" } } " let mainQuery = " plantListQueryGenerator (first: 10, offset: 0, globalFilter: { " <> gFilter <> " }) { id name truckList { id }} " let queryQ s = "query plantList_test { " <> s <> " }" let queryStruct = GQLRequest { query = queryQ (mconcat $ replicate repeatedQ mainQuery),
haskell
lowerToCodeDiv4 c = case lowerToCode c of Just n -> case evenDiv2 n of Just n' -> evenDiv2 n' Nothing -> Nothing Nothing -> Nothing pipeM :: (a -> Maybe b) -> (b -> Maybe c) -> (a -> Maybe c) (f `pipeM` g) v = case f v of Just x -> g x
haskell
error $ mconcat ["Failed to read [[", str, "]] for environment variable ", env] -- | Fill a database from csv files main :: IO () main = do env <- lookupSetting "ENV" Development port <- lookupSetting "PORT" 8081 logEnv <- defaultLogEnv pool <- makePool env logEnv
haskell
-- -> Event t () -- -> m (Event t (ReqResult () HappyHour)) genQueryHH :: MonadWidget t m => Event t () -> m (Event t (ReqResult () [HappyHour])) genCreateHH :<|> genUpdateHH :<|> genDeleteHH :<|> _ :<|> genQueryHH = apiClients createHH :: MonadWidget t m => Event t HappyHour -> m (Event t UUID) createHH eHH = do
haskell
new :: rforall a. ST <a >a >Int new = undefined read :: hg:(Map <Int >Int) ~> p:Int -> ST <{h:Map <Int >Int | h == hg} >{h:Map <Int >Int | h == hg} >{v:Int| v == select hg p} read = undefined write :: h:(Map <Int >Int) ~> p:Int -> v:Int -> ST <{hg:Map <Int >Int | h == hg} >{hg:Map <Int >Int | store h p v == hg} >Unit write = undefined ----------------------------------------------------------------------------- -- | Sessions ----------------------------------------------------------------------------- channelStart :: {v:Int| v == 0} channelStart = 0
haskell
sdivo :: MonadBoolector m => Node -> Node -> m Node sdivo n1 n2 = mkNode ["sdivo", show n1, show n2] $ liftBoolector2 B.sdivo (_node n1) (_node n2) -- -- Comparison operations. -- -- | Create an unsigned less than.
haskell
( level , experience , attack , defence , levelUp ) where import Gimlight.Localization (MultilingualText, multilingualText) import TextShow (TextShow (showt)) level :: MultilingualText level = multilingualText "Level" "レベル" experience :: MultilingualText experience = multilingualText "Experience" "経験値"
haskell
orr :: a -> a -> a orr = undefined g :: _ g = f `orr` True f :: _ f = g
haskell
import Test.HUnit.Base main32 :: IO () main32 = do [myGCD 36 63, myGCD (-3) (-6), myGCD (-3) 6] @?= [9, 3, 3]
haskell
typeStringBlock :: String -> Maybe TypeError typeStringBlock src_ = let src = "void main(){"++src_++"}" in case parseProgram "src/Spec.hs" src of Left err -> Just (InternalError err)
haskell
run :: MongoDB.Action IO () run = do delete ([] :: [Filter User]) insertUsers
haskell
<gh_stars>1-10 {-# htermination (until :: (a -> MyBool) -> (a -> a) -> a -> a) #-} import qualified Prelude data MyBool = MyTrue | MyFalse data List a = Cons a (List a) | Nil until0 x p f MyTrue = x; until0 x p f MyFalse = until p f (f x); until :: (a -> MyBool) -> (a -> a) -> a -> a; until p f x = until0 x p f (p x);
haskell
instance Alternative Parser where empty = mzero (<|>) = mplus
haskell
backgroundProcess :: (Serialize i, Ord i, Serialize a, Eq i, Eq a) => KademliaInstance i a -> Chan (Reply i a) -> [ThreadId] -> IO () backgroundProcess inst chan threadIds = do reply <- liftIO . readChan $ chan case reply of
haskell
module Bench.Reader ( benchmark ) where import Control.Carrier.Reader import Control.Monad (replicateM_) import Control.Monad.Trans.Reader (runReaderT) import Gauge hiding (benchmark)
haskell
hello = "Hello World" dummy x = x -- a * x^2 + b * x + c = 0 d a b c = b*b - 4*a*c
haskell
main :: IO () main = hspec $ do describe "identities generated are proper" $ do it "identities are well ordered" $ do
haskell
getTotalRows ) where import Database.HDBC import Data.List getIntOrDefault :: Int -> [SqlValue] -> Int -> Int getIntOrDefault def [] _ = def getIntOrDefault _ row i = fromSql (row!!i) :: Int
haskell
text "', of type '" <+> prettyTCM t' <+> text "'." ca <- liftTCM $ runErrorT $ checkArguments ExpandLast DontExpandInstanceArguments (getRange mv) [] t' t case ca of Left _ -> __IMPOSSIBLE__ Right (args, t'') -> do leqType t'' t ctxArgs <- getContextArgs assignV m ctxArgs (term `apply` args) return False cs -> do reportSDoc "tc.constr.findInScope" 15 $ text ("findInScope 5: more than one candidate found: ") <+> prettyTCM (List.map fst cs)
haskell
. NE.nonEmpty . map (compile . unpack) . filter (not . T.null) . map T.strip . T.splitOn "," . pack where err = "Must be non-empty, comma-separated list of non-empty patterns"
haskell
modificarPeso :: (Peso->Peso)->Raton->Raton modificarPeso unaFuncion unRaton =unRaton { peso = unaFuncion.peso $unRaton } modificarEnfermedad :: (Enfermedades->Enfermedades)->Raton->Raton modificarEnfermedad unaFuncion unRaton =unRaton { enfermedades = unaFuncion.enfermedades $unRaton } enfermedadesQueNoterminanDeCiertaForma :: String->Enfermedades->Enfermedades enfermedadesQueNoterminanDeCiertaForma terminacion = filter (not.(== terminacion).tail) hierbaVerde :: String->Hierba
haskell
<gh_stars>1-10 -- Copyright (c) 2016, <NAME> -- ExternBug.hs {-# LANGUAGE ForeignFunctionInterface #-} module ExternBug (bar) where foreign import ccall "bar" bar :: IO ()
haskell
runTrials config = do conclusions <- for ([1 .. config ^. #stats . #numTrials] :: [Int]) $ \i -> do putStrLn $ "Run #" <> show i game <- runReaderT ?? config $ magnify #game $ newGame @rs label <- runGame @rs game & magnify (#stats . #heuristicWeights) & (runReaderT ?? config) & timeout (config ^. #stats . #microSecondsTimeout) <&> toGameLabel
haskell
Lexer.ParseResult(..), getDynFlags, lexTokenStream, lexTokenStreamWith, ) where import qualified Data.ByteString as B import Data.List
haskell
-- divByZeroCircuit' -- :: Circuit -- '[Var] -- '[Int] -- '[Var Int] -- '[Var] -- '[Int] -- '[Var Int] -- N1 -- divByZeroCircuit' = task -- (\_ _ _ -> do
haskell
-- * Notes -- ** Motivation -- | Haskell provides many ways to convert between common types, and core -- libraries add even more. It can be challenging to know which function to -- use when converting from some source type @a@ to some target type @b@. It -- can be even harder to know if that conversion is safe or if there are any -- pitfalls to watch out for. -- -- This library tries to address that problem by providing a common
haskell
filename :: FilePath, forceResolution :: Bool } paperOptions :: Parser PaperOptions paperOptions = PaperOptions <$> strOption ( long "filename" <> short 'f' <> metavar "FILENAME" <> help "File from which to read paper thoughs." ) <*> switch ( long "force" <> help "Whether to force the resolution of authors and references")
haskell
getConfig :: String -> Either String Config getConfig input = case parse parseConfig "Config Error!" input of Left err -> Left $ show err Right c | isJust (getWidth c) -> Right c | isJust (getHeight c) -> Right c
haskell
import Data.Map (Map) import qualified Data.Map as Map -- Map.lookup "Foo" hashTable hashTable :: Map String Integer hashTable = Map.fromList [("Foo", 1), ("Bar", 2), ("Buz", 3)]
haskell
-- -- Stability : experimental -- Portability : non-portable (OS X - only) -- -- Tools for investigating binaries. module Ez.System.Binutil (readRpaths) where #ifdef darwin_HOST_OS import Ez.System.Otool #elif linux_HOST_OS import Ez.System.Elf #endif
haskell
module Number where -- 整数 (有界) number1 :: Int number1 = 123 -- 整数 number2 :: Integer number2 = 100000000000000000000 -- 浮動小数点数 (単精度) number3 :: Float number3 = 10 / 3 -- 3.3333333 -- 浮動小数点数 (倍精度)
haskell
printGrid res height print n printGrid :: Grid -> Int -> IO () printGrid g h = mapM_ putStrLn $ map (\m -> flatten $ map show $ map snd $ M.toList $ M.filterWithKey (\(x,y) _ -> y == m) g) [0..h-1] simulate :: (Grid,Int,Int) -> (Grid,Int,Int) simulate (g,countit,fc) = (resetToZero n,countit+1,nfc) where incd = foldl (mapInc) g allPoints (n,nfc) = until (\(a,_) -> M.size (M.filter (>9) a) == 0) flashAll (incd,fc)
haskell
module Test.TWebDriver ( module Test.WebDriver ) where -------------------------------------------------------------------------------- import Test.WebDriver hiding (Element (..), Selector (..), click, findElem) --------------------------------------------------------------------------------
haskell
module Main where import Lib ( parseFile , createPSTypes ) import Protolude
haskell
scriptExists :: [ByteString] -> Edis xs xs (Either Reply [Bool]) scriptExists scripts = Edis $ Redis.scriptExists scripts scriptFlush :: Edis xs xs (Either Reply Status) scriptFlush = Edis $ Redis.scriptFlush scriptKill :: Edis xs xs (Either Reply Status) scriptKill = Edis $ Redis.scriptFlush
haskell
:> Post '[ SafeJSON] (Headers '[ Header "x-trace-uuid" String] KnowledgeModel) list_POST :: Maybe String -> KnowledgeModelChangeDTO -> BaseContextM (Headers '[ Header "x-trace-uuid" String] KnowledgeModel) list_POST mTokenHeader reqDto = getMaybeAuthServiceExecutor mTokenHeader $ \runInMaybeAuthService -> runInMaybeAuthService $ addTraceUuidHeader =<< createKnowledgeModelPreview reqDto
haskell
data JSRulePtr type JSRule = JSPtr JSRulePtr instance FromJS JSRule Rule where fromJS = jsRule2Rule
haskell
module Main ( main ) where import Prelude import Freckle.App.Test.DocTest main :: IO () main = doctest "library/"
haskell
clientName client = case client of GovOrg name -> name Company name id person resp -> name Individual person ads -> case person of Person fNm lNm gender -> fNm ++ " " ++ lNm--}
haskell
} type instance Elem (Vector a) = a type instance CollIndex (Vector a) = Data Index type instance CollSize (Vector a) = Data Length -- | Non-nested vector type Vector1 a = Vector (Data a) -- | Two-level nested vector type Vector2 a = Vector (Vector (Data a))
haskell
-- @fields@. -- e.g. -- data Foo = { a :: Int } -- makeExtendingDatatype "bar" [''Foo] [("b", [t| String |])] -- Will generate