# a2ps style sheet for Haskell
# Copyright (c) 1999-2000 Ilya Beylin, Akim Demaille, Miguel Santana

# This file is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <https://www.gnu.org/licenses/>.

# this file:	ftp://ftp.cs.chalmers.se/pub/users/ilya/a2ps/haskell.ssh

style Haskell is
written by "Ilya Beylin <ilya@cs.chalmers.se>"
version is 1.3
requires a2ps 4.12k


documentation is
"Haskell: non-strict functional programming language"
"  https://www.haskell.org/"

#Notes:
#- Haskell strings are not parsed properly. C-strings are used instead
#- maximal-munch rule is not followed in examples like ::: or ---
#- Only 7bit characters are recognised in places like operator names
#- literal Haskell (inverted commentary) is not at all supported

# Perhaps one should instead write a proper Haskell parser which would
# produce PreTeX

# A typical "sheets.map" entry:
# 	# Haskell programs
# 	*.hs                    haskell
end documentation

first alphabet is
   "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
second alphabet is
   "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_\'0123456789"
case sensitive

keywords in Keyword_strong are
    # the keywords of Haskell 98
    "case", "class", "data", "default", "deriving", "do", "else",
    "if", "import", "in", "infix", "infixl", "infixr", "instance",
    "let", "module", "newtype", "of", "then", "type", "where",
#   "_", "as",                # these should not be highlighted
    "qualified", "hiding"     # special words (not reserved)
end keywords

keywords in Keyword are
  # Constructors
  /A-Z[a-zA-z0-9\'_]*/
end keywords

operators  in Keyword_strong are
  /->/, "[", "]",/`[a-zA-z0-9\'_]+`/,
  # Constructor operators
  /:[-!@#$%^&*+<>\/?\\=|:]*/,
  # type signatures
  (/^[a-z][a-zA-Z0-9\'_, ]*::.*$/  Comment_strong)
end operators

# use symbol font with -g
optional operators are
   # does not look nice, and cannot be not protected
   #/\\\\/ \lambda,
   /->/ \rightarrow,
   /<-/ \leftarrow,
   /=>/ \Rightarrow,
   /\/=/ \neq,
   /<=/ \leq,
   />=/ \geq,
   "::" \in
end operators

operators are
  /[-!@#$%^&*+<>\/?\\=|]{3,}/
end operators

sequences are
  # preprocessor directives
  /^#/  Comment_strong,
  "{-" Comment Comment "-}" Comment,
  "--" Comment,
  "{-#" Comment_strong Comment_strong "-}" Comment_strong,
  C-string  # not quite, but actual syntax is too involved
end sequences

end style
