News for hackers. Stuff that matters.
Re:Linear types make performance more predictable by Ixiaus on Tuesday March 14, 2017 @09:10PM (#13873040)
It's uncommon to see single-letter datatype names; the general idea being that designing your programs with a data-type orientation should provide the kind of description you're looking for; type variables are very often single letter since they're not very important to understanding (the exception being exceptionally unusual types).

Single letter bindings are not common in production haskell code though there are exceptions where it's very clear using single letter binding names is clear enough and not easily confused, like this for instance:

    -- | Produce @Nothing@ if the first argument is @False@; produce
    -- @Just a@ if the first argument is @True@.
    consMaybe :: Bool -> a -> Maybe a
    consMaybe b v = guard b *> pure v
but usually, most production Haskell (at least where I work and write it) looks like this (minus the top-level function documentation and all the surrounding types and imports, which are important for context):

    makeKey :: FormatTime t
            => t    -- Formattable timestamp, usually obtained with getCurrentTime
            -> Text -- AWS region, e.g: us-east-1
            -> Text -- AWS service, e.g: s3
            -> Text -- AWS signing key protocol, e.g: aws4_request
            -> Text -- AWS secret access key
            -> ScopedSigningKey
    makeKey ctime region service protocol key = ScopedSigningKey scope' sigkey
      where
        dateStamp = formatTime defaultTimeLocale "%Y%m%d" ctime -- YYYYMMDD
        scope'    = Data.Text.intercalate "/" [ pack dateStamp, region, service, protocol ]
    
        sign :: ByteArrayAccess ba => ba -> C8.ByteString -> Digest SHA256
        sign k m  = hmacGetDigest $ hmac k m
    
        kDate     = sign (encodeUtf8 $ "AWS4" <> key) (C8.pack dateStamp)
        kRegion   = sign kDate    (encodeUtf8 region)
        kService  = sign kRegion  (encodeUtf8 service)
        kSigning  = sign kService (encodeUtf8 protocol)
        sigkey    = decodeUtf8 $ convertToBase Base64 kSigning

There are no comments on this comment yet.