Copyright | © Frank Jung 2022 |
---|---|
License | GPL-3 |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Weekday
Description
A simple demonstration on how to map to and from a bounded, enumerated data type.
In this example we use the weekdays names as our type to iterate across.
makeWeekday
is a simple conversion function to map aWeekday
from a stringfullWeek
returns a list of all abbreviated weekdayscapitalise
returns the title case of a string
The makeWeekday
code is rather weak as any word where the first 3 letters
map to a weekday is valid for conversion.
Other Examples
Using enum:
This example shows how use Weekday
from an enumeration:
>>>
toEnum 0 :: WeekDay
Mon
Documentation
Abbreviated days of the week from Mon (Monday) to Sun (Sunday).
Instances
Arbitrary Weekday Source # | Provide a random instance of a This is for ease of use in property testing.
|
Bounded Weekday Source # | |
Enum Weekday Source # | |
Read Weekday Source # | |
Show Weekday Source # | |
Eq Weekday Source # | |
capitalise :: String -> String Source #
Return title case of string.
>>>
capitalise "monday"
"Monday"
>>>
null (capitalise "")
True