模板Haskell可以找出在类型类中声明的相关类型同义词的名称和/或声明吗?我曾期望reify会做我想做的事,但似乎并没有提供所有必要的信息。它适用于获取函数类型签名: % ghci GHCi, version 7.8.3: http://www.haskell.org/ghc/ :? for help ... Prelude> -- I'll be inserting line breaks and whitespace for clarity Prelude> -- in all GHCi output. Prelude> :set -XTemplateHaskell Prelude> import Language.Haskell.TH Prelude Language.Haskell.TH> class C a where f :: a -> Int Prelude Language.Haskell.TH> putStrLn $(stringE . …
我在让Chai的expect.to.thrownode.js应用程序进行测试时遇到问题。测试会因抛出的错误而不断失败,但是如果我将测试用例包装在try和catch中并断言所捕获的错误,它将起作用。 难道expect.to.throw不喜欢的工作,我认为它应该还是什么? it('should throw an error if you try to get an undefined property', function (done) { var params = { a: 'test', b: 'test', c: 'test' }; var model = new TestModel(MOCK_REQUEST, params); // neither of these work expect(model.get('z')).to.throw('Property does not exist in model schema.'); expect(model.get('z')).to.throw(new Error('Property does not …