我有一个与Haskell类型系统有关的问题.这不是我第一次遇到类型系统的限制.我将省略我的项目详细信息并使用简化示例.这是一些代码:
-- Works
foo :: (Bounded a, Enum a) => a
foo = minBound
-- "ambiguous" constraint:
-- 'a' has no occurrences in type declaration
bar :: (Bounded a, Enum a) => Int
bar = fromEnum minBound
-- Too much information in return
-- but I can show haskell the appropriate type of 'min'
baz :: (Bounded a, Enum a) => (a, Int)
baz = let min = minBound
in (min, someFunction . fromEnum $ min)
-- Type constraint 'a' …
Run Code Online (Sandbox Code Playgroud)