emacs是否可以从Amazon S3存储桶加载缓冲区?如果是这样,有人已经建立了可以做到这一点的东西?
为什么我不能在这里推出Show?
{-# LANGUAGE ExistentialQuantification #-}
data Obj = forall a. (Show a) => Item_Obj {get :: a, rest :: Obj} | No_Obj deriving Show
xs :: Obj
xs = Item_Obj 1 $ Item_Obj "foo" $ Item_Obj 'c' $ No_Obj
main :: IO ()
main = putStrLn . show $ xs
Run Code Online (Sandbox Code Playgroud) 为什么我不能从A访问'x'属性?
A = {}; B = {y: 'y'}; C = {x: 'x'}; A.prototype = B; B.prototype = C; A.x
Run Code Online (Sandbox Code Playgroud) 此代码将正确编译:
import Text.Printf
import Test.HUnit
doubleMe x = x + x
doubleUs x y = doubleMe x + doubleMe y
doubleSmallNumber x = if x > 100 then x else x*2
doubleSmallNumber' x = if x > 100 then x else x*2 + 1
conanO'Brien = "It's a-me, Conan O'Brien!"
main = do
runTestTT $ TestList [TestCase $ ae 4 $ doubleMe 2,
TestCase $ ae 10 $ doubleUs 2 3,
TestCase $ ae 4 $ doubleSmallNumber 2,
TestCase $ …Run Code Online (Sandbox Code Playgroud) 为什么countInFile1和countInFile3有编译器错误,当countInFile0和countInFile2没有时.这四个都是一回事.
count :: String -> String -> Int
count w = length . filter (==w) . words
present :: String -> String -> IO String
present w = return . show . count w
-- VALID: pointed readFile, regular present
countInFile0 :: String -> FilePath -> IO ()
countInFile0 w f = putStrLn =<< present w =<< readFile f
-- INVALID: pointless readFile, regular present
countInFile1 :: String -> FilePath -> IO ()
countInFile1 w = putStrLn =<< present w …Run Code Online (Sandbox Code Playgroud) 我正在尝试将i以下类的类型注释移至 SAKS:
class Demote t (i :: t -> Type) where
demote :: forall (t' :: t) . i t' -> t
Run Code Online (Sandbox Code Playgroud)
以下尝试均无效:
-- fails because k and t will not unify?
type Demote :: Type -> (k -> Type) -> Constraint
class Demote t i where
demote :: forall (t' :: t) . i t' -> t
-- fails because the SAKS and class head do not share the same namespace?
type Demote :: (k ~ t) …Run Code Online (Sandbox Code Playgroud) 我无法理解类型应用程序的工作原理.如果sing在refuteRefuteKnockable没有类型应用程序的情况下调用singin knockableOrOpened将无法键入check,为什么可以在没有类型应用程序的情况下使用?
refuteRefuteKnockable :: SingI s => Refuted (Refuted (Knockable s)) -> Knockable s
refuteRefuteKnockable rrK =
case isKnockable $ sing of
Proved k -> k
Disproved rK -> absurd $ rrK rK
knockableOrOpened :: forall s. SingI s => Or Knockable ((:~:) Opened) s
knockableOrOpened =
case sing @s of
SOpened -> OrRight $ Refl
SClosed -> OrLeft KnockClosed
SLocked -> OrLeft KnockLocked
Run Code Online (Sandbox Code Playgroud)
我正在使用以下代码库:https://github.com/mstksg/inCode/blob/master/code-samples/singletons/Door3.hs
我可以得到一个where子句来跨模式匹配一个case语句:
updateHung :: Text -> Maybe Char -> Int
updateHung word got =
let x = case got of
Just l
| elem l . unpack $ word -> pass
| otherwise -> strike
Nothing -> pass
where
strike = 1
pass = 0
in x
Run Code Online (Sandbox Code Playgroud)
但是当我尝试使用 multipart 函数做同样的事情时,它不起作用:
updateHung :: Text -> Maybe Char -> Int
updateHung word (Just l)
| elem l . unpack $ word = pass
| otherwise = strike
updateHung word …Run Code Online (Sandbox Code Playgroud) 以下import语句与foldr等发生冲突.因为第一个import语句似乎将Data.Foldable中的所有函数导入到我的模块中:
import Data.Foldable (Foldable (..))
import qualified Data.Foldable as Foldable (foldr, foldl, foldr1, foldl1, foldMap)
Run Code Online (Sandbox Code Playgroud)
这个import语句似乎有效.然而,可折叠类现在可折叠.可折叠:
import qualified Data.Foldable as Foldable (Foldable (..), foldr, foldl, foldr1, foldl1, foldMap)
Run Code Online (Sandbox Code Playgroud) 在下面的程序test?中将不会编译但test?会.原因似乎是因为forall s.in withModulus?.似乎s每个呼叫都是不同的类型,withModulus?因为forall s..为什么会这样?
{-# LANGUAGE
GADTs
, KindSignatures
, RankNTypes
, TupleSections
, ViewPatterns #-}
module Main where
import Data.Reflection
newtype Modulus :: * -> * -> * where
Modulus :: a -> Modulus s a
deriving (Eq, Show)
newtype M :: * -> * -> * where
M :: a -> M s a
deriving (Eq, Show)
add :: Integral a => Modulus s a …Run Code Online (Sandbox Code Playgroud)