Haskelle Newbee不知道如何解决这个问题

时间:2018-01-22 17:03:11

标签: haskell

此代码:

foreign export ccall rvcb_create_context :: Ptr Spec -> CInt -> CInt -> CInt -> CInt -> CInt -> IO (Ptr Context)
rvcb_create_context specPtr id direction alignment size step = do
  spec <- deRefStablePtr $ castPtrToStablePtr $ castPtr specPtr

  let wsize = fi size
      wstep = fi step
      alignment'
        | alignment == raava_start = AlignStart
        | alignment == raava_end   = AlignEnd
      direction'
        | direction == raava_tostart = ToStart
        | direction == raava_toend   = ToEnd
      window
        | id == raava_single    = Single
        | id == raava_rolling   = Rolling alignment' wsize wstep
        | id == raava_expanding = Expanding direction' wsize wstep
        | otherwise            =
          error (printf "impossible id %s" (show id))

生成此错误,即使我对其

有什么含糊的概念,我也不知道如何修复
121:35: error:
    • Couldn't match expected type ‘Window’
                  with actual type ‘WinStep -> Window’
    • Probable cause: ‘Expanding’ is applied to too few arguments
      In the expression: Expanding direction' wsize wstep
      In an equation for ‘window'’:
          window'
            | id == raava_single = Single
            | id == raava_rolling = Rolling alignment' wsize wstep
            | id == raava_expanding = Expanding direction' wsize wstep
            | otherwise = error (printf "impossible id %s" (show id))
      In the expression:
        do spec <- deRefStablePtr $ castPtrToStablePtr $ castPtr specPtr
           let wsize = fi size
               wstep = fi step
               ....
           let context = genContext spec window
           contextPtr <- newStablePtr context
           ....
    |
121 |         | id == raava_expanding = Expanding direction' wsize wstep

1 个答案:

答案 0 :(得分:1)

你的问题在这里:

    | id == raava_expanding = Expanding direction' wsize wstep

编译器说你错过了ExpandingWinStep的另一个参数。如果您不放置该参数,则返回类型为WinStep -> Window的函数,而不是预期类型Window