I look for something equivalent to what we can have in Python doing this::
>>> 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.
>>>
This is not a question about "how to get info from a library's contents" like they talk here: Is there a way to see the list of functions in a module, in GHCI?
It's about how to have create a list with all the functions names (so strings) provided by Prelude
before any additional import.
I can see this exact list using completion after Prelude.
Prelude> Prelude.
Display all 256 possibilities? (y or n)
Prelude.!! Prelude.RealFrac Prelude.fromEnum Prelude.readLn
Prelude.$ Prelude.Right Prelude.fromInteger Prelude.readParen
Prelude.$! Prelude.Semigroup Prelude.fromIntegral Prelude.reads
Prelude.&& Prelude.Show Prelude.fromRational Prelude.readsPrec
Prelude.* Prelude.ShowS Prelude.fst Prelude.realToFrac
Prelude.** Prelude.String Prelude.gcd Prelude.recip
Prelude.*> Prelude.Traversable Prelude.getChar Prelude.rem
Prelude.+ Prelude.True Prelude.getContents Prelude.repeat
Prelude.++ Prelude.Word Prelude.getLine Prelude.replicate
Prelude.- Prelude.^ Prelude.head Prelude.return
Prelude.. Prelude.^^ Prelude.id Prelude.reverse
Prelude./ Prelude.abs Prelude.init Prelude.round
Prelude./= Prelude.acos Prelude.interact Prelude.scaleFloat
Prelude.< Prelude.acosh Prelude.ioError Prelude.scanl
Prelude.<$ Prelude.all Prelude.isDenormalized Prelude.scanl1
Prelude.<$> Prelude.and Prelude.isIEEE Prelude.scanr
Prelude.<* Prelude.any Prelude.isInfinite Prelude.scanr1
Prelude.<*> Prelude.appendFile Prelude.isNaN Prelude.seq
Prelude.<= Prelude.asTypeOf Prelude.isNegativeZero Prelude.sequence
Prelude.<> Prelude.asin Prelude.iterate Prelude.sequenceA
Prelude.=<< Prelude.asinh Prelude.last Prelude.sequence_
Prelude.== Prelude.atan Prelude.lcm Prelude.show
Prelude.> Prelude.atan2 Prelude.length Prelude.showChar
Prelude.>= Prelude.atanh Prelude.lex Prelude.showList
Prelude.>> Prelude.break Prelude.lines Prelude.showParen
Prelude.>>= Prelude.ceiling Prelude.log Prelude.showString
Prelude.Applicative Prelude.compare Prelude.logBase Prelude.shows
Prelude.Bool Prelude.concat Prelude.lookup Prelude.showsPrec
Prelude.Bounded Prelude.concatMap Prelude.map Prelude.significand
Prelude.Char Prelude.const Prelude.mapM Prelude.signum
Prelude.Double Prelude.cos Prelude.mapM_ Prelude.sin
Prelude.EQ Prelude.cosh Prelude.mappend Prelude.sinh
Prelude.Either Prelude.curry Prelude.max Prelude.snd
Prelude.Enum Prelude.cycle Prelude.maxBound Prelude.span
Prelude.Eq Prelude.decodeFloat Prelude.maximum Prelude.splitAt
Prelude.False Prelude.div Prelude.maybe Prelude.sqrt
Prelude.FilePath Prelude.divMod Prelude.mconcat Prelude.subtract
Prelude.Float Prelude.drop Prelude.mempty Prelude.succ
Prelude.Floating Prelude.dropWhile Prelude.min Prelude.sum
Prelude.Foldable Prelude.either Prelude.minBound Prelude.tail
Prelude.Fractional Prelude.elem Prelude.minimum Prelude.take
Prelude.Functor Prelude.encodeFloat Prelude.mod Prelude.takeWhile
Prelude.GT Prelude.enumFrom Prelude.negate Prelude.tan
Prelude.IO Prelude.enumFromThen Prelude.not Prelude.tanh
Prelude.IOError Prelude.enumFromThenTo Prelude.notElem Prelude.toEnum
Prelude.Int Prelude.enumFromTo Prelude.null Prelude.toInteger
Prelude.Integer Prelude.error Prelude.odd Prelude.toRational
Prelude.Integral Prelude.errorWithoutStackTrace Prelude.or Prelude.traverse
Prelude.Just Prelude.even Prelude.otherwise Prelude.truncate
Prelude.LT Prelude.exp Prelude.pi Prelude.uncurry
Prelude.Left Prelude.exponent Prelude.pred Prelude.undefined
Prelude.Maybe Prelude.fail Prelude.print Prelude.unlines
Prelude.Monad Prelude.filter Prelude.product Prelude.until
Prelude.MonadFail Prelude.flip Prelude.properFraction Prelude.unwords
Prelude.Monoid Prelude.floatDigits Prelude.pure Prelude.unzip
Prelude.Nothing Prelude.floatRadix Prelude.putChar Prelude.unzip3
Prelude.Num Prelude.floatRange Prelude.putStr Prelude.userError
Prelude.Ord Prelude.floor Prelude.putStrLn Prelude.words
Prelude.Ordering Prelude.fmap Prelude.quot Prelude.writeFile
Prelude.Rational Prelude.foldMap Prelude.quotRem Prelude.zip
Prelude.Read Prelude.foldl Prelude.read Prelude.zip3
Prelude.ReadS Prelude.foldl1 Prelude.readFile Prelude.zipWith
Prelude.Real Prelude.foldr Prelude.readIO Prelude.zipWith3
Prelude.RealFloat Prelude.foldr1 Prelude.readList Prelude.||
Prelude> Prelude.
So right now I do this manualy with copy past & cleaning on vim and then copying this list back on Prelude like this:
Prelude> all_prelude_functions = ["acos", "acosh", "all", "and", "any", "appendFile", "asTypeOf", "asin", "asinh", "atan", "atan2", "atanh", "break", "ceiling", "compare", "concat", "concatMap"]
Prelude> all_prelude_functions
["acos","acosh","all","and","any","appendFile","asTypeOf","asin","asinh","atan","atan2","atanh","break","ceiling","compare","concat","concatMap"]
Prelude>
I would like to create this list directly inside Prelude
.hs
file. Why do you need such a list? What do you want to do with it? – GinnyginoPrelude
module, but nothing in there is really special language-wise – it's just what's imported unless you sayimport Prelude ()
to prevent that. ... – JohnGHC.Prim
, but in there are only very awkward to use low-level operations. It isn't supposed to be used in normal Haskell at all, and in fact isn't related to what the Haskell standard defines. – John