Haskell跟踪函数组合吗? [英] Does haskell keep track of function composition?
问题描述
我想知道Haskell是否跟踪天气函数是一个函数组合,也就是说我可以定义一个类似于这个函数的函数吗?
compositionSplit fg =(f,g)
不,这是不可能的。
例如,
f1 =(+ 1)。 (+ 1):: Int - > Int
与
f2 =减1。 (+ 3):: Int - > Int
和参照透明度要求等于可以代替等于,所以如果 I was wondering if Haskell keeps track of weather a function is a function composition, i.e would it be possible for me to define a function that does something similar to this?:
No, it wouldn't be possible. For example, is the same function as and referential transparency demands that equals can be substituted for equals, so if 这篇关于Haskell跟踪函数组合吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! compositionSplit
是可能的,它会产生相同的结果 f1
f2
,因为它是相同的函数,但是
compositionSplit f1 = ((+ 1),(+1))
和 compositionSplit f2 =(subtract 1,(+ 3))
的 compositionSplit
。
compositionSplit f.g = (f,g)
f1 = (+ 1) . (+ 1) :: Int -> Int
f2 = subtract 1 . (+ 3) :: Int -> Int
compositionSplit
were possible, it would
f1
and f2
, since that is the same function, yetcompositionSplit f1 = ((+ 1), (+1))
and compositionSplit f2 = (subtract 1, (+ 3))
would be required by the specification of compositionSplit
.