在项目pandoc中,Paths_pandoc在Shared.hs中导入.Paths_pandoc.hs位于dist/build/autogen /中.它是如何生成的以及它对pandoc的作用.
我使用的是带有语言环境zh_CN和ghc-7.0.4的Windows 7
cmd.exe的默认代码页是936.
> cabal install ghc-mod
Resolving dependencies...
Configuring ghc-syb-utils-0.2.1.0...
Preprocessing library ghc-syb-utils-0.2.1.0...
Building ghc-syb-utils-0.2.1.0...
<built-in>:0:4: lexical error (UTF-8 decoding error)
cabal: Error: some packages failed to install:
ghc-mod-1.10.7 depends on ghc-syb-utils-0.2.1.0 which failed to install.
ghc-syb-utils-0.2.1.0 failed during the building phase. The exception was:
ExitFailure 1
Run Code Online (Sandbox Code Playgroud)
我已尝试更改代码页并重新安装,但获得相同的输出.
> chcp 65001
> cabal install ghc-mod
Run Code Online (Sandbox Code Playgroud)
一些包可以成功构建:
xml-1.3.12 textmath-0.6.0.3 tagsoup-0.12.6
有些包会失败:
temporary-1.1.2.3 utf8-string-0.3.7 pandoc-types-1.9.0.2 json-0.5
这是一种表示现实世界物理单位的数据类型:
import qualified Prelude as P
import Prelude hiding ((+), (*), (/), (-), Int, pi)
data Int = Zero | Succ Int | Pred Int
data Unit :: Int -> Int -> Int -> * where
U :: Double -> Unit m s kg
(+) :: Unit m s kg -> Unit m s kg -> Unit m s kg
(-) :: Unit m s kg -> Unit m s kg -> Unit m s kg
(*) :: Unit m1 …Run Code Online (Sandbox Code Playgroud) 在map之后和reduce之前,有一个排序阶段.在流模式下,hadoop如何知道您的密钥类型是什么,并对其进行排序.
例如
输入文件格式
1990 1
1991 4
1992 5
...
Run Code Online (Sandbox Code Playgroud)
地图的结果有钥匙1990,1991,1992 ......,怎么用hadoop排序呢?(数字排序或字母排序)
import Text.JSON
import Control.Monad
data Status = Status { user :: String, text :: String } deriving Show
makeStatus :: JSObject JSValue -> Result Status
makeStatus tweet = let (!) = flip valFromObj in do
userObject <- tweet ! "user"
user <- userObject ! "screen_name"
text <- tweet ! "text"
return Status {user = user, text = text}
Run Code Online (Sandbox Code Playgroud)
[1 of 1] Compiling Main ( twitter.hs, interpreted )
twitter.hs:11:27:
Couldn't match expected type `[Char]'
with actual type `JSObject JSValue'
Expected type: …Run Code Online (Sandbox Code Playgroud) 我尝试在GHCi中运行来自http://gregorycollins.net/posts/2011/10/01/cufp2011/index.html#(43)的代码,但得到了"浮点异常,GHCi退出.
{-# LANGUAGE OverloadedStrings #-}
import Control.Applicative
import Data.Aeson
import Data.Attoparsec (parseOnly)
import Data.ByteString.Char8 (ByteString)
import qualified Data.ByteString.Char8 as S
import qualified Data.ByteString.Lazy.Char8 as L
------------------------------------------------------------------------------
example1 :: ByteString -> Either String Coord
example1 bs = parseOnly json bs >>= convert
where
convert value = case fromJSON value of
(Error e) -> Left e
(Success a) -> Right a
example2 :: Coord -> ByteString
example2 c = S.concat $ L.toChunks $ encode c
------------------------------------------------------------------------------
data Coord = Coord …Run Code Online (Sandbox Code Playgroud)