transformers 0.4: change in accessor function exports?

Michael Snoyman michael at snoyman.com
Wed May 7 13:35:24 UTC 2014


On Wed, May 7, 2014 at 4:31 PM, Henning Thielemann <
schlepptop at henning-thielemann.de> wrote:

> Am 07.05.2014 13:43, schrieb Michael Snoyman:
>
>
>  In the case here, the syntax:
>>
>>      import Control.Monad.Trans.Reader (ReaderT (..))
>>
>> is very convenient. But it's true that you don't really gain much from
>> the distinction between these two:
>>
>>      import Control.Monad.Trans.Reader (ReaderT (ReaderT, runReaderT))
>>      import Control.Monad.Trans.Reader (ReaderT (ReaderT), runReaderT)
>>
>> Perhaps the latter should be considered a better approach, since it's
>> more resilient to changes in datatypes.
>>
>
> However, even if imported in the second way, runReaderT identifier can be
> used in record field update syntax. I guess it would be more consistent to
> allow only the use as a function when imported like an ordinary function.
>
>
If you think *that's* bad, you'll love this:

module Person
    ( Person
    , name
    , age
    , defaultPerson
    ) where

data Person = Person { name :: String, age :: Int}
    deriving Show

defaultPerson = Person "Alice" 25
----
module Main where

import Person

main = print defaultPerson { name = "Bob", age = 30 }
----

(Yes, I've been known to abuse this in my libraries, and in 20/20
hindsight, I wish I hadn't.)

Michael
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/libraries/attachments/20140507/0bbcd142/attachment.html>


More information about the Libraries mailing list