小编Geo*_* Co的帖子

Haskell 类型推断导致错误消息指向错误的变量

在ghci中加载以下代码

\n
{-# OPTIONS_GHC -Wall   #-}\n\n\n--following gives a type error about the arg int not str\nbug ::  String -> Int -> Int \nbug str int =  num \n  where num =  str * 10  +  int \n\n-- the following gives a type error about the arg str as expected \nworks ::  String -> Int -> Int \nworks str int = str * 10  +  int\n
Run Code Online (Sandbox Code Playgroud)\n

这给出了以下错误:

\n
:reload\n[1 of 1] Compiling Main             ( bugTI.hs, interpreted )\n\nbugTI.hs:6:16: error:\n    \xe2\x80\xa2 Couldn't …
Run Code Online (Sandbox Code Playgroud)

haskell

2
推荐指数
1
解决办法
258
查看次数

标签 统计

haskell ×1