1
renderYaml :: forall a p e. 
  Yaml -> Registry p a (err :: Exception | e) -> Eff (err :: Exception | e) Unit
renderYaml yaml r = let 

    yamlToForeign  :: Yaml -> Either String Foreign
    yamlToForeign  = runFn3 parseYaml Left Right

    -- Without the explicit type here, psc throws:
    -- Error in declaration renderYaml
    -- Error in expression Presentable.ViewParser.parse(v):
    -- Duplicate label "err" in row.
    grrinference   :: forall e. Foreign -> Eff (err :: Exception | e) Unit
    -- with the explicit type, psc throws:
    -- Error in declaration renderYaml
    -- Cannot unify ( | e10478) with ( | e10503)
    grrinference v = parse v r >>= render

  in case yamlToForeign yaml of
    Right v  -> grrinference v
    Left err -> throw $ "Yaml view failed to parse : " ++ err

我已经扭曲了我的大脑,但我不明白如何在这里统一类型。PureScript 的早期版本一切正常。但是在 0.6 中我被卡住了。

--

解析的详细信息

parse :: forall a p e. Foreign -> Registry a p e-> Eff (err :: Exception | e) [Presentable a p e]

更多类型信息

type Yaml              = String
type Registry a p e    = M.Map String (Linker a p e)
type Attributes a      = Maybe { | a}
type Parent p          = Maybe { | p}
type Linker a p e      = Parent p -> Attributes a -> Eff e (Parent p)

data Presentable a p e = Presentable (Linker a p e) (Attributes a) (Maybe [Presentable a p e])
4

0 回答 0