Reactjs 铝热剂中电子的Node.js效应

Reactjs 铝热剂中电子的Node.js效应,reactjs,electron,purescript,Reactjs,Electron,Purescript,我正在尝试展开以添加目录的输入,我将显示其文件名 但是,我无法使用以下函数进行类型检查。最后两行有问题,最后一行是第53行: performAction :: T.PerformAction _ State _ Action performAction (SetEditText s) _ _ = void do T.cotransform $ _ { dir = s } performAction (UpdateFiles s) _ _ = void

我正在尝试展开以添加目录的输入,我将显示其文件名

但是,我无法使用以下函数进行类型检查。最后两行有问题,最后一行是第53行:

performAction :: T.PerformAction _ State _ Action
performAction (SetEditText s)           _ _ = void do
  T.cotransform $ _ { dir = s }
performAction (UpdateFiles s)           _ _ = void do
   filenames <- either (const []) id <$> try (readdir s)
   T.cotransform $ _ { names = filenames }
表演是一种类型

forall t39 t40. Action -> t40 -> {dir :: String, names :: Array String} -> FreeT (CoTransform (Maybe {dir :: String, names :: Array String}) ({dir :: String, names :: Array String} -> {dir :: String, names :: Array String}))
实际误差为

Could not match type at line 53 col 4

FreeT
  (CoTransform t2
     ({ files :: t3
      | t4
      }
      -> { files :: Array String
         | t4
         }
     )
  )
with type
Eff
while trying to match type FreeT
                         (CoTransform t2
                            ({ files :: t3
                             | t4
                             }
                             -> { files :: Array String
                                | t4
                                }
                            )
                         )
                         t5
with type Eff
          ( fs :: FS
          | t0
          )
while checking that expression (apply cotransform) (\$1 ->
                                                  $1 { files = f
                                                     }
                                               )
has type Eff
         ( fs :: FS
         | t0
         )
         t1
in value declaration performAction
where t1 is an unknown type
  t0 is an unknown type
  t2 is an unknown type
  t5 is an unknown type
  t4 is an unknown type
  t3 is an unknown type
整个项目可以在下面找到

我怀疑我必须使用lift/liftEff/liftEff'/liftAff中的任何一种。但是,

performAction :: T.PerformAction _ State _ Action
performAction (UpdateFiles s)           _ _ = void do
   filenames <-  ( lift (either (const []) id <$> try (readdir s)))
   T.cotransform $ _ { names = filenames }

您可以使用以下工具使其工作:

performAction :: forall e. T.PerformAction (fs :: FS | e) State _ Action
performAction (SetEditText s)           _ _ = void do
  T.cotransform $ _ { dir = s }
performAction (UpdateFiles s)           _ _ = void do
   filenames <- lift (liftEff (either (const []) id <$> try (readdir s)))
   T.cotransform $ _ { names = filenames }
  -- T.cotransform $ _ { dir = ""}

liftEff将您的Eff带到Aff,然后将其提升到自由空间。。。那个铝热剂用的。额外的提升应该是不必要的,但我认为这里的问题是围绕行和类型类的类型推断,在下一个版本中,情况应该会更好,我们很可能会有函数依赖关系。

您可以使用:

performAction :: forall e. T.PerformAction (fs :: FS | e) State _ Action
performAction (SetEditText s)           _ _ = void do
  T.cotransform $ _ { dir = s }
performAction (UpdateFiles s)           _ _ = void do
   filenames <- lift (liftEff (either (const []) id <$> try (readdir s)))
   T.cotransform $ _ { names = filenames }
  -- T.cotransform $ _ { dir = ""}

liftEff将您的Eff带到Aff,然后将其提升到自由空间。。。那个铝热剂用的。额外的提升应该是不必要的,但我认为这里的问题是围绕行和类型类的类型推断,在下一个版本中,情况应该会更好,我们很可能会有函数依赖关系。

太棒了!如果我遇到你,我就得给你买瓶啤酒。太棒了!如果我遇到你,我就得请你喝杯啤酒。
performAction :: forall e. T.PerformAction (fs :: FS | e) State _ Action
performAction (SetEditText s)           _ _ = void do
  T.cotransform $ _ { dir = s }
performAction (UpdateFiles s)           _ _ = void do
   filenames <- lift (liftEff (either (const []) id <$> try (readdir s)))
   T.cotransform $ _ { names = filenames }
  -- T.cotransform $ _ { dir = ""}