Copyright | © Frank Jung 2023-2024 |
---|---|
License | GPL-3.0-only |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Greeting
Description
Synopsis
- newtype Name = Name {}
- newtype Salutation = Salutation {}
- data GreetingMessage = GreetingMessage {}
- class Redacted a where
- newtype Common = Common String
- newtype Secret = Secret String
- newtype UserName = UserName String
- newtype AdminUser = AdminUser UserName
- defaultMessage :: GreetingMessage
- formatMessage :: GreetingMessage -> String
Types
Name type.
newtype Salutation Source #
Salutation type.
Constructors
Salutation | |
Fields |
Instances
Show Salutation Source # | |
Defined in Greeting Methods showsPrec :: Int -> Salutation -> ShowS # show :: Salutation -> String # showList :: [Salutation] -> ShowS # | |
Eq Salutation Source # | |
Defined in Greeting |
data GreetingMessage Source #
Greeting message type. It consists of a salutation, a name to greet, and a list of names from whom the greeting is from.
Constructors
GreetingMessage | |
Fields
|
Instances
Show GreetingMessage Source # | |
Defined in Greeting Methods showsPrec :: Int -> GreetingMessage -> ShowS # show :: GreetingMessage -> String # showList :: [GreetingMessage] -> ShowS # | |
Eq GreetingMessage Source # | |
Defined in Greeting Methods (==) :: GreetingMessage -> GreetingMessage -> Bool # (/=) :: GreetingMessage -> GreetingMessage -> Bool # |
class Redacted a where Source #
Redacted type class.
Minimal complete definition
Nothing
Common type.
Instances
Redacted Common Source # | Common type instance of Redacted. This will echo the string as is. |
Show Common Source # | Override Show instance to echo result with out type signature. A better way is to use GeneralizedNewtypeDeriving extension to derive the Show instance. This Show instance does not show the type. |
Secret type.
Simpler way to implement Redacted instance for Secret
.
Needs the DeriveAnyClass
extension.
Overrides Show instance to give a customised value.
AdminUer type. Will override Redacted instance to give a customised value.
Functions
defaultMessage :: GreetingMessage Source #
Default greeting message.
defaultMessage
{greetingSalutation
::Salutation
"Hello" ,greetingTo
:: Name "World" ,greetingFrom
:: []} }
formatMessage :: GreetingMessage -> String Source #
Format greeting message.
>>>
formatMessage defaultMessage
"Hello, World!"
>>>
formatMessage (defaultMessage {greetingTo = Name "Robyn", greetingFrom = [Name "Frank"]})
"Hello, Robyn! from Frank"