;; Haskell Unicode helper functions
;;
;; Copyright 2010‚Äî2011 Roel van Dijk
;;
;; All rights reserved.
;;
;; Redistribution and use in source and binary forms, with or without
;; modification, are permitted provided that the following conditions
;; are met:
;;
;;     * Redistributions of source code must retain the above
;;       copyright notice, this list of conditions and the following
;;       disclaimer.
;;
;;     * Redistributions in binary form must reproduce the above
;;       copyright notice, this list of conditions and the following
;;       disclaimer in the documentation and/or other materials
;;       provided with the distribution.
;;
;;     * The name of Roel van Dijk and the names of contributors may
;;       NOT be used to endorse or promote products derived from this
;;       software without specific prior written permission.
;;
;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
;; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
;; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
;; FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
;; COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
;; INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
;; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
;; SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
;; HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
;; STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
;; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
;; OF THE POSSIBILITY OF SUCH DAMAGE.

(provide 'haskell-unicode-input-method)
(require 'quail)

;;;###autoload
(defun turn-on-haskell-unicode-input-method ()
  "Set input method `haskell-unicode'.
See Info node `Unicode(haskell-mode)' for more details."
  (interactive)
  (set-input-method "haskell-unicode"))

(quail-define-package
 "haskell-unicode" ;; name
 "UTF-8"           ;; language
 "\\"              ;; title
 t                 ;; guidance
 "Haskell Unicode input method.
Designed to be used with the Haskell UnicodeSyntax language
extension in combination with the x-unicode-symbols set of
packages (base-unicode-symbols and containers-unicode-symbols).
"                  ;; docstring
  nil              ;; translation-keys
  nil              ;; forget-last-selection
  nil              ;; deterministic
  nil              ;; kbd-translate
  nil              ;; show-layout
  nil              ;; create-decode-map
  nil              ;; maximum-shortest
  nil              ;; overlay-plist
  nil              ;; update-translation-function
  nil              ;; conversion-keys
  t                ;; simple
  )

(quail-define-rules
 ;; Greek letters
 ("alpha "           ["Œ±"])
 ("Alpha "           ["Œë"])
 ("beta "            ["Œ≤"])
 ("Beta "            ["Œí"])
 ("gamma "           ["Œ≥"])
 ("Gamma "           ["Œì"])
 ("delta "           ["Œ¥"])
 ("Delta "           ["Œî"])
 ("epsilon "         ["Œµ"])
 ("Epsilon "         ["Œï"])
 ("zeta "            ["Œ∂"])
 ("Zeta "            ["Œñ"])
 ("eta "             ["Œ∑"])
 ("Eta "             ["Œó"])
 ("theta "           ["Œ∏"])
 ("Theta "           ["Œò"])
 ("iota "            ["Œπ"])
 ("Iota "            ["Œô"])
 ("kappa "           ["Œ∫"])
 ("Kappa "           ["Œö"])
 ("lambda "          ["Œª"])
 ("Lambda "          ["Œõ"])
 ("lamda "           ["Œª"])
 ("Lamda "           ["Œõ"])
 ("mu "              ["Œº"])
 ("Mu "              ["Œú"])
 ("nu "              ["ŒΩ"])
 ("Nu "              ["Œù"])
 ("xi "              ["Œæ"])
 ("Xi "              ["Œû"])
 ("omicron "         ["Œø"])
 ("Omicron "         ["Œü"])
 ("pi "              ["œÄ"])
 ("Pi "              ["Œ†"])
 ("rho "             ["œÅ"])
 ("Rho "             ["Œ°"])
 ("sigma "           ["œÉ"])
 ("Sigma "           ["Œ£"])
 ("tau "             ["œÑ"])
 ("Tau "             ["Œ§"])
 ("upsilon "         ["œÖ"])
 ("Upsilon "         ["Œ•"])
 ("phi "             ["œÜ"])
 ("Phi "             ["Œ¶"])
 ("chi "             ["œá"])
 ("Chi "             ["Œß"])
 ("psi "             ["œà"])
 ("Psi "             ["Œ®"])
 ("omega "           ["œâ"])
 ("Omega "           ["Œ©"])
 ("digamma "         ["œù"])
 ("Digamma "         ["œú"])
 ("san "             ["œª"])
 ("San "             ["œ∫"])
 ("qoppa "           ["œô"])
 ("Qoppa "           ["œò"])
 ("sampi "           ["œ°"])
 ("Sampi "           ["œ†"])
 ("stigma "          ["œõ"])
 ("Stigma "          ["œö"])
 ("heta "            ["Õ±"])
 ("Heta "            ["Õ∞"])
 ("sho "             ["œ∏"])
 ("Sho "             ["œ∑"])

 ;; Double-struck letters
 ("|A|"              ["ùî∏"])
 ("|B|"              ["ùîπ"])
 ("|C|"              ["‚ÑÇ"])
 ("|D|"              ["ùîª"])
 ("|E|"              ["ùîº"])
 ("|F|"              ["ùîΩ"])
 ("|G|"              ["ùîæ"])
 ("|H|"              ["‚Ñç"])
 ("|I|"              ["ùïÄ"])
 ("|J|"              ["ùïÅ"])
 ("|K|"              ["ùïÇ"])
 ("|L|"              ["ùïÉ"])
 ("|M|"              ["ùïÑ"])
 ("|N|"              ["‚Ñï"])
 ("|O|"              ["ùïÜ"])
 ("|P|"              ["‚Ñô"])
 ("|Q|"              ["‚Ñö"])
 ("|R|"              ["‚Ñù"])
 ("|S|"              ["ùïä"])
 ("|T|"              ["ùïã"])
 ("|U|"              ["ùïå"])
 ("|V|"              ["ùïç"])
 ("|W|"              ["ùïé"])
 ("|X|"              ["ùïè"])
 ("|Y|"              ["ùïê"])
 ("|Z|"              ["‚Ñ§"])
 ("|gamma|"          ["‚ÑΩ"])
 ("|Gamma|"          ["‚Ñæ"])
 ("|pi|"             ["‚Ñº"])
 ("|Pi|"             ["‚Ñø"])

 ;; Types
 ("::"               ["‚à∑"])

 ;; Quantifiers
 ("forall"           ["‚àÄ"])
 ("exists"           ["‚àÉ"])

 ;; Arrows
 ("->"               ["‚Üí"])
 ;; ("-->"              ["‚ü∂"])
 ("<-"               ["‚Üê"])
 ;; ("<--"              ["‚üµ"])
 ;; ("<->"              ["‚Üî"])
 ;; ("<-->"             ["‚ü∑"])

 ("=>"               ["‚áí"])
 ;; ("==>"              ["‚üπ"])
 ;; ("<="               ["‚áê"])
 ;; ("<=="              ["‚ü∏"])
 ;; ("<=>"              ["‚áî"])
 ;; ("<==>"             ["‚ü∫"])

 ;; ("|->"              ["‚Ü¶"])
 ;; ("|-->"             ["‚üº"])
 ;; ("<-|"              ["‚Ü§"])
 ;; ("<--|"             ["‚üª"])

 ;; ("|=>"              ["‚§á"])
 ;; ("|==>"             ["‚üæ"])
 ;; ("<=|"              ["‚§Ü"])
 ;; ("<==|"             ["‚üΩ"])

 ("~>"               ["‚áù"])
 ;; ("~~>"              ["‚üø"])
 ("<~"               ["‚áú"])
 ;; ("<~~"              ["‚¨≥"])

 ;; (">->"              ["‚Ü£"])
 ;; ("<-<"              ["‚Ü¢"])
 ;; ("->>"              ["‚Ü†"])
 ;; ("<<-"              ["‚Üû"])

 ;; (">->>"             ["‚§ñ"])
 ;; ("<<-<"             ["‚¨ª"])

 ;; ("<|-"              ["‚áΩ"])
 ;; ("-|>"              ["‚áæ"])
 ;; ("<|-|>"            ["‚áø"])

 ;; ("<-/-"             ["‚Üö"])
 ;; ("-/->"             ["‚Üõ"])

 ;; ("<-|-"             ["‚á∑"])
 ;; ("-|->"             ["‚á∏"])
 ;; ("<-|->"            ["‚áπ"])

 ;; ("<-||-"            ["‚á∫"])
 ;; ("-||->"            ["‚áª"])
 ;; ("<-||->"           ["‚áº"])

 ;; ("-o->"             ["‚á¥"])
 ;; ("<-o-"             ["‚¨∞"])

 ;; Boolean operators
 ;; ("not"              ["¬¨"])
 ("&&"               ["‚àß"])
 ("||"               ["‚à®"])

 ;; Relational operators
 ("=="               ["‚â°"])
 ("/="               ["‚â¢" "‚â†"])
 ("<="               ["‚â§"])
 (">="               ["‚â•"])
 ("/<"               ["‚âÆ"])
 ("/>"               ["‚âØ"])

 ;; Arithmetic
 ;; (" / "              [" √∑ "])
 (" * "              [" ‚ãÖ "])

 ;; Containers / Collections
 ;; ("++"               ["‚ß∫"])
 ;; ("+++"              ["‚ßª"])
 ;; ("|||"              ["‚´¥"])
 ;; ("empty"            ["‚àÖ"])
 ("elem"             ["‚àà"])
 ("notElem"          ["‚àâ"])
 ("member"           ["‚àà"])
 ("notMember"        ["‚àâ"])
 ("union"            ["‚à™"])
 ("intersection"     ["‚à©"])
 ("isSubsetOf"       ["‚äÜ"])
 ("isProperSubsetOf" ["‚äÇ"])

 ;; Other
 ;; ("<<"               ["‚â™"])
 ;; (">>"               ["‚â´"])
 ("<<<"              ["‚ãò"])
 (">>>"              ["‚ãô"])
 ("<|"               ["‚ä≤"])
 ("|>"               ["‚ä≥"])
 ("><"               ["‚ãà"])
 ;; ("mempty"           ["‚àÖ"])
 ("mappend"          ["‚äï"])
 ;; ("<*>"              ["‚äõ"])
 (" . "              [" ‚àò "])
 ("undefined"        ["‚ä•"])
 (":="               ["‚âî"])
 ("=:"               ["‚âï"])
 ("=def"             ["‚âù"])
 ("=?"               ["‚âü"])
 ("..."              ["‚Ä¶"])

 ;; Braces
 ;; ("[|"               ["„Äö"])
 ;; ("|]"               ["„Äõ"])

 ;; Numeric subscripts
 ("_0 "              ["‚ÇÄ"])
 ("_1 "              ["‚ÇÅ"])
 ("_2 "              ["‚ÇÇ"])
 ("_3 "              ["‚ÇÉ"])
 ("_4 "              ["‚ÇÑ"])
 ("_5 "              ["‚ÇÖ"])
 ("_6 "              ["‚ÇÜ"])
 ("_7 "              ["‚Çá"])
 ("_8 "              ["‚Çà"])
 ("_9 "              ["‚Çâ"])

 ;; Numeric superscripts
 ("^0 "              ["‚Å∞"])
 ("^1 "              ["¬π"])
 ("^2 "              ["¬≤"])
 ("^3 "              ["¬≥"])
 ("^4 "              ["‚Å¥"])
 ("^5 "              ["‚Åµ"])
 ("^6 "              ["‚Å∂"])
 ("^7 "              ["‚Å∑"])
 ("^8 "              ["‚Å∏"])
 ("^9 "              ["‚Åπ"])
)
