type currency = 
  | EUR
  | USD
  | GBP
  | JPY
  | CNY
  | INR
  | AUD
  | CAD
  | CHF
  | NZD

type currency_pairs = {
  pairs : ((currency * currency) * real) list
}

let find_rate (pairs : currency_pairs) (from_currency : currency) (to_currency : currency) : real option =
  List.assoc (from_currency, to_currency) pairs.pairs

let convert (pairs : currency_pairs) (from_currency : currency) (to_currency : currency) (amount : real) : real option =
  if from_currency = to_currency then
    Some amount
  else
    match find_rate pairs from_currency to_currency with
    | Some rate -> Some (amount *. rate)
    | None -> None

let create_currency_rates () : ((currency * currency) * real) list =
  [
    ((EUR, USD), 1.1);
    ((USD, EUR), 0.9);
    ((GBP, USD), 1.3);
    ((USD, GBP), 0.77);
    ((JPY, USD), 0.009);
    ((USD, JPY), 110.0);
    ((CNY, USD), 0.15);
    ((USD, CNY), 6.5);
    ((INR, USD), 0.013);
    ((USD, INR), 75.0);
    ((AUD, USD), 0.7);
    ((USD, AUD), 1.4);
    ((CAD, USD), 0.8);
    ((USD, CAD), 1.25);
    ((CHF, USD), 1.05);
    ((USD, CHF), 0.95);
    ((NZD, USD), 0.65);
    ((USD, NZD), 1.54)
  ]

let main () : unit =
  let rates = create_currency_rates () in
  let pairs = { pairs = rates } in
  let _ = convert pairs EUR USD 100.0 in
  let _ = convert pairs USD EUR 100.0 in
  let _ = convert pairs GBP USD 100.0 in
  let _ = convert pairs USD GBP 100.0 in
  let _ = convert pairs JPY USD 100.0 in
  let _ = convert pairs USD JPY 100.0 in
  ()
