読者です 読者をやめる 読者になる 読者になる

Bird's tech

23歳エンジニアのアウトプット

haskellでつるかめ算 続き

https://github.com/ygnmhdtt/tsurukame

main = do
  putStrLn "総数:"
  allStr <- getLine  
  putStrLn "脚の数:"  
  legsStr <- getLine  

  -- 型変換  
  let all = stringToInt allStr  
  let legs = stringToInt legsStr

  print ("亀:")
  print (calc all legs)
  print ("鶴:")
  print (calcTsuru all legs)

-- 計算
calc :: Integer -> Integer -> Integer
calc all legs =
  (legs - all * 2) div 2

calcTsuru :: Integer -> Integer -> Integer
calcTsuru all legs =
  all - calc all legs

-- 型変換
stringToInt :: String -> Integer
stringToInt str = 
  read str :: Integer

エラー ↓

Couldn't match expected type ‘(Integer -> Integer -> Integer)
                                    -> Integer -> Integer’
                  with actual type ‘Integer’
    • The function ‘le - al * 2’ is applied to two arguments,
      but its type ‘Integer’ has none
      In the expression: (le - al * 2) div 2
      In an equation for ‘calc’: calc al le = (le - al * 2) div 2

calc関数の型宣言がおかしい?