I have found the definition for and, on the internet but I couldnt find the actual implementation of and. I did search for some sort of prelude haskell file on my computer but it didn’t return anything which could be opened in a text editor.
Share
You can use Hoogle to search for Haskell functions, like so:
http://www.haskell.org/hoogle/?hoogle=and
The function links take you to the library module where the function was defined, and in this case the link for
andtakes us to here:http://hackage.haskell.org/packages/archive/base/latest/doc/html/Prelude.html#v:and
You then click on the
Sourcelink to the right of the function name and it takes you to the source of that function. For the case ofandit links us to here:http://hackage.haskell.org/packages/archive/base/latest/doc/html/src/GHC-List.html#and
You’ll see that
andactually has two definitions. One is the Standard Prelude definition, which is only enabled if you compile with theUSE_REPORT_PRELUDEflag, and the other is the definition the Prelude is usually compiled with, which is typically more optimized.