Talk:Haskell/Modules

encapsulation
there should be something on how not exporting a constructor can hide information. if no expert takes on the job within the next few days, I am happy to do it.
 * Agree; I will add something along these lines later. Duplode (discuss • contribs) 05:17, 29 September 2013 (UTC)

Needs some clarification
I'm learning from this wikibook, so I can't make the changes myself.. there ought to be a real example of a module definition, not just the syntax. I'm not quite clear on how 'where' works (at first I thought it was a syntactical marker) after reading this. --207.14.29.3 23:22, 19 July 2007 (UTC)
 * I agree. there should be one toy module completely defined. I'm doing it.
 * Arguably solved in an indirect way by making Haskell/Standalone programs the very next module. Duplode (discuss • contribs) 05:18, 29 September 2013 (UTC)

How to express Main.(++++)?
I define a infix function (++++) in module Main.


 * Sorry, could you elaborate on your question? If you want to import/export infix functions, you have to wrap them around parentheses, like  .  Were you talking about that?  -- Kowey 07:05, 2 August 2007 (UTC)

for example: module Main where (+)::[a]-&gt;[a]-&gt;[a] a + b = a++b main = do   print ([1] + [2]) return It says "Ambiguous",because + is also define in Prelude.

How to explicitly point it's Main.+?

 Infix operators can be qualified Hugs> 1 Prelude.+ 2 3 Hugs> (Prelude.+) 1 2 3 Note that you may have to hide the original  and import the Prelude qualified in order to redefine   in terms of the old one: module Main( (+) ) where

import Prelude hiding ( (+) ) import Prelude qualified

(+) :: Num a => [a]-&gt;[a]-&gt;[a] a + b = zipWith (Prelude.+) a b -- apfe&lambda;mus 09:42, 3 August 2007 (UTC) 

The $ operator
Some examples in this section use the $ operator, which has not been introduced yet. It is a bit confusing, and I still don't quite get what it does. Could someone add little more detail on that, please?


 * The $ operator is just ordinary function application . It has very low precedence, however, which is very useful to saving parentheses. Example:

length (map (^2) [1..10]) = length $ map (^2) [1..10] = length $ map (^2) $ [1..10]


 * --apfe&lambda;mus 07:25, 28 March 2011 (UTC)


 * To add to that, it can also be useful in other situations where it can remove a lambda expression: . We should include information on this operator before this module outside of the talk page, though. --Digichoron (discuss • contribs) 01:05, 6 April 2011 (UTC)

Qualified imports
I've read over this section several times and can not determine what the difference is between a 'qualified import' and a simple 'import'? VernonF (discuss • contribs) 19:37, 26 September 2021 (UTC)