Chadtech / elm-us-state-abbreviations / UsStates

Here are the abbreviations for every US State, as a union type, and two functions to convert to state names as strings.


type Abbreviation
    = AL
    | AK
    | AZ
    | AR
    | CA
    | CO
    | CT
    | DE
    | DC
    | FL
    | GA
    | HI
    | ID
    | IL
    | IN
    | IA
    | KS
    | KY
    | LA
    | ME
    | MT
    | NE
    | NV
    | NH
    | NJ
    | NM
    | NY
    | NC
    | ND
    | OH
    | OK
    | OR
    | MD
    | MA
    | MI
    | MN
    | MS
    | MO
    | PA
    | RI
    | SC
    | SD
    | TN
    | TX
    | UT
    | VT
    | VA
    | WA
    | WV
    | WI
    | WY

Every US State abbreviation.

all : List Abbreviation

All the abbreviations as a list

toString : Abbreviation -> String

Get the states name from the abbreviation

UsState.toString AZ == "arizona" -- True

fromString : String -> Maybe Abbreviation

Get the states abbreviation from its name

UsState.fromString "Arizona" == Just AZ -- True

UsState.fromString "Arizona   " == Just AZ -- True

UsState.fromString "arizona" == Just AZ -- True

UsState.fromString "puerto rico" == Nothing -- True