Going through the source code for the prelude brings up weirdness

后端 未结 2 1626
暗喜
暗喜 2021-02-19 05:52

I was looking for the definition of seq and came across this weirdness. Why do all these functions have the same/similar definitions?

seq :: a ->         


        
2条回答
  •  天命终不由人
    2021-02-19 06:31

    What's going on is that these functions cannot be implemented in Haskell, but they should appear in the docs. Since haddock needs a syntactically correct (and well-typed) definition for each signature, the source must contain dummy definitions. Further, at the point where they are defined (in the ghc-prim package), error (and hence undefined) are not yet available, so the more obvious seq = error "Not implementable in Haskell" can't be used, thus the circular definition.

提交回复
热议问题