Skip to content
This repository was archived by the owner on Oct 7, 2020. It is now read-only.
This repository was archived by the owner on Oct 7, 2020. It is now read-only.

Use GHCi :doc instead of Hoogle #849

Open
@zeronone

Description

@zeronone

AFAIK, Hoogle's JSON output is not complete and translating the html to markdown is not perfect. How about using GHCi's new :doc feature. Here is an example:

λ> :doc foldl
 Left-associative fold of a structure.

 In the case of lists, 'foldl', when applied to a binary
 operator, a starting value (typically the left-identity of the operator),
 and a list, reduces the list using the binary operator, from left to
 right:

 > foldl f z [x1, x2, ..., xn] == (...((z `f` x1) `f` x2) `f`...) `f` xn

 Note that to produce the outermost application of the operator the
 entire input list must be traversed. This means that 'foldl'' will
 diverge if given an infinite list.

 Also note that if you want an efficient left-fold, you probably want to
 use 'foldl'' instead of 'foldl'. The reason for this is that latter does
 not force the "inner" results (e.g. @z `f` x1@ in the above example)
 before applying them to the operator (e.g. to @(`f` x2)@). This results
 in a thunk chain @O(n)@ elements long, which then must be evaluated from
 the outside-in.

 For a general 'Foldable' structure this should be semantically identical
 to,

 @foldl f z = 'List.foldl' f z . 'toList'@

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions