From ramin.honary at gmail.com Thu Jan 9 07:46:28 2014 From: ramin.honary at gmail.com (Ramin Honary) Date: Thu, 9 Jan 2014 16:46:28 +0900 Subject: Hiding top level declaration with tilde Message-ID: Hello, I did some Googling, and read a bit through the Haskell 2010 report, Chapter 5 "Modules," and searched through the Haskell-prime Trac tickets and can't really find anything on this. I don't know if it has ever been suggested before, or the reasoning for how export lists work the way they do. So as we all know, when there is no exports list in a module declaration, everything in the top level is exported by default. If you provide an exports list, everything is hidden except what you declare in the exports list. I think a good way to hide things without an exports list might be to simply prefix the type signature with a tilde character. For example: module M where ~type A = () ~newtype B = B () ~data C = MkB1 () | MkB2 () ~abc :: () abc = () increment :: Int -> Int increment = (+1) So in this example, the module M would only export the "increment" function, everything else would be hidden. Right now, this would produce a compile-time error like: Invalid type signature: ~abc :: () I propose making this kind of expression legal and effecting whether or not the symbol is exported. The only disadvantage I can think of is that tilde is generally reserved for making things more lazy, and using tilde in a way that has nothing to do with lazyness, it could make the language a bit more confusing. Otherwise I think it is very practical. -------------- next part -------------- An HTML attachment was scrubbed... URL: From hvr at gnu.org Thu Jan 9 09:30:45 2014 From: hvr at gnu.org (Herbert Valerio Riedel) Date: Thu, 09 Jan 2014 10:30:45 +0100 Subject: Hiding top level declaration with tilde In-Reply-To: (Ramin Honary's message of "Thu, 9 Jan 2014 16:46:28 +0900") References: Message-ID: <87d2k11oze.fsf@gnu.org> On 2014-01-09 at 08:46:28 +0100, Ramin Honary wrote: [...] > So as we all know, when there is no exports list in a module declaration, > everything in the top level is exported by default. > > If you provide an exports list, everything is hidden except what you > declare in the exports list. Btw, that's almost symmetric with an import statement lacking an 'impspec' and one providing a non-"hiding" 'impspec'; Otoh I've been wondering for some time why the export declaration doesn't support the "hiding" modifier, e.g. module M hiding (A, B(..), C(..), abc) where ... to make the export declaration a bit more symmetric with 'impsec' on the import side. > I think a good way to hide things without an exports list might be to > simply prefix the type signature with a tilde character. For example: > > module M where > > ~type A = () > ~newtype B = B () > ~data C = MkB1 () | MkB2 () > > ~abc :: () > abc = () > > increment :: Int -> Int > increment = (+1) > > So in this example, the module M would only export the "increment" > function, everything else would be hidden. So in order to hide a function/value this way, you have to write a type-signature for 'abc', in order to be able to declare 'abc' non-exported? [...] Cheers, hvr From vitea3v at rambler.ru Thu Jan 9 23:05:51 2014 From: vitea3v at rambler.ru (Wvv) Date: Thu, 9 Jan 2014 15:05:51 -0800 (PST) Subject: Hiding top level declaration with tilde In-Reply-To: References: Message-ID: <1389308751070-5741962.post@n5.nabble.com> It was discussed several times. for example: http://haskell.1045720.n5.nabble.com/Proposal-Pragma-EXPORT-tt5736547.html -- View this message in context: http://haskell.1045720.n5.nabble.com/Hiding-top-level-declaration-with-tilde-tp5741909p5741962.html Sent from the Haskell - Haskell-prime mailing list archive at Nabble.com. From hvr at gnu.org Wed Jan 29 11:09:51 2014 From: hvr at gnu.org (Herbert Valerio Riedel) Date: Wed, 29 Jan 2014 12:09:51 +0100 Subject: Over/underflow semantics for 'Int' et al. Message-ID: <87iot3avsw.fsf@gnu.org> Hello *, I'd like to point your attention to https://ghc.haskell.org/trac/ghc/ticket/8695 which brings up the issue what the results operations such as * `div minBound (-1)` * `quot minBound (-1)` * `abs minBound` shall result in for the standard H2010 fixed-width signed types such as `Int`, that is whether ? (arithmetic overflow-exception) or `minBound` is the more appropriate result. Relevant sections from the Haskell 2010 report: (http://www.haskell.org/onlinereport/haskell2010/haskellch6.html#x13-1350006.4) | 6.4. Numbers | | [...] The results of exceptional conditions (such as overflow or | underflow) on the fixed-precision numeric types are undefined; an | implementation may choose error (?, semantically), a truncated value, | or a special value such as infinity, indefinite, etc. ...which seems contradictory to... (http://www.haskell.org/onlinereport/haskell2010/haskellch18.html#x26-22400018.1) | * 18.1. Signed integer types | | This module provides signed integer types of unspecified width (Int) | and fixed widths (Int8, Int16, Int32 and Int64). All arithmetic is | performed modulo 2^n, where n is the number of bits in the type. | [...] Would a Haskell 2010 implementation which turns *every* integer over/underflow (even those for addition or multiplication of 'Int' values whose result would lie outside of [minBound..maxBound]) into a arithmetic exception be a valid H2010 implementation? -- hvr