我想知道是否可以返回包含使用类型为Num的变量构造的Double变量的结果。举个例子:
dist :: (Graph g n e, Ord n, Num e) => g -> n -> n -> [Double]
dist graph n1 n2 = loop (nodes graph) where
loop [] = []
loop nodes = [n'] ++ loop (tail nodes) where
n' = if (getDist (head nodes)) == 0) then 1/0 else (getDist (head nodes)) + 1 --1/0 = infinity
我正在考虑一个类似toFractional的函数,总是从if语句
中提供一个double