我在寻找一种方法来获取前奏Haskell的所有内建命名空间。如何在Haskell中知道builtins函数?
东西相当于什么,我们可以在Python中有这样::
>>> print([func for func in dir(__builtins__) if func[0].islower()])
['abs', 'all', 'any', 'ascii', 'bin', 'bool', 'bytearray', 'bytes', 'callable', 'chr', 'classmethod', 'compile', 'complex', 'copyright', 'credits', 'delattr',
'dict', 'dir', 'divmod', 'enumerate', 'eval', 'exec', 'exit', 'filter', 'float', 'format', 'frozenset', 'getattr', 'globals', 'hasattr', 'hash', 'help', 'hex', 'id', 'input', 'int', 'isinstance', 'issubclass', 'iter', 'len',
'license', 'list', 'locals', 'map', 'max', 'memoryview', 'min', 'next', 'object', 'oct', 'open', 'ord', 'pow', 'print', 'property', 'quit', 'range', 'repr', 'reversed', 'round', 'set', 'setattr', 'slice', 'sorted', 'staticmethod',
'str', 'sum', 'super', 'tuple', 'type', 'vars', 'zip']
>>> print(len.__doc__)
Return the number of items in a container.
>>>
这不是一个关于“如何从库中的内容信息”像他们谈论这里的问题:Is there a way to see the list of functions in a module, in GHCI?
这是关于内建的,所以关于你没有导入任何libray的语言。
我需要获取专业program.hs
中的功能列表,不在Prelude帮助系统或Prelude完成系统中。
[有没有办法在GHCI中看到模块中的函数列表?](https://stackoverflow.com/questions/1698942/is-there-a-way-to参见ghci模块中的函数列表) –
那么,你可以将GHCI中的列表粘贴到一个巨大的字符串中,并将它存储在'.hs'文件中。 *为什么*你需要这样的清单?你想用它做什么? – rampion
定义“内建”的含义。 Haskell并没有真正的“内建”。你是说,空模块或REPL中的可用定义?这只是[Prelude'模块](http://hackage.haskell.org/package/base-4.10.0.0/docs/Prelude.html),但没有任何内容是真正特别的语言 - 这只是导入的内容除非你说''import prelude()'来防止这种情况。 ... – leftaroundabout