Lookup value-pairs from the left or the right.
PairDictlowerUppercaseLetters=
empty
|>insert { left= 'a', right= 'A' }
|>insert { left= 'b', right= 'B' }
|>insert { left= 'c', right= 'C' }
upperCase char=
rightOf char lowerUppercaseLetterstry in the ellie of the example cased letters
type Element=
Hydrogen
| Helium
type alias ProtonCount= Int
elementProtons=
empty
|>insert { left= Hydrogen, right= 1 }
|>insert { left= Helium, right= 2 }
elementsByProtons=
dictFromRight elementProtonsYou have pairs that belong together:
brackets=
fromList
[ ( '(', ')' )
, ( '{', '}' )
]
typeChar character=
case leftOf character brackets of
Just opening->
String.fromList [ opening, character ]
Nothing->
case rightOf character brackets of
Just closing->
String.fromList [ character, closing ]
Nothing->
String.fromChar character
"Typing (: " ++(typeChar '(') ++". Even }: " ++(typeChar '}')PairDictanswers=
fromList
[ ( "Hi", "Hi there!" )
, ( "Bye", "Ok, have a nice day and spread some love.")
, ( "How are you", "I don't have feelings :(" )
, ( "Are you a robot", "I think the most human answer is 'Haha... yes'" )
]please use a dict where it is more appropriate: Dicts are for one-way access
englishGerman=
fromList
[ ( "elm", "Ulme" )
, ( "git", "Schwachkopf" )
]A right → left and backwards relationship isn't fitting, as left or right can have multiple translations!
Please take a look at elm-bidict