| 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.
makeWeekdayis a simple conversion function to map aWeekdayfrom a stringfullWeekreturns a list of all abbreviated weekdayscapitalisereturns 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 :: WeekDayMon
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