lang
stringclasses
10 values
seed
stringlengths
5
2.12k
haskell
(\m i -> if m == 'X' then i else charIntToBool m) mask (intToBits val) ) in run (Map.insert mem newVal acc) mask as True -> let msk = a =~ "[X,0-9]+" :: String in run acc (replicate 28 'X' <> msk) as runV2 acc mask = \case [] -> acc (a : as) -> case matchTest (mkRegex "^mask") a of
haskell
-- are counted from 0 and we wrap around cyclically if /i/ equals the -- length of the list. import Quipper import QuipperLib.Arith
haskell
primeFacsExp :: Integer -> [(Integer, Int)]
haskell
, eventsMonth , eventExpectedDelivery , eventEstimatedOvulation ) where import Data.Time.Calendar (Day, addDays) import ICalendar (Event, vEvent) standardDuration :: Num a => a
haskell
{-# LANGUAGE TypeOperators #-} {-| Entry point for the entire application. -} module Main where
haskell
return $ VkPipelineColorBlendStateCreateInfo { vkSType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO , vkPNext = nullPtr , vkFlags = zeroBits , vkLogicOpEnable = logicOpEnable , vkLogicOp = logicOp , vkAttachmentCount = fromIntegral attachmentsLen , vkPAttachments = attachmentsPtr , vkBlendConstants = let V4 x y z w = blendConstants in SV.fromTuple $ coerce (x, y, z, w)
haskell
(return $ MkR CantReadFile p defaultValue) MkR SuccessfulResolution p a -> do let val = decode a case val of Just b ->
haskell
main = do [host, port, n] <- getArgs sok <- initSocket host port -- intialise the server socket putStrLn $ "staring server on " ++ host ++ ":" ++ port kill <- newEmptyMVar li <- newMVar (read n :: Int) rms <- newTVarIO [] let inf = ("IP:10.62.0.104\nPort:"++port++"\nStudentID:13319506\n") ser = Server {info=inf, sock=sok, roomsList=rms, stop=kill, limit=li} --_ <- forkIO $ runServer sock (read n :: Int) ("IP:10.62.0.104\nPort:"++port++"\nStudentID:13319506\n") kill _ <- forkIO $ runServer ser takeMVar kill putStrLn "Terminating Server"
haskell
let programOps = withFileOperations fileOperationsDoesFileExistFail undefined org = GithubOrg "org1" repo = GithubRepo "repo1" configDir = mkTextTag "/some/dir/path" handlerProg = repoHandler programOps org repo configDir (result, outputState) = runState handlerProg Map.empty
haskell
} newtype PubsubMessageBatch = PubsubMessageBatch { messages :: [PublishPubsubMessage] } deriving stock (Show, Eq, Generic) deriving anyclass Aeson.ToJSON newtype PublishResponse = PublishResponse { messageIds :: [MessageId] } deriving stock (Show, Eq, Generic) deriving anyclass Aeson.FromJSON
haskell
import Database.PostgreSQL.Simple.Migration import Database.PostgreSQL.Transact import GHC.Generics import GHC.IO (mkUserError) import GHC.Stack import GHC.TypeLits import Hedgehog (MonadGen (..)) import qualified Hedgehog.Gen as H
haskell
tickTime = do timeStateRef' <- view (env.monadTimeStateRef) timeNow <- Time.time liftIO $ modifyIORef' timeStateRef' (tickTimeState timeNow) tickTimeState :: Seconds -> MonadTimeState -> MonadTimeState tickTimeState timeNow ts = ts & previousTime .~ (ts ^. currentTime) & currentTime .~ timeNow deltaTime :: ( MonadReader r m , HasEnv r , MonadIO m
haskell
instance Storable DevInfo where sizeOf _ = #size struct hidraw_devinfo alignment _ = 4 -- #alignment struct hidraw_devinfo peek p = do
haskell
, Options(..) , NodeFormat (..) , parse ) where import Control.Applicative ((<|>)) import Prelude hiding (FilePath)
haskell
dataFileName = baseOutputName ++ ".txt" results' = map ((\[a, b] -> (a, b)) . L.toList) results chartPlot2D results = do layout_title .= "Normal Coordinates" setColors [opaque red] plot (points "points" results) pp2DResults' :: FilePath -> [(Double,Double)] -> IO ()
haskell
import Text.Trifecta type Password = String data PasswordPolicy = PasswordPolicy { char :: Char, minLetters :: Integer, maxLetters :: Integer } deriving (Show, Eq) data PasswordRecord = PasswordRecord PasswordPolicy Password deriving (Show, Eq) newtype Error = Error { message :: String } deriving (Show, Eq)
haskell
defaultSystemOnTPTP = SystemOnTPTP { optAutoMode = "-cE" , optAutoModeSystemsLimit = "3" , optAutoModeTimeLimit = "300" , optCompleteness = False , optCorrectness = False , optCPUPassword = "" , optFORMULAEProblem = "" , optFormulaURL = "" , optIDV = False , optNoHTML = "1" , optProblemSource = "FORMULAE" --"TPTP" , optQuietFlag = "-q01" --q2 , optReportFlag = "-q0"
haskell
Stability : experimental Portability : POSIX Example using KeyHomomorphicPRF with AT. -} module KHPRFAccMain where
haskell
, dfa_D :: arrow (s, a) s , dfa_q_0 :: s , dfa_F :: Set s } -> DFA arrow s a data NFA arrow s a where
haskell
import RIO.Effect import RIO.Effect.TH data Teletype cfg a where GetL :: Teletype cfg String PutL :: String -> Teletype cfg () genSend ''Teletype teletypeIO :: EFF Teletype cfg :~> MonadIO teletypeIO = handleEffect $ \case GetL -> liftIO getLine PutL l -> liftIO ( putStrLn l )
haskell
-} type HomoFuncConstraint (n :: Nat) a = (HomoArgFuncConstraint n a, ResultT n a ~ IndexT 0 a) {-| Like 'HomoFuncConstraint', but only constrains all the arguments to be the same type, not the result. -} type family HomoArgFuncConstraint (n :: Nat) a :: Constraint type instance HomoArgFuncConstraint 0 a = (FuncConstraint 0 a) type instance HomoArgFuncConstraint 1 a = (FuncConstraint 1 a) type instance HomoArgFuncConstraint 2 a = (FuncConstraint 2 a, IndexT 0 a ~ IndexT 1 a)
haskell
import Data.Word -- | Subwords of size 2 ^ 0 alternating between all bits cleared and all bits mu0 :: Word16 mu0 = 0x55 {-# INLINE mu0 #-} -- | Subwords of size 2 ^ 1 alternating between all bits cleared and all bits mu1 :: Word16 mu1 = 0x33 {-# INLINE mu1 #-} -- | Subwords of size 2 ^ 2 alternating between all bits cleared and all bits mu2 :: Word16
haskell
data Number = One | Two data Tuple (a :: *) (b :: *) (c :: *) (d :: *) = Double a b | Triple a b c | Quad a b c d -- Test uses type constructors with more than two data contructors with -- more than 2 parameters. Contains incomplete patterns. (\i. case i of Double x (Double y y') -> y' Double x (Triple y y' y'') -> y'' Triple x y (Triple z z' z'') -> z'' Quad x y z (Double w w') -> w' -- Matches this line, returns Two Quad x y z (Quad w w' w'' w''') -> w'''
haskell
instance (Arrow arr) => Applicative (FoldA arr i a) where pure x = FoldA (ret ()) (ret ()) (ret x) {-# INLINE pure #-} FoldA stepL startL doneL <*> FoldA stepR startR doneR = let step = arr (\(Pair (Pair xL xR) a) -> Pair (Pair xL a) (Pair xR a)) >>> (stepL **** stepR) start = startL &&&& startR done = (doneL **** doneR) >>> arr applyP in FoldA step start done {-# INLINE (<*>) #-}
haskell
import PKCloud.Accounts.Import as Export import PKCloud.Accounts.Routes as Export instance PKCloudAccounts master => PKCloudApp (PKCloudAccountsApp master) where pkcloudAppName PKCloudAccountsApp = "Accounts" pkcloudAppIdentifier PKCloudAccountsApp = "accounts" pkcloudAppRoot = HomeR
haskell
module Generator.Smoother ( Smoother (..) , smooth , anneal , cluster ) where import Data.Foldable (toList) import Data.Kind (Type) import Data.List (delete) import Data.Maybe (fromMaybe) import Data.Nat (Nat) import qualified Map import Map (Map_)
haskell
exec_C_ADDI :: GPR_Addr -> InstrField -> Machine_State -> Machine_State exec_C_ADDI rd_rs1 nzimm6 mstate = let imm12 = sign_extend 6 12 nzimm6 instr_I = ADDI rd_rs1 rd_rs1 imm12 is_C = True mstate1 = exec_ADDI is_C instr_I mstate in mstate1 -- ================================================================ -- C_JAL: expands to JAL exec_C_JAL :: InstrField -> Machine_State -> Machine_State
haskell
genChildren tcn cs = do funD 'children (map (genChildrenClause tcn) cs) genChildrenClause :: TH.Name -> Con -> Q Clause genChildrenClause tcn (NormalC name fieldTypes) = do fieldNames <- replicateM (length fieldTypes) (newName "x") let pats = [conP name (map varP fieldNames)] body = return . NormalB . concatLists . catMaybes =<< mapM (fieldChildren tcn) (zip fieldNames fieldTypes) clause pats body [] genChildrenClause _ _ = error "genChildrenClause: Bad Con"
haskell
errHandler e = do resources' <- loggerHandler resources e writeIORef resourcesRef resources' when (predicate pri) action `C.catch` errHandler loggerHandler :: LoggerResources -> C.SomeException -> IO LoggerResources loggerHandler resources e = do logError stdHandler "failed to use log file, error is:" logError stdHandler $ T.pack $ C.displayException e
haskell
<gh_stars>1-10 module Task2 where
haskell
<gh_stars>1-10 {- Problem 9 Find the product a*b*c of the only Pythagorean triplet (a, b, c) for which a + b + c = 1000. Result 31875000 .58 s -} module Problem9 (solution) where
haskell
compareLastNames name1 name2 = if lastNameCompare == EQ then firstNameCompare else lastNameCompare where lastName1 = snd name1 lastName2 = snd name2 firstName1 = fst name1 firstName2 = fst name2 lastNameCompare = compare lastName1 lastName2 firstNameCompare = compare firstName1 firstName2 sfOffice :: ([Char], [Char]) -> [Char] sfOffice name =
haskell
convertTime = posixSecondsToUTCTime . realToFrac . diffPosix . fromWindowsTick where fromWindowsTick x = x `div` 10000000 diffPosix x = x - 11644473600
haskell
let newNode = ASTUtil.buildQName newName $ SrcLoc.SrcLoc (SrcLoc.srcSpanFilename span) (SrcLoc.srcSpanStartLine span) (SrcLoc.srcSpanStartColumn span) let newRewrite = ASTUtil.Rewrite (SrcLoc.srcInfoSpan $ Syntax.ann node) (length newName - length oldName) rewrites <- get put $ newRewrite : rewrites
haskell
NB: mapper takes as input a CONLL-parsed file (one sentence per line, #-separated tokens) NB: first line (containing tab-separated contexts elements) must be manually added to the file that is the result of hadoop
haskell
-- Module : Streamly.External.Posix.DirStream -- Copyright : © 2020 <NAME> -- License : BSD3 -- -- Maintainer : <NAME> <<EMAIL>> -- Stability : experimental -- Portability : portable
haskell
. fmap (\x -> bool x '@' $ x == 'b') . intercalate "." . fmap (\(z, o) -> nameOfNote (head ns) z ++ "/" ++ show o) . flip zip is $ intsFromNotes ns where (ns, is) = unzip nos
haskell
import System.IO.Unsafe -- | Native machine code JIT execution target -- data Native = Native { gangSize :: {-# UNPACK #-} !Int , linkCache :: {-# UNPACK #-} !LinkCache , fillS :: {-# UNPACK #-} !Executable , fillP :: {-# UNPACK #-} !Executable , segmentOffset :: !Bool
haskell
import Atcoder.Task myConfig :: WDConfig myConfig = defaultConfig { wdCapabilities = (defaultCaps { browser = chrome }) } main :: IO () main = defaultMain =<< tests tests :: IO TestTree
haskell
puncture :: PhaseVector -> (PhaseVector, PhaseVector) puncture v = let v' = AMV.toVector v u' = V.uniq v' gen i | i >= V.length v' = Nothing | v' V.! (i-1) == v' V.! i = Just (v' V.! i, i+1) | otherwise = gen $ i+1 in (fromVector u', fromVector $ V.unfoldr gen 1) unfold :: (b -> (a,b)) -> b -> [a] unfold f b = let (a,b') = f b in a : unfold f b' -- | probability assigned to \( w \), given by \( \theta = s/N - w/T -- \), by the \( T \)-dimensional inverse-QFT of the given punctured
haskell
persistClassyRules :: LensRules persistClassyRules = persistDefaultRules & lensIso .~ const Nothing & handleSingletons .~ False & lensClass .~ classy & classRequired .~ True & partialLenses .~ False & buildTraversals .~ True where
haskell
import Control.Monad.IO.Class import Control.Monad.Trans.State.Lazy import Control.Monad (void) import App.Domain import App.State import App.Repositories import App.Data import App.Entities initialState :: App FakeRepo FakeRepo FakeRepo initialState = App { appDependencies = AppDependencies { accountRepository = FakeRepo , transactionRepository = FakeRepo , customerRepository = FakeRepo
haskell
instance Show Color where show Transparent = " " show Black = "X" show White = "-" readRow :: [Int] -> Int -> ([Int], [Int]) readRow pixels w = foldl (\(result, h:t) i -> (result ++ [h], t)) ([], pixels) [1 .. w] readLayer :: [Int] -> Int -> Int -> ([[Int]], [Int])
haskell
module Data.List(BST) where data BST k v = Leaf | Branch (BST k v) k v (BST k v) deriving (Eq, Show) insert k v Leaf = Branch Leaf k v Leaf insert k v (Branch l k' v' r) | k<k' = Branch (insert k v l) k' v' r
haskell
-- Retorna o numero de valores acima da media na lista qtd_acima_media [_] = 1 qtd_acima_media lista = size_list (acima_media lista)
haskell
{-# LANGUAGE DataKinds #-} {-# LANGUAGE DatatypeContexts #-} {-# LANGUAGE PolyKinds #-} {-# LANGUAGE StandaloneKindSignatures #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE UnliftedNewtypes #-} {-# LANGUAGE LinearTypes #-}
haskell
_ <- string "path:" _ <- spaces path <- manyTill anyChar endOfLine _ <- spaces _ <- string "version:" _<- spaces version <- manyTill anyChar (lookAhead endOfLine) pure $ PR name path version
haskell
module ForSyDe.Reactive ( module ForSyDe.Reactive.CoreTypeSY, module ForSyDe.Reactive.CoreSY, module ForSyDe.Reactive.CoreTypeCT, module ForSyDe.Reactive.CoreCT, module ForSyDe.Reactive.Utils ) where import ForSyDe.Reactive.CoreTypeSY import ForSyDe.Reactive.CoreSY
haskell
header bar = style [ ("position", "absolute") , ("left", px 0) , ("top", px 0) , ("width", "100%") , ("height", px (if bar then 24 else 0)) , ("background-color", "#333") , ("border-radius", "2px 2px 0px 0px") , ("user-select", "none") ] content bar = style [ ("position", "absolute")
haskell
module Main where import Date main :: IO () main = runDateDemo
haskell
writeToScreenWithPos :: Game -> ((Surface -> Const Surface Surface) -> Surfaces -> Const Surface Surfaces) -> Point V2 CInt -> IO () writeToScreenWithPos s source pos = surfaceBlit (s^.surfaces.source) Nothing (s^.surfaces.screenSurface) (Just pos) writeScore :: Game -> IO () writeScore state = bracket (renderUTF8Solid (state^.world.font) msg titaniumWhite)
haskell
-- | Flat genomes -- prop> all in [0.0, 1.0] type ChromosomeType = Double type OrderPermutationGenome = [ChromosomeType] type SelectorGenome = [ChromosomeType] type PackingSelectorGenome = [ChromosomeType] type OrientationGenome = [ChromosomeType] type FillOrderGenome = [ChromosomeType] -- | Tupelization of all flat genomes type RandomSelectors = ( SelectorGenome
haskell
listAll = do xs <- getPings putStrLn $ ppShow $ map head $ group $ sort $ map getName xs getName xs = case break (== '_') (reverse xs) of (as,_:bs) -> reverse bs
haskell
} return pa pulseM :: ((a -> IO ()) -> (String -> IO ()) -> ReaderT PulseAudio IO ()) -> PulseM a pulseM f = do pa <- lift ask contErrT $ \cont exit -> f (flip runReaderT pa . cont) (flip runReaderT pa . exit) resetContext :: PulseM () resetContext = contErrT $ \cont exit -> do pa <- ask
haskell
strictSAN :: forall s. (Stream s, SANToken (Token s), IsString (Tokens s)) => Position -> Parser s Ply strictSAN pos = case legalPlies pos of [] -> fail "No legal moves in this position" ms -> (castling pos <|> normal ms) >>= checkStatus where normal ms = do p <- sanPiece <|> pure Pawn case filter (pieceFrom p) ms of [] -> fail $ show (color pos) <> " has no " <> show p <> " which could be moved" ms' -> target p ms' pieceFrom p (moveFrom -> from) = p == snd (fromJust (pieceAt pos from)) moveFrom (unpack -> (from, _, _)) = from target p ms = coords p ms >>= \m@(unpack -> (_, to, _)) -> case p of Pawn | lastRank to -> promoteTo m <$> promotion
haskell
<gh_stars>0 module TreesThatGrows.Example where example :: IO () example = putStrLn "hello, trees that grows"
haskell
data TheFees = TheFees { k :: Float , c :: Int } deriving Show data Fees = Fees deriving Show type Proof = Map Address Account -- | Increment nonce. touchAccount :: Access Address Account m => Address -> m ()
haskell
case mKnownFields of Nothing -> return TcPluginNoRewrite Just knownFields -> return TcPluginRewriteTo { tcRewriterWanteds = [] , tcPluginReduction =
haskell
import Relude import qualified Data.Generics.Uniplate.Data as U import qualified Data.List as L import Expr distribute :: Expr -> Expr distribute = U.rewrite f where f :: Expr -> Maybe Expr f e@Or{} | res == e = Nothing | otherwise = Just res
haskell
module JosephusPermutationSpec (spec) where import JosephusPermutation (josephus) import Test.Hspec spec = do describe "josephus" $ do it "works with integers" $ do josephus [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] 1 `shouldBe` [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] josephus [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] 2 `shouldBe` [2, 4, 6, 8, 10, 3, 7, 1, 9, 5]
haskell
, fail_ctr_rollover , fail_encrypt_gcm ) where import Ivory.Language import Ivory.Serialize newtype GecError = GecError Uint32
haskell
module X ) where import Game.GoreAndAsh.Core as X import Game.GoreAndAsh.Math as X
haskell
data RunconSwitch = DUMMY deriving (Bounded, Enum, Eq, Ord, Show) data OutputArgs = OA String runcon :: Utility RunconSwitch OutputArgs OutputArgs OutputArgs OutputArgs runcon = Utility "runcon" argDescs input parse core format output where input _ = return $ OA "" parse _ = id
haskell
| If | Cons | Add | Sub | Mul | Le | Lt | Eq deriving Eq -- | Associativty data Assoc = AssocLeft | AssocRight
haskell
let batchSize = BatchSize 1 let utxo = CoinMap $ Map.fromList [ ( mkInputId "|\243^\SUBg\242\231\&1\213\203" , unsafeCoin @Int 2 ) ] property $ prop_inputsGreaterThanOutputs @InputId @OutputId feeOpts batchSize utxo -------------------------------------------------------------------------------- -- Properties -------------------------------------------------------------------------------- -- | No coin selection has outputs
haskell
getHomeR :: Handler Html getHomeR = do defaultLayout $ do setTitle $ title "Home" $(widgetFile "homepage")
haskell
mockStackS1 = [Stone P1 S, Stone P2 F, Stone P1 F] mockStackC1 = [Stone P1 C, Stone P2 F] mockStackF2 = [Stone P2 F] mockCellA1 = Cell ('a', 1) mockStackS1 mockCellA2 = Cell ('a', 2) mockStackS1 mockCellA3 = Cell ('a', 3) mockStackF2 mockCellB3 = Cell ('b', 3) mockStackS1 mockCellC4 = Cell ('c', 4) mockStackC1 mockBoard =
haskell
-- | Creates a constant with a given value constantVar :: Constant -> Variable constantVar = ConstantVar isVariableChar :: Char -> Bool isVariableChar c = isAlphaNum c || c == '_' || c == '-' || c == '.' -- | Creates a variable with a given name. variable :: String -> Variable variable (x:y) = if isLetter x && all isVariableChar y then Var (x:y) else error "variable name must start with a letter and contain only alphanumeric characters, dot, underscore or hyphen" variable _ = error "variable name is empty"
haskell
) updateCountF :: Members '[BaseApp.WriteStore, Output BaseApp.Event, BaseApp.Logger] r => Count -> Sem r () updateCountF count = do V.putVar count countVar let event = CountSet count BaseApp.emit event BaseApp.logEvent event
haskell
LitPat _ l -> litToTokens l -- Aeson.object ["lit" .= l] IntervalPat _ x y -> error "paToToken IntervalPat TBD" -- Aeson.object ["interval" .= [x, y]] ConsPat _ x y -> error "paToToken ConsPat TBD" -- Aeson.object ["cons" .= [x, y]] ConPat _ x y -> error "paToToken ConPat TBD" -- Aeson.object ["con" .= [toJSON x, toJSON y]] ListPat _ xs -> error "paToToken ListPat TBD" -- Aeson.object ["list" .= xs]
haskell
withFixture1 :: String -> IO a -> IO () withFixture1 nm f = Exception.bracket setUp (\_ -> f) tearDown where setUp = Printf.hPrintf IO.stderr "(%s) SetUp ...\n" nm tearDown _ = Printf.hPrintf IO.stderr "... TearDown (%s)\n" nm epsilon = 0.001 (lst, revlst) = ([0..4], reverse (enumFromTo 0 4)) caseSquare = mapM_ (\n -> do mapM_ (\(funcA, nm) -> assertEqual nm (n ** 2.0) (funcA n) ) [(squareR, "squareR"), (squareI, "squareI") , (squareF, "squareF"), (squareU, "squareU") , (squareLc, "squareLc")]
haskell
case11_no x = let {-# NOINLINE y #-} y = x + 1 {-# NOINLINE f #-} f 0 = 1 f z = f (z-1) * y -- Could float into argument and contify (but shouldn't!)
haskell
cross f g = over _1 f . over _2 g newtype State s a = St{unSt :: s -> (s,a)} newtype Counter a = C{unC :: State Int a} instance Functor Counter where fmap f (C (St p)) = C . St $ (cross id f) . p
haskell
getBR :: Monad m => (BRH2 -> Double) -> Pipe (Maybe BRH2) (Maybe Double) (ReaderT InputParam m) () getBR select = do brs0 <- await yield $ case brs0 of Nothing -> Nothing Just brs -> Just (select brs) getBRHpW :: Monad m => Pipe (Maybe BRH2) (Maybe Double) (ReaderT InputParam m) () getBRHpW = getBR _h2HpmW runSushiWithBR :: MonadIO m => Double -> FilePath
haskell
isAnagram :: (String, String) -> Bool isAnagram (str1, str2) = runST $ do ht :: HashTable s Char Int <- H.new mapM_ (flip (H.mutate ht) (f (+1))) str1 mapM_ (flip (H.mutate ht) (f (+(-1)))) str2
haskell
= mapDict toBackend . mapDict (Sub (Impl.inferBackendInstance @t @ds)) $ inferDeriveContext @t @ds @b undefined inferNum :: forall (t :: Type) (ds :: [Nat]) (b :: Type) (i :: Type) . (Num t, Impl.KnownBackend t ds b) => Dict (Num (Backend i t ds b)) inferNum = mapDict toBackend
haskell
let tip = CI.tipFromCardanoBlock block balance = TxUtxoBalance.fromBlock tip txs in case UtxoState.insert balance index of Left err -> error (show err) Right (UtxoState.InsertUtxoSuccess newIndex _insertPosition) -> newIndex step index (RollBackward cardanoPoint _) = let point = CI.fromCardanoPoint cardanoPoint in case TxUtxoBalance.rollback point index of Left err -> error (show err) Right (UtxoState.RollbackResult _newTip rolledBackIndex) -> rolledBackIndex
haskell
let unoffset (Offset i) = i pure $ T.unlines $ ls & _last %~ T.take (fromIntegral $ unoffset $ p_col end) & _head %~ T.drop (fromIntegral $ unoffset $ p_col start) positionToVim :: Pos' Int64 -> (Int64, Int64) positionToVim p = ( fromIntegral $ getVimLineNumber $ p_line p , fromIntegral $ p_col p ) reportError :: Text -> Neovim env ()
haskell
) where import Types.Edge import Util.GenData (GenData(..), SuchThat(..)) import qualified Test.SmallCheck.Series as SS import qualified Test.Tasty.QuickCheck as QC import qualified Data.List.NonEmpty as NE import Data.Graph.Cycle (verifyCycle) import Data.Maybe (isNothing) import qualified Control.Exception as Ex import Data.List (sort, nub)
haskell
instance Bounded InitFlag where minBound = InitJPG maxBound = InitWEBP instance Enum InitFlag Word32 where
haskell
srcSpan (Endfile x sp s) = sp srcSpan (Exit x sp s) = sp srcSpan (Format x sp _) = sp srcSpan (Forall x sp es f) = sp srcSpan (Goto x sp s) = sp srcSpan (Nullify x sp e) = sp srcSpan (Inquire x sp s e) = sp srcSpan (Pause x sp _) = sp
haskell
{-#LANGUAGE QuasiQuotes#-} module Language.Thesaurus.RogetLite.Transcursion where import Language.Thesaurus transcursion :: ThProg transcursion = [thesaurus| # Space ## Transcursion noun: * transcursion transiliency, transgression, tresspass, encroachment, infringement, extravagation, transcendence, redundance
haskell
import qualified Chapter06.Caesar as C run :: IO () run = hspec $ do describe "Chapter06" $ do
haskell
, module Language.C99.Util.IsList , module Language.C99.Util.Expr ) where import Language.C99.Util.Wrap import Language.C99.Util.IsList
haskell
import Control.Monad import Control.Monad.IO.Class () import Control.Monad.Reader import Control.Monad.State import Control.Monad.Writer import Data.Functor.Identity import Control.DeepSeq import qualified Control.Exception (evaluate) import Gauge.Benchmark
haskell
addPrefix _ _ = Prelude.id classNormalizer :: TargetIdNS -> XMLString -> XMLString classNormalizer TargetTypeName = normalizeTypeName classNormalizer TargetConsName = normalizeTypeName -- same normalization as type names, but separate space classNormalizer TargetFieldName = normalizeFieldName -- | Translate XML Schema identifier into Haskell identifier, -- maintaining dictionary to assure uniqueness of Haskell identifier. translate :: IdClass -> XMLString -- input container name -> XMLString -- input name -> CG B.Builder -- TODO special variant of monad which only can write to dictionary, but can't output translate (SchemaGroup, TargetTypeName) container xmlName =
haskell
largestBasinProduct :: Grid -> Int largestBasinProduct grid = product $ take 3 $ reverse $ sort $ map (basinSizeForCoords grid) $ keys $ lowPoints grid main = do input <- parsedInput (2021, 9) lines print $ riskLevelSum $ gridMap input print $ largestBasinProduct $ gridMap input
haskell
01-first_steps -} ---------------------------------------------------------------------------------------------------- --Activate interactive mode in the GHC Haskell compilator. ghci --To change prompt. :set prompt "ghci> " --Simple aritmetic 12+2 14*2 16-2
haskell
module Main where import Hue main :: IO () main = putStrLn "Hello World"
haskell
import Data.Maybe import Distribution.PackageDescription import Distribution.Simple import Distribution.Simple.PreProcess main :: IO () main = defaultMainWithHooks hooks { hookedPreProcessors = hscDropCpp11 $ hookedPreProcessors hooks } where hooks = simpleUserHooks -- gcc shows a warning if -std=c++11 is used when compiling a C file, but -- clang is more strict and considers that an error, so we need to filter it -- out.
haskell
module Day01 where import AOC main = do ns <- parseInput $ eachLine number print $ sum ns print $ firstDuplicate $ scanl (+) (0 :: Integer) $ cycle ns
haskell
roundRes :: Float -> Float roundRes d | dp > 0 = if dp1 - dp > (4 * 10 ^^ (-3)) && dp1 - dp < (5 * 10 ^^ (-3)) then dp + 0.01 else dp | dp < 0 = if dp1 - dp < (-4 * 10 ^^ (-3)) && dp1 - dp > (-5 * 10 ^^ (-3)) then dp - 0.01 else dp
haskell
-- add tasks to the global queue to allow canceling evaluateMany :: [Submission] -> Codex () evaluateMany submissions = do conf <- getSnapletUserConfig taskGroup <- liftIO $
haskell
Var x -> return $ env Map.! x Lam x _ body -> return $ VClosure x body env App a b -> do x <- eval env a y <- eval env b apply x y
haskell
3 return (a + b) baz = do a <- foo let b = a + 2 c = b + 3 bar c let d = c + 2 return d
haskell
-- | -- Pause request; value of command field is "pause". -- The request suspenses the debuggee. -- penDebug will respond with a StoppedEvent (event type 'pause') after a successful 'pause' command. -- data PauseRequest = PauseRequest { seqPauseRequest :: Int -- Sequence number , typePauseRequest :: String -- One of "request", "response", or "event"
haskell
-- import Network.HTTP.Req import Boreal.Anime import Boreal.Auth -- import Boreal.Config import Data.Aeson (Result (..)) import Data.Text (Text)
haskell
distanceF cxs xs = max 0 $ (disctance2 xs cxs) instance Figure Point where distanceF cxs (Point xs) = max 0 $ (disctance2 xs cxs) instance Figure Sphere where distanceF cxs (Sphere xs r _) = max 0 $ (disctance2 xs cxs - r)
haskell
data Value = Num Integer | Fun (Value -> M Value) | Wrong instance Show Value where show (Num x) = show x show (Fun _) = "<function>" show Wrong = "<wrong>"
haskell
uid' = case readMaybe ("0x" <> unpack uid) of Nothing -> Left ("Could not parse uid: " <> unpack uid) Just x -> Right x in case method of Add -> pure . addItem catname it -- @REFACTOR Mod -> \r -> (\u -> modItem it{_uid=u} r) <$> uid' Del -> \r -> flip delItem r <$> uid' runCommand Cat{method,catname,newname,description} = let it = Category {_name=newname,_description=description,_items=[]}