如何在Haskell中读取内置函数的实现代码/源代码? [英] How to read the implementation code/source code for inbuilt functions in Haskell?
本文介绍了如何在Haskell中读取内置函数的实现代码/源代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
例如,如果我想阅读Prelude中默认的 curry
函数的源代码,该在哪里引用?有没有办法阅读它的实现?我试图在Hoogle中搜索它,但是它没有给出确切的实现,只是输入和输出类型.我在堆栈上使用GHCI来运行haskell.-
接着,您将进入
-|"curry"将未咖喱函数转换为咖喱函数.咖喱::(((a,b)-> c)->a->b->C咖喱f x y = f(x,y)
For instance if I would like to read the source code for the default curry
function in Prelude, where do I refer? Is there a way to read it's implementation? I tried to search it in Hoogle, but it doesn't give the exact implementation, just the input and output types. I am using GHCI on stack to run haskell.-
解决方案
Like @Lee mentioned in the comments, there is a link for source for many of the functions on hackage.
Following this will take you to the source code for curry
:
-- | 'curry' converts an uncurried function to a curried function.
curry :: ((a, b) -> c) -> a -> b -> c
curry f x y = f (x, y)
这篇关于如何在Haskell中读取内置函数的实现代码/源代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文