lectures.alex.balgavy.eu

Lecture notes from university.
git clone git://git.alex.balgavy.eu/lectures.alex.balgavy.eu.git
Log | Files | Refs | Submodules

syntax_test_haskell.hs (6284B)


      1 -- SYNTAX TEST "Packages/Haskell/Haskell.sublime-syntax"
      2 
      3 23*36  -- single line comment
      4 --     ^^ punctuation.definition.comment.haskell
      5 --     ^^^^^^^^^^^^^^^^^^^^^^^ comment.line.double-dash.haskell
      6 23*36
      7 -- <- - comment.line.double-dash.haskell
      8 
      9    {- block comment -} 23*36
     10 -- ^^ punctuation.definition.comment.begin.haskell
     11 -- ^^^^^^^^^^^^^^^^^^^ comment.block.haskell
     12 --                  ^^ punctuation.definition.comment.end.haskell
     13 --                    ^ - comment.block.haskell
     14 
     15    {- {-# #-} -} 23*36
     16 -- ^^ punctuation.definition.comment.begin.haskell
     17 -- ^^^^^^^^^^^^^ comment.block.haskell - meta.preprocessor.haskell
     18 --            ^^ punctuation.definition.comment.end.haskell
     19 --              ^ - comment.block.haskell
     20 
     21    {- {- #-} -} 23*36
     22 -- ^^ punctuation.definition.comment.begin.haskell
     23 -- ^^^^^^^^^^^^ comment.block.haskell
     24 --           ^^ punctuation.definition.comment.end.haskell
     25 --             ^ - comment.block.haskell
     26 
     27    {- {- -} -} 23*36
     28 -- ^^ punctuation.definition.comment.begin.haskell
     29 -- ^^^^^^^^^^^ comment.block.haskell
     30 --          ^^ punctuation.definition.comment.end.haskell
     31 --            ^ - comment.block.haskell
     32 
     33    {- {-# -} -} 23*36
     34 -- ^^ punctuation.definition.comment.begin.haskell
     35 -- ^^^^^^^^^^^^ comment.block.haskell - meta.preprocessor.haskell
     36 --           ^^ punctuation.definition.comment.end.haskell
     37 --             ^ - comment.block.haskell
     38 
     39    {- {-# {- test -} -} -} 23*36
     40 -- ^^ punctuation.definition.comment.begin.haskell
     41 -- ^^^^^^^^^^^^^^^^^^^^^^^ comment.block.haskell - meta.preprocessor.haskell
     42 --                      ^^ punctuation.definition.comment.end.haskell
     43 --                        ^ - comment.block.haskell
     44 
     45    class (Functor t, Foldable t) => Traversable t where
     46 -- ^^^^^ keyword.other.haskell
     47 -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.class.haskell
     48    {-# MINIMAL traverse | sequenceA LANGUAGE #-}
     49 -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.haskell
     50 --                                              ^ - meta.preprocessor.haskell
     51 --                                   ^^^^^^^ keyword.other.preprocessor.haskell
     52 
     53 -- | Map each element of a structure to an action,
     54 -- evaluate these actions from left to right, and
     55 -- collect the results. For a version that ignores
     56 -- the results see 'Data.Foldable.traverse_'.
     57 -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.double-dash.haskell
     58 
     59    traverse :: Applicative f =>
     60 -- ^^^^^^^^ entity.name.function.haskell
     61 --          ^^ keyword.other.double-colon.haskell
     62 --             ^^^^^^^^^^^ storage.type.haskell
     63 -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.type-declaration.haskell
     64 --                           ^^ keyword.other.big-arrow.haskell
     65     (a -> f b)
     66 -- ^^^^^^^^^^^^ meta.function.type-declaration.haskell
     67 --     ^^ keyword.other.arrow.haskell
     68     -> t a
     69 -- ^^^^^^^^ meta.function.type-declaration.haskell
     70 --  ^^ keyword.other.arrow.haskell
     71     -> f (t b)
     72 -- ^^^^^^^^^^^^ meta.function.type-declaration.haskell
     73 --  ^^ keyword.other.arrow.haskell
     74    traverse f = sequenceA . fmap f
     75 --            ^ keyword.operator.haskell
     76 --                        ^ keyword.operator.haskell
     77 
     78 -- | Evaluate each action in the structure from
     79 -- left to right, and collect the results.
     80 -- For a version that ignores the results see
     81 -- 'Data.Foldable.sequenceA_'.
     82    sequenceA ∷ Applicative f ⇒ t (f a) → f (t a)
     83 -- ^^^^^^^^^ entity.name.function.haskell
     84 --           ^ keyword.other.double-colon.haskell
     85 --             ^^^^^^^^^^^ storage.type.haskell
     86 --                           ^ keyword.other.big-arrow.haskell
     87 --                                     ^ keyword.other.arrow.haskell
     88    sequenceA = traverse id
     89 --           ^ keyword.operator.haskell
     90 
     91 --
     92 -- infix operators
     93 --
     94    a a = (+) a 2
     95 --     ^ keyword.operator.haskell
     96 --       ^^^ entity.name.function.infix.haskell
     97 --             ^ constant.numeric.integer.decimal.haskell
     98    a a = (-) a 2
     99 --     ^ keyword.operator.haskell
    100 --       ^^^ entity.name.function.infix.haskell
    101 --             ^ constant.numeric.integer.decimal.haskell
    102    a a = (*) a 2
    103 --     ^ keyword.operator.haskell
    104 --       ^^^ entity.name.function.infix.haskell
    105 --             ^ constant.numeric.integer.decimal.haskell
    106    a a = (/) a 2
    107 --     ^ keyword.operator.haskell
    108 --       ^^^ entity.name.function.infix.haskell
    109 --             ^ constant.numeric.integer.decimal.haskell
    110 
    111 -- Tests for #1320, #1880.
    112 
    113    class TooMany a where
    114      tooMany :: a -> Bool
    115 -- ^^^^^^^^^^^^^^^^^^^^^^ meta.function.type-declaration.haskell
    116      tooManyToo ::
    117 -- ^^^^^^^^^^^^^^^ meta.function.type-declaration.haskell
    118        a -> Bool
    119 -- ^^^^^^^^^^^^^ meta.function.type-declaration.haskell
    120 
    121    instance TooMany Int where
    122 -- ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.instance.haskell
    123      tooMany n = n > 42
    124 
    125    foldBoolGuard :: a -> a -> Bool -> a
    126 -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.type-declaration.haskell
    127    foldBoolGuard x y z
    128 -- ^^^^^^^^^^^^^^^^^^^ source.haskell
    129      | z         = y
    130 --   ^ keyword.operator.haskell
    131      | otherwise = x
    132 
    133    countTheBeforeVowel :: String
    134    -- This comment should not interrupt the type signature.
    135 
    136    -- The blank line above should not interrupt the type signature.
    137 
    138    {-
    139       This multiline comment should
    140       not interrupt the type signature.
    141    -}
    142 
    143      -> Integer
    144 -- ^^^^^^^^^^^^ meta.function.type-declaration.haskell
    145    countTheBeforeVowel = undefined
    146 
    147 
    148 --NUMBERS
    149 
    150     0
    151 --  ^ constant.numeric.integer.decimal
    152 
    153     1234567890
    154 --  ^^^^^^^^^^ constant.numeric.integer.decimal
    155 
    156     0o1234567
    157 --  ^^^^^^^^^ constant.numeric.integer.octal
    158 --  ^^ punctuation.definition.numeric.base.haskell
    159 
    160     1.
    161 --  ^ constant.numeric.integer.decimal
    162 --   ^ keyword.operator.haskell
    163 
    164     .2
    165 --  ^ keyword.operator.haskell
    166 --   ^ constant.numeric.integer.decimal
    167 
    168     12.345
    169 --  ^^^^^^ constant.numeric.float.decimal
    170 --    ^ punctuation.separator.decimal
    171 
    172     1e10
    173 --  ^^^^ constant.numeric.float.decimal
    174 
    175     0.5e+0
    176 --  ^^^^^^ constant.numeric.float.decimal
    177 --   ^ punctuation.separator.decimal
    178 
    179     9e-1
    180 --  ^^^^ constant.numeric.float.decimal
    181 
    182     0x0
    183 --  ^^^ constant.numeric.integer.hexadecimal
    184 --  ^^ punctuation.definition.numeric.base
    185 
    186     0XdeafBEEF42
    187 --  ^^^^^^^^^^^^ constant.numeric.integer.hexadecimal
    188 --  ^^ punctuation.definition.numeric.base