diff --git a/components/prism-haskell.js b/components/prism-haskell.js index 1a09b1c282..852b3a89be 100644 --- a/components/prism-haskell.js +++ b/components/prism-haskell.js @@ -19,22 +19,47 @@ Prism.languages.haskell = { pattern: /(^[\t ]*)import\s+(?:qualified\s+)?(?:[A-Z][\w']*)(?:\.[A-Z][\w']*)*(?:\s+as\s+(?:[A-Z][\w']*)(?:\.[A-Z][\w']*)*)?(?:\s+hiding\b)?/m, lookbehind: true, inside: { - 'keyword': /\b(?:import|qualified|as|hiding)\b/ + 'keyword': /\b(?:import|qualified|as|hiding)\b/, + 'punctuation': /\./ } }, // These are builtin variables only. Constructors are highlighted later as a constant. 'builtin': /\b(?:abs|acos|acosh|all|and|any|appendFile|approxRational|asTypeOf|asin|asinh|atan|atan2|atanh|basicIORun|break|catch|ceiling|chr|compare|concat|concatMap|const|cos|cosh|curry|cycle|decodeFloat|denominator|digitToInt|div|divMod|drop|dropWhile|either|elem|encodeFloat|enumFrom|enumFromThen|enumFromThenTo|enumFromTo|error|even|exp|exponent|fail|filter|flip|floatDigits|floatRadix|floatRange|floor|fmap|foldl|foldl1|foldr|foldr1|fromDouble|fromEnum|fromInt|fromInteger|fromIntegral|fromRational|fst|gcd|getChar|getContents|getLine|group|head|id|inRange|index|init|intToDigit|interact|ioError|isAlpha|isAlphaNum|isAscii|isControl|isDenormalized|isDigit|isHexDigit|isIEEE|isInfinite|isLower|isNaN|isNegativeZero|isOctDigit|isPrint|isSpace|isUpper|iterate|last|lcm|length|lex|lexDigits|lexLitChar|lines|log|logBase|lookup|map|mapM|mapM_|max|maxBound|maximum|maybe|min|minBound|minimum|mod|negate|not|notElem|null|numerator|odd|or|ord|otherwise|pack|pi|pred|primExitWith|print|product|properFraction|putChar|putStr|putStrLn|quot|quotRem|range|rangeSize|read|readDec|readFile|readFloat|readHex|readIO|readInt|readList|readLitChar|readLn|readOct|readParen|readSigned|reads|readsPrec|realToFrac|recip|rem|repeat|replicate|return|reverse|round|scaleFloat|scanl|scanl1|scanr|scanr1|seq|sequence|sequence_|show|showChar|showInt|showList|showLitChar|showParen|showSigned|showString|shows|showsPrec|significand|signum|sin|sinh|snd|sort|span|splitAt|sqrt|subtract|succ|sum|tail|take|takeWhile|tan|tanh|threadToIOResult|toEnum|toInt|toInteger|toLower|toRational|toUpper|truncate|uncurry|undefined|unlines|until|unwords|unzip|unzip3|userError|words|writeFile|zip|zip3|zipWith|zipWith3)\b/, // decimal integers and floating point numbers | octal integers | hexadecimal integers 'number': /\b(?:\d+(?:\.\d+)?(?:e[+-]?\d+)?|0o[0-7]+|0x[0-9a-f]+)\b/i, - // Most of this is needed because of the meaning of a single '.'. - // If it stands alone freely, it is the function composition. - // It may also be a separator between a module name and an identifier => no - // operator. If it comes together with other special characters it is an - // operator too. - 'operator': /\s\.\s|[-!#$%*+=?&@|~:<>^\\\/]*\.[-!#$%*+=?&@|~.:<>^\\\/]+|[-!#$%*+=?&@|~.:<>^\\\/]+\.[-!#$%*+=?&@|~:<>^\\\/]*|[-!#$%*+=?&@|~:<>^\\\/]+|`(?:[A-Z][\w']*\.)*[_a-z][\w']*`/, + 'operator': [ + { + // infix operator + pattern: /`(?:[A-Z][\w']*\.)*[_a-z][\w']*`/, + greedy: true + }, + { + // function composition + pattern: /(\s)\.(?=\s)/, + lookbehind: true + }, + // Most of this is needed because of the meaning of a single '.'. + // If it stands alone freely, it is the function composition. + // It may also be a separator between a module name and an identifier => no + // operator. If it comes together with other special characters it is an + // operator too. + // + // This regex means: /[-!#$%*+=?&@|~.:<>^\\\/]+/ without /\./. + /[-!#$%*+=?&@|~:<>^\\\/][-!#$%*+=?&@|~.:<>^\\\/]*|\.[-!#$%*+=?&@|~.:<>^\\\/]+/, + ], // In Haskell, nearly everything is a variable, do not highlight these. - 'hvariable': /\b(?:[A-Z][\w']*\.)*[_a-z][\w']*\b/, - 'constant': /\b(?:[A-Z][\w']*\.)*[A-Z][\w']*\b/, + 'hvariable': { + pattern: /\b(?:[A-Z][\w']*\.)*[_a-z][\w']*/, + inside: { + 'punctuation': /\./ + } + }, + 'constant': { + pattern: /\b(?:[A-Z][\w']*\.)*[A-Z][\w']*/, + inside: { + 'punctuation': /\./ + } + }, 'punctuation': /[{}[\];(),.:]/ }; diff --git a/components/prism-haskell.min.js b/components/prism-haskell.min.js index d62b563057..9257b46bf7 100644 --- a/components/prism-haskell.min.js +++ b/components/prism-haskell.min.js @@ -1 +1 @@ -Prism.languages.haskell={comment:{pattern:/(^|[^-!#$%*+=?&@|~.:<>^\\\/])(?:--(?:(?=.)[^-!#$%*+=?&@|~.:<>^\\\/].*|$)|\{-[\s\S]*?-\})/m,lookbehind:!0},char:{pattern:/'(?:[^\\']|\\(?:[abfnrtv\\"'&]|\^[A-Z@[\]^_]|NUL|SOH|STX|ETX|EOT|ENQ|ACK|BEL|BS|HT|LF|VT|FF|CR|SO|SI|DLE|DC1|DC2|DC3|DC4|NAK|SYN|ETB|CAN|EM|SUB|ESC|FS|GS|RS|US|SP|DEL|\d+|o[0-7]+|x[0-9a-fA-F]+))'/,alias:"string"},string:{pattern:/"(?:[^\\"]|\\(?:\S|\s+\\))*"/,greedy:!0},keyword:/\b(?:case|class|data|deriving|do|else|if|in|infixl|infixr|instance|let|module|newtype|of|primitive|then|type|where)\b/,"import-statement":{pattern:/(^[\t ]*)import\s+(?:qualified\s+)?(?:[A-Z][\w']*)(?:\.[A-Z][\w']*)*(?:\s+as\s+(?:[A-Z][\w']*)(?:\.[A-Z][\w']*)*)?(?:\s+hiding\b)?/m,lookbehind:!0,inside:{keyword:/\b(?:import|qualified|as|hiding)\b/}},builtin:/\b(?:abs|acos|acosh|all|and|any|appendFile|approxRational|asTypeOf|asin|asinh|atan|atan2|atanh|basicIORun|break|catch|ceiling|chr|compare|concat|concatMap|const|cos|cosh|curry|cycle|decodeFloat|denominator|digitToInt|div|divMod|drop|dropWhile|either|elem|encodeFloat|enumFrom|enumFromThen|enumFromThenTo|enumFromTo|error|even|exp|exponent|fail|filter|flip|floatDigits|floatRadix|floatRange|floor|fmap|foldl|foldl1|foldr|foldr1|fromDouble|fromEnum|fromInt|fromInteger|fromIntegral|fromRational|fst|gcd|getChar|getContents|getLine|group|head|id|inRange|index|init|intToDigit|interact|ioError|isAlpha|isAlphaNum|isAscii|isControl|isDenormalized|isDigit|isHexDigit|isIEEE|isInfinite|isLower|isNaN|isNegativeZero|isOctDigit|isPrint|isSpace|isUpper|iterate|last|lcm|length|lex|lexDigits|lexLitChar|lines|log|logBase|lookup|map|mapM|mapM_|max|maxBound|maximum|maybe|min|minBound|minimum|mod|negate|not|notElem|null|numerator|odd|or|ord|otherwise|pack|pi|pred|primExitWith|print|product|properFraction|putChar|putStr|putStrLn|quot|quotRem|range|rangeSize|read|readDec|readFile|readFloat|readHex|readIO|readInt|readList|readLitChar|readLn|readOct|readParen|readSigned|reads|readsPrec|realToFrac|recip|rem|repeat|replicate|return|reverse|round|scaleFloat|scanl|scanl1|scanr|scanr1|seq|sequence|sequence_|show|showChar|showInt|showList|showLitChar|showParen|showSigned|showString|shows|showsPrec|significand|signum|sin|sinh|snd|sort|span|splitAt|sqrt|subtract|succ|sum|tail|take|takeWhile|tan|tanh|threadToIOResult|toEnum|toInt|toInteger|toLower|toRational|toUpper|truncate|uncurry|undefined|unlines|until|unwords|unzip|unzip3|userError|words|writeFile|zip|zip3|zipWith|zipWith3)\b/,number:/\b(?:\d+(?:\.\d+)?(?:e[+-]?\d+)?|0o[0-7]+|0x[0-9a-f]+)\b/i,operator:/\s\.\s|[-!#$%*+=?&@|~:<>^\\\/]*\.[-!#$%*+=?&@|~.:<>^\\\/]+|[-!#$%*+=?&@|~.:<>^\\\/]+\.[-!#$%*+=?&@|~:<>^\\\/]*|[-!#$%*+=?&@|~:<>^\\\/]+|`(?:[A-Z][\w']*\.)*[_a-z][\w']*`/,hvariable:/\b(?:[A-Z][\w']*\.)*[_a-z][\w']*\b/,constant:/\b(?:[A-Z][\w']*\.)*[A-Z][\w']*\b/,punctuation:/[{}[\];(),.:]/},Prism.languages.hs=Prism.languages.haskell; \ No newline at end of file +Prism.languages.haskell={comment:{pattern:/(^|[^-!#$%*+=?&@|~.:<>^\\\/])(?:--(?:(?=.)[^-!#$%*+=?&@|~.:<>^\\\/].*|$)|\{-[\s\S]*?-\})/m,lookbehind:!0},char:{pattern:/'(?:[^\\']|\\(?:[abfnrtv\\"'&]|\^[A-Z@[\]^_]|NUL|SOH|STX|ETX|EOT|ENQ|ACK|BEL|BS|HT|LF|VT|FF|CR|SO|SI|DLE|DC1|DC2|DC3|DC4|NAK|SYN|ETB|CAN|EM|SUB|ESC|FS|GS|RS|US|SP|DEL|\d+|o[0-7]+|x[0-9a-fA-F]+))'/,alias:"string"},string:{pattern:/"(?:[^\\"]|\\(?:\S|\s+\\))*"/,greedy:!0},keyword:/\b(?:case|class|data|deriving|do|else|if|in|infixl|infixr|instance|let|module|newtype|of|primitive|then|type|where)\b/,"import-statement":{pattern:/(^[\t ]*)import\s+(?:qualified\s+)?(?:[A-Z][\w']*)(?:\.[A-Z][\w']*)*(?:\s+as\s+(?:[A-Z][\w']*)(?:\.[A-Z][\w']*)*)?(?:\s+hiding\b)?/m,lookbehind:!0,inside:{keyword:/\b(?:import|qualified|as|hiding)\b/,punctuation:/\./}},builtin:/\b(?:abs|acos|acosh|all|and|any|appendFile|approxRational|asTypeOf|asin|asinh|atan|atan2|atanh|basicIORun|break|catch|ceiling|chr|compare|concat|concatMap|const|cos|cosh|curry|cycle|decodeFloat|denominator|digitToInt|div|divMod|drop|dropWhile|either|elem|encodeFloat|enumFrom|enumFromThen|enumFromThenTo|enumFromTo|error|even|exp|exponent|fail|filter|flip|floatDigits|floatRadix|floatRange|floor|fmap|foldl|foldl1|foldr|foldr1|fromDouble|fromEnum|fromInt|fromInteger|fromIntegral|fromRational|fst|gcd|getChar|getContents|getLine|group|head|id|inRange|index|init|intToDigit|interact|ioError|isAlpha|isAlphaNum|isAscii|isControl|isDenormalized|isDigit|isHexDigit|isIEEE|isInfinite|isLower|isNaN|isNegativeZero|isOctDigit|isPrint|isSpace|isUpper|iterate|last|lcm|length|lex|lexDigits|lexLitChar|lines|log|logBase|lookup|map|mapM|mapM_|max|maxBound|maximum|maybe|min|minBound|minimum|mod|negate|not|notElem|null|numerator|odd|or|ord|otherwise|pack|pi|pred|primExitWith|print|product|properFraction|putChar|putStr|putStrLn|quot|quotRem|range|rangeSize|read|readDec|readFile|readFloat|readHex|readIO|readInt|readList|readLitChar|readLn|readOct|readParen|readSigned|reads|readsPrec|realToFrac|recip|rem|repeat|replicate|return|reverse|round|scaleFloat|scanl|scanl1|scanr|scanr1|seq|sequence|sequence_|show|showChar|showInt|showList|showLitChar|showParen|showSigned|showString|shows|showsPrec|significand|signum|sin|sinh|snd|sort|span|splitAt|sqrt|subtract|succ|sum|tail|take|takeWhile|tan|tanh|threadToIOResult|toEnum|toInt|toInteger|toLower|toRational|toUpper|truncate|uncurry|undefined|unlines|until|unwords|unzip|unzip3|userError|words|writeFile|zip|zip3|zipWith|zipWith3)\b/,number:/\b(?:\d+(?:\.\d+)?(?:e[+-]?\d+)?|0o[0-7]+|0x[0-9a-f]+)\b/i,operator:[{pattern:/`(?:[A-Z][\w']*\.)*[_a-z][\w']*`/,greedy:!0},{pattern:/(\s)\.(?=\s)/,lookbehind:!0},/[-!#$%*+=?&@|~:<>^\\\/][-!#$%*+=?&@|~.:<>^\\\/]*|\.[-!#$%*+=?&@|~.:<>^\\\/]+/],hvariable:{pattern:/\b(?:[A-Z][\w']*\.)*[_a-z][\w']*/,inside:{punctuation:/\./}},constant:{pattern:/\b(?:[A-Z][\w']*\.)*[A-Z][\w']*/,inside:{punctuation:/\./}},punctuation:/[{}[\];(),.:]/},Prism.languages.hs=Prism.languages.haskell; \ No newline at end of file diff --git a/components/prism-purescript.js b/components/prism-purescript.js index 9abff50301..35d21eb187 100644 --- a/components/prism-purescript.js +++ b/components/prism-purescript.js @@ -8,12 +8,24 @@ Prism.languages.purescript = Prism.languages.extend('haskell', { pattern: /(^[\t ]*)import\s+[A-Z][\w']*(?:\.[A-Z][\w']*)*(?:\s+as\s+[A-Z][\w']*(?:\.[A-Z][\w']*)*)?(?:\s+hiding\b)?/m, lookbehind: true, inside: { - 'keyword': /\b(?:import|as|hiding)\b/ + 'keyword': /\b(?:import|as|hiding)\b/, + 'punctuation': /\./ } }, // These are builtin functions only. Constructors are highlighted later as a constant. 'builtin': /\b(?:absurd|add|ap|append|apply|between|bind|bottom|clamp|compare|comparing|compose|conj|const|degree|discard|disj|div|eq|flap|flip|gcd|identity|ifM|join|lcm|liftA1|liftM1|map|max|mempty|min|mod|mul|negate|not|notEq|one|otherwise|recip|show|sub|top|unit|unless|unlessM|void|when|whenM|zero)\b/, + + 'operator': [ + // Infix operators + Prism.languages.haskell.operator[0], + // ASCII operators + Prism.languages.haskell.operator[2], + // All UTF16 Unicode operator symbols + // This regex is equivalent to /(?=[\x80-\uFFFF])[\p{gc=Math_Symbol}\p{gc=Currency_Symbol}\p{Modifier_Symbol}\p{Other_Symbol}]/u + // See https://github.com/PrismJS/prism/issues/3006 for more details. + /[\xa2-\xa6\xa8\xa9\xac\xae-\xb1\xb4\xb8\xd7\xf7\u02c2-\u02c5\u02d2-\u02df\u02e5-\u02eb\u02ed\u02ef-\u02ff\u0375\u0384\u0385\u03f6\u0482\u058d-\u058f\u0606-\u0608\u060b\u060e\u060f\u06de\u06e9\u06fd\u06fe\u07f6\u07fe\u07ff\u09f2\u09f3\u09fa\u09fb\u0af1\u0b70\u0bf3-\u0bfa\u0c7f\u0d4f\u0d79\u0e3f\u0f01-\u0f03\u0f13\u0f15-\u0f17\u0f1a-\u0f1f\u0f34\u0f36\u0f38\u0fbe-\u0fc5\u0fc7-\u0fcc\u0fce\u0fcf\u0fd5-\u0fd8\u109e\u109f\u1390-\u1399\u166d\u17db\u1940\u19de-\u19ff\u1b61-\u1b6a\u1b74-\u1b7c\u1fbd\u1fbf-\u1fc1\u1fcd-\u1fcf\u1fdd-\u1fdf\u1fed-\u1fef\u1ffd\u1ffe\u2044\u2052\u207a-\u207c\u208a-\u208c\u20a0-\u20bf\u2100\u2101\u2103-\u2106\u2108\u2109\u2114\u2116-\u2118\u211e-\u2123\u2125\u2127\u2129\u212e\u213a\u213b\u2140-\u2144\u214a-\u214d\u214f\u218a\u218b\u2190-\u2307\u230c-\u2328\u232b-\u2426\u2440-\u244a\u249c-\u24e9\u2500-\u2767\u2794-\u27c4\u27c7-\u27e5\u27f0-\u2982\u2999-\u29d7\u29dc-\u29fb\u29fe-\u2b73\u2b76-\u2b95\u2b97-\u2bff\u2ce5-\u2cea\u2e50\u2e51\u2e80-\u2e99\u2e9b-\u2ef3\u2f00-\u2fd5\u2ff0-\u2ffb\u3004\u3012\u3013\u3020\u3036\u3037\u303e\u303f\u309b\u309c\u3190\u3191\u3196-\u319f\u31c0-\u31e3\u3200-\u321e\u322a-\u3247\u3250\u3260-\u327f\u328a-\u32b0\u32c0-\u33ff\u4dc0-\u4dff\ua490-\ua4c6\ua700-\ua716\ua720\ua721\ua789\ua78a\ua828-\ua82b\ua836-\ua839\uaa77-\uaa79\uab5b\uab6a\uab6b\ufb29\ufbb2-\ufbc1\ufdfc\ufdfd\ufe62\ufe64-\ufe66\ufe69\uff04\uff0b\uff1c-\uff1e\uff3e\uff40\uff5c\uff5e\uffe0-\uffe6\uffe8-\uffee\ufffc\ufffd]/ + ] }); Prism.languages.purs = Prism.languages.purescript; diff --git a/components/prism-purescript.min.js b/components/prism-purescript.min.js index afa495712a..17d9f57126 100644 --- a/components/prism-purescript.min.js +++ b/components/prism-purescript.min.js @@ -1 +1 @@ -Prism.languages.purescript=Prism.languages.extend("haskell",{keyword:/\b(?:ado|case|class|data|derive|do|else|forall|if|in|infixl|infixr|instance|let|module|newtype|of|primitive|then|type|where)\b|∀/,"import-statement":{pattern:/(^[\t ]*)import\s+[A-Z][\w']*(?:\.[A-Z][\w']*)*(?:\s+as\s+[A-Z][\w']*(?:\.[A-Z][\w']*)*)?(?:\s+hiding\b)?/m,lookbehind:!0,inside:{keyword:/\b(?:import|as|hiding)\b/}},builtin:/\b(?:absurd|add|ap|append|apply|between|bind|bottom|clamp|compare|comparing|compose|conj|const|degree|discard|disj|div|eq|flap|flip|gcd|identity|ifM|join|lcm|liftA1|liftM1|map|max|mempty|min|mod|mul|negate|not|notEq|one|otherwise|recip|show|sub|top|unit|unless|unlessM|void|when|whenM|zero)\b/}),Prism.languages.purs=Prism.languages.purescript; \ No newline at end of file +Prism.languages.purescript=Prism.languages.extend("haskell",{keyword:/\b(?:ado|case|class|data|derive|do|else|forall|if|in|infixl|infixr|instance|let|module|newtype|of|primitive|then|type|where)\b|∀/,"import-statement":{pattern:/(^[\t ]*)import\s+[A-Z][\w']*(?:\.[A-Z][\w']*)*(?:\s+as\s+[A-Z][\w']*(?:\.[A-Z][\w']*)*)?(?:\s+hiding\b)?/m,lookbehind:!0,inside:{keyword:/\b(?:import|as|hiding)\b/,punctuation:/\./}},builtin:/\b(?:absurd|add|ap|append|apply|between|bind|bottom|clamp|compare|comparing|compose|conj|const|degree|discard|disj|div|eq|flap|flip|gcd|identity|ifM|join|lcm|liftA1|liftM1|map|max|mempty|min|mod|mul|negate|not|notEq|one|otherwise|recip|show|sub|top|unit|unless|unlessM|void|when|whenM|zero)\b/,operator:[Prism.languages.haskell.operator[0],Prism.languages.haskell.operator[2],/[\xa2-\xa6\xa8\xa9\xac\xae-\xb1\xb4\xb8\xd7\xf7\u02c2-\u02c5\u02d2-\u02df\u02e5-\u02eb\u02ed\u02ef-\u02ff\u0375\u0384\u0385\u03f6\u0482\u058d-\u058f\u0606-\u0608\u060b\u060e\u060f\u06de\u06e9\u06fd\u06fe\u07f6\u07fe\u07ff\u09f2\u09f3\u09fa\u09fb\u0af1\u0b70\u0bf3-\u0bfa\u0c7f\u0d4f\u0d79\u0e3f\u0f01-\u0f03\u0f13\u0f15-\u0f17\u0f1a-\u0f1f\u0f34\u0f36\u0f38\u0fbe-\u0fc5\u0fc7-\u0fcc\u0fce\u0fcf\u0fd5-\u0fd8\u109e\u109f\u1390-\u1399\u166d\u17db\u1940\u19de-\u19ff\u1b61-\u1b6a\u1b74-\u1b7c\u1fbd\u1fbf-\u1fc1\u1fcd-\u1fcf\u1fdd-\u1fdf\u1fed-\u1fef\u1ffd\u1ffe\u2044\u2052\u207a-\u207c\u208a-\u208c\u20a0-\u20bf\u2100\u2101\u2103-\u2106\u2108\u2109\u2114\u2116-\u2118\u211e-\u2123\u2125\u2127\u2129\u212e\u213a\u213b\u2140-\u2144\u214a-\u214d\u214f\u218a\u218b\u2190-\u2307\u230c-\u2328\u232b-\u2426\u2440-\u244a\u249c-\u24e9\u2500-\u2767\u2794-\u27c4\u27c7-\u27e5\u27f0-\u2982\u2999-\u29d7\u29dc-\u29fb\u29fe-\u2b73\u2b76-\u2b95\u2b97-\u2bff\u2ce5-\u2cea\u2e50\u2e51\u2e80-\u2e99\u2e9b-\u2ef3\u2f00-\u2fd5\u2ff0-\u2ffb\u3004\u3012\u3013\u3020\u3036\u3037\u303e\u303f\u309b\u309c\u3190\u3191\u3196-\u319f\u31c0-\u31e3\u3200-\u321e\u322a-\u3247\u3250\u3260-\u327f\u328a-\u32b0\u32c0-\u33ff\u4dc0-\u4dff\ua490-\ua4c6\ua700-\ua716\ua720\ua721\ua789\ua78a\ua828-\ua82b\ua836-\ua839\uaa77-\uaa79\uab5b\uab6a\uab6b\ufb29\ufbb2-\ufbc1\ufdfc\ufdfd\ufe62\ufe64-\ufe66\ufe69\uff04\uff0b\uff1c-\uff1e\uff3e\uff40\uff5c\uff5e\uffe0-\uffe6\uffe8-\uffee\ufffc\ufffd]/]}),Prism.languages.purs=Prism.languages.purescript; \ No newline at end of file diff --git a/tests/languages/haskell/constant_feature.test b/tests/languages/haskell/constant_feature.test index 06f25f10e5..e477b737f7 100644 --- a/tests/languages/haskell/constant_feature.test +++ b/tests/languages/haskell/constant_feature.test @@ -1,15 +1,25 @@ Foo +Foo' Foo.Bar Baz.Foobar_42 ---------------------------------------------------- [ - ["constant", "Foo"], - ["constant", "Foo.Bar"], - ["constant", "Baz.Foobar_42"] + ["constant", ["Foo"]], + ["constant", ["Foo'"]], + ["constant", [ + "Foo", + ["punctuation", "."], + "Bar" + ]], + ["constant", [ + "Baz", + ["punctuation", "."], + "Foobar_42" + ]] ] ---------------------------------------------------- -Checks for constants. \ No newline at end of file +Checks for constants. diff --git a/tests/languages/haskell/hvariable_feature.test b/tests/languages/haskell/hvariable_feature.test index defa3ba74d..f7a6fc94dc 100644 --- a/tests/languages/haskell/hvariable_feature.test +++ b/tests/languages/haskell/hvariable_feature.test @@ -1,15 +1,25 @@ foo +foo' Foo.bar Baz.foobar_42 ---------------------------------------------------- [ - ["hvariable", "foo"], - ["hvariable", "Foo.bar"], - ["hvariable", "Baz.foobar_42"] + ["hvariable", ["foo"]], + ["hvariable", ["foo'"]], + ["hvariable", [ + "Foo", + ["punctuation", "."], + "bar" + ]], + ["hvariable", [ + "Baz", + ["punctuation", "."], + "foobar_42" + ]] ] ---------------------------------------------------- -Checks for hvariables. \ No newline at end of file +Checks for hvariables. diff --git a/tests/languages/haskell/import_statement_feature.test b/tests/languages/haskell/import_statement_feature.test index 105f510a04..afd7ddc74b 100644 --- a/tests/languages/haskell/import_statement_feature.test +++ b/tests/languages/haskell/import_statement_feature.test @@ -17,15 +17,21 @@ import Foo.Bar as Foo.Baz hiding ]], ["import-statement", [ ["keyword", "import"], - " Foo_42.Bar ", + " Foo_42", + ["punctuation", "."], + "Bar ", ["keyword", "as"], " Foobar" ]], ["import-statement", [ ["keyword", "import"], - " Foo.Bar ", + " Foo", + ["punctuation", "."], + "Bar ", ["keyword", "as"], - " Foo.Baz ", + " Foo", + ["punctuation", "."], + "Baz ", ["keyword", "hiding"] ]] ] diff --git a/tests/languages/haskell/operator_feature.test b/tests/languages/haskell/operator_feature.test index 9cd8339fbf..80cebc3d6e 100644 --- a/tests/languages/haskell/operator_feature.test +++ b/tests/languages/haskell/operator_feature.test @@ -17,21 +17,58 @@ reverse . sort [ ["operator", ".."], - ["builtin", "reverse"], ["operator", " . "], ["builtin", "sort"], + + ["builtin", "reverse"], + ["operator", "."], + ["builtin", "sort"], + ["operator", "`foo`"], + ["operator", "`Foo.bar`"], - ["operator", "+"], ["operator", "-"], ["operator", "*"], ["operator", "/"], - ["operator", "^"], ["operator", "^^"], ["operator", "**"], - ["operator", "&&"], ["operator", "||"], - ["operator", "<"], ["operator", "<="], ["operator", "=="], ["operator", "/="], - ["operator", ">="], ["operator", ">"], ["operator", "\\"], ["operator", "|"], - ["operator", "++"], ["operator", ":"], ["operator", "!!"], - ["operator", "\\\\"], ["operator", "<-"], ["operator", "->"], - ["operator", "="], ["operator", "::"], ["operator", "=>"], - ["operator", ">>"], ["operator", ">>="], ["operator", ">@>"], - ["operator", "~"], ["operator", "!"], ["operator", "@"] + + ["operator", "+"], + ["operator", "-"], + ["operator", "*"], + ["operator", "/"], + + ["operator", "^"], + ["operator", "^^"], + ["operator", "**"], + + ["operator", "&&"], + ["operator", "||"], + + ["operator", "<"], + ["operator", "<="], + ["operator", "=="], + ["operator", "/="], + + ["operator", ">="], + ["operator", ">"], + ["operator", "\\"], + ["operator", "|"], + + ["operator", "++"], + ["operator", ":"], + ["operator", "!!"], + + ["operator", "\\\\"], + ["operator", "<-"], + ["operator", "->"], + + ["operator", "="], + ["operator", "::"], + ["operator", "=>"], + + ["operator", ">>"], + ["operator", ">>="], + ["operator", ">@>"], + + ["operator", "~"], + ["operator", "!"], + ["operator", "@"] ] ---------------------------------------------------- -Checks for operators. \ No newline at end of file +Checks for operators. diff --git a/tests/languages/idris/constant_feature.test b/tests/languages/idris/constant_feature.test index 06f25f10e5..39ea0c114e 100644 --- a/tests/languages/idris/constant_feature.test +++ b/tests/languages/idris/constant_feature.test @@ -5,11 +5,19 @@ Baz.Foobar_42 ---------------------------------------------------- [ - ["constant", "Foo"], - ["constant", "Foo.Bar"], - ["constant", "Baz.Foobar_42"] + ["constant", ["Foo"]], + ["constant", [ + "Foo", + ["punctuation", "."], + "Bar" + ]], + ["constant", [ + "Baz", + ["punctuation", "."], + "Foobar_42" + ]] ] ---------------------------------------------------- -Checks for constants. \ No newline at end of file +Checks for constants. diff --git a/tests/languages/idris/hvariable_feature.test b/tests/languages/idris/hvariable_feature.test index defa3ba74d..048ac84ec9 100644 --- a/tests/languages/idris/hvariable_feature.test +++ b/tests/languages/idris/hvariable_feature.test @@ -5,11 +5,19 @@ Baz.foobar_42 ---------------------------------------------------- [ - ["hvariable", "foo"], - ["hvariable", "Foo.bar"], - ["hvariable", "Baz.foobar_42"] + ["hvariable", ["foo"]], + ["hvariable", [ + "Foo", + ["punctuation", "."], + "bar" + ]], + ["hvariable", [ + "Baz", + ["punctuation", "."], + "foobar_42" + ]] ] ---------------------------------------------------- -Checks for hvariables. \ No newline at end of file +Checks for hvariables. diff --git a/tests/languages/idris/import_statement_feature.test b/tests/languages/idris/import_statement_feature.test index 6d647d9234..5554b07990 100644 --- a/tests/languages/idris/import_statement_feature.test +++ b/tests/languages/idris/import_statement_feature.test @@ -4,7 +4,7 @@ import Foo [ ["keyword", "import"], - ["constant", "Foo"] + ["constant", ["Foo"]] ] ---------------------------------------------------- diff --git a/tests/languages/idris/operator_feature.test b/tests/languages/idris/operator_feature.test index 928fdb411f..19486493b6 100644 --- a/tests/languages/idris/operator_feature.test +++ b/tests/languages/idris/operator_feature.test @@ -17,21 +17,58 @@ reverse . sort [ ["operator", ".."], - ["hvariable", "reverse"], ["operator", " . "], ["hvariable", "sort"], + + ["hvariable", ["reverse"]], + ["operator", "."], + ["hvariable", ["sort"]], + ["operator", "`foo`"], + ["operator", "`Foo.bar`"], - ["operator", "+"], ["operator", "-"], ["operator", "*"], ["operator", "/"], - ["operator", "^"], ["operator", "^^"], ["operator", "**"], - ["operator", "&&"], ["operator", "||"], - ["operator", "<"], ["operator", "<="], ["operator", "=="], ["operator", "/="], - ["operator", ">="], ["operator", ">"], ["operator", "\\"], ["operator", "|"], - ["operator", "++"], ["operator", ":"], ["operator", "!!"], - ["operator", "\\\\"], ["operator", "<-"], ["operator", "->"], - ["operator", "="], ["operator", "::"], ["operator", "=>"], - ["operator", ">>"], ["operator", ">>="], ["operator", ">@>"], - ["operator", "~"], ["operator", "!"], ["operator", "@"] + + ["operator", "+"], + ["operator", "-"], + ["operator", "*"], + ["operator", "/"], + + ["operator", "^"], + ["operator", "^^"], + ["operator", "**"], + + ["operator", "&&"], + ["operator", "||"], + + ["operator", "<"], + ["operator", "<="], + ["operator", "=="], + ["operator", "/="], + + ["operator", ">="], + ["operator", ">"], + ["operator", "\\"], + ["operator", "|"], + + ["operator", "++"], + ["operator", ":"], + ["operator", "!!"], + + ["operator", "\\\\"], + ["operator", "<-"], + ["operator", "->"], + + ["operator", "="], + ["operator", "::"], + ["operator", "=>"], + + ["operator", ">>"], + ["operator", ">>="], + ["operator", ">@>"], + + ["operator", "~"], + ["operator", "!"], + ["operator", "@"] ] ---------------------------------------------------- -Checks for operators. \ No newline at end of file +Checks for operators. diff --git a/tests/languages/purescript/constant_feature.test b/tests/languages/purescript/constant_feature.test index 06f25f10e5..39ea0c114e 100644 --- a/tests/languages/purescript/constant_feature.test +++ b/tests/languages/purescript/constant_feature.test @@ -5,11 +5,19 @@ Baz.Foobar_42 ---------------------------------------------------- [ - ["constant", "Foo"], - ["constant", "Foo.Bar"], - ["constant", "Baz.Foobar_42"] + ["constant", ["Foo"]], + ["constant", [ + "Foo", + ["punctuation", "."], + "Bar" + ]], + ["constant", [ + "Baz", + ["punctuation", "."], + "Foobar_42" + ]] ] ---------------------------------------------------- -Checks for constants. \ No newline at end of file +Checks for constants. diff --git a/tests/languages/purescript/hvariable_feature.test b/tests/languages/purescript/hvariable_feature.test index defa3ba74d..048ac84ec9 100644 --- a/tests/languages/purescript/hvariable_feature.test +++ b/tests/languages/purescript/hvariable_feature.test @@ -5,11 +5,19 @@ Baz.foobar_42 ---------------------------------------------------- [ - ["hvariable", "foo"], - ["hvariable", "Foo.bar"], - ["hvariable", "Baz.foobar_42"] + ["hvariable", ["foo"]], + ["hvariable", [ + "Foo", + ["punctuation", "."], + "bar" + ]], + ["hvariable", [ + "Baz", + ["punctuation", "."], + "foobar_42" + ]] ] ---------------------------------------------------- -Checks for hvariables. \ No newline at end of file +Checks for hvariables. diff --git a/tests/languages/purescript/import_statement_feature.test b/tests/languages/purescript/import_statement_feature.test index 1a09337f63..b7e3f0a729 100644 --- a/tests/languages/purescript/import_statement_feature.test +++ b/tests/languages/purescript/import_statement_feature.test @@ -10,25 +10,36 @@ import Foo.Bar (test) ["keyword", "import"], " Foo" ]], + ["import-statement", [ ["keyword", "import"], - " Foo_42.Bar ", + " Foo_42", + ["punctuation", "."], + "Bar ", ["keyword", "as"], " Foobar" ]], + ["import-statement", [ ["keyword", "import"], - " Foo.Bar ", + " Foo", + ["punctuation", "."], + "Bar ", ["keyword", "as"], - " Foo.Baz ", + " Foo", + ["punctuation", "."], + "Baz ", ["keyword", "hiding"] ]], + ["import-statement", [ - ["keyword", "import"], - " Foo.Bar" + ["keyword", "import"], + " Foo", + ["punctuation", "."], + "Bar" ]], ["punctuation", "("], - ["hvariable", "test"], + ["hvariable", ["test"]], ["punctuation", ")"] ] diff --git a/tests/languages/purescript/issue3006.test b/tests/languages/purescript/issue3006.test new file mode 100644 index 0000000000..bf8dfbe384 --- /dev/null +++ b/tests/languages/purescript/issue3006.test @@ -0,0 +1,161 @@ +readBooleanOrIntAsBoolean ∷ Foreign → Foreign.F Boolean +readBooleanOrIntAsBoolean value = + Foreign.readBoolean value + <|> (toBool =<< Foreign.readInt value) + where + toBool ∷ Int → Foreign.F Boolean + toBool = case _ of + 0 → pure false + 1 → pure true + int → Foreign.fail (Foreign.ForeignError ("Invalid integer: " <> show int)) + +isSuccessResponse ∷ ∀ a. AX.Response a → Boolean +isSuccessResponse { status } = status >= (StatusCode 200) && status < (StatusCode 400) + +infix 4 eq as ≡ + +isMempty ∷ ∀ m. Monoid m → Boolean +isMempty = _ ≡ mempty + +---------------------------------------------------- + +[ + ["hvariable", ["readBooleanOrIntAsBoolean"]], + ["operator", "∷"], + ["constant", ["Foreign"]], + ["operator", "→"], + ["constant", [ + "Foreign", + ["punctuation", "."], + "F" + ]], + ["constant", ["Boolean"]], + + ["hvariable", ["readBooleanOrIntAsBoolean"]], + ["hvariable", ["value"]], + ["operator", "="], + + ["hvariable", [ + "Foreign", + ["punctuation", "."], + "readBoolean" + ]], + ["hvariable", ["value"]], + + ["operator", "<|>"], + ["punctuation", "("], + ["hvariable", ["toBool"]], + ["operator", "=<<"], + ["hvariable", [ + "Foreign", + ["punctuation", "."], + "readInt" + ]], + ["hvariable", ["value"]], + ["punctuation", ")"], + + ["keyword", "where"], + + ["hvariable", ["toBool"]], + ["operator", "∷"], + ["constant", ["Int"]], + ["operator", "→"], + ["constant", [ + "Foreign", + ["punctuation", "."], + "F" + ]], + ["constant", ["Boolean"]], + + ["hvariable", ["toBool"]], + ["operator", "="], + ["keyword", "case"], + ["hvariable", ["_"]], + ["keyword", "of"], + + ["number", "0"], + ["operator", "→"], + ["hvariable", ["pure"]], + ["hvariable", ["false"]], + + ["number", "1"], + ["operator", "→"], + ["hvariable", ["pure"]], + ["hvariable", ["true"]], + + ["hvariable", ["int"]], + ["operator", "→"], + ["hvariable", [ + "Foreign", + ["punctuation", "."], + "fail" + ]], + ["punctuation", "("], + ["constant", [ + "Foreign", + ["punctuation", "."], + "ForeignError" + ]], + ["punctuation", "("], + ["string", "\"Invalid integer: \""], + ["operator", "<>"], + ["builtin", "show"], + ["hvariable", ["int"]], + ["punctuation", ")"], + ["punctuation", ")"], + + ["hvariable", ["isSuccessResponse"]], + ["operator", "∷"], + ["keyword", "∀"], + ["hvariable", ["a"]], + ["punctuation", "."], + ["constant", [ + "AX", + ["punctuation", "."], + "Response" + ]], + ["hvariable", ["a"]], + ["operator", "→"], + ["constant", ["Boolean"]], + + ["hvariable", ["isSuccessResponse"]], + ["punctuation", "{"], + ["hvariable", ["status"]], + ["punctuation", "}"], + ["operator", "="], + ["hvariable", ["status"]], + ["operator", ">="], + ["punctuation", "("], + ["constant", ["StatusCode"]], + ["number", "200"], + ["punctuation", ")"], + ["operator", "&&"], + ["hvariable", ["status"]], + ["operator", "<"], + ["punctuation", "("], + ["constant", ["StatusCode"]], + ["number", "400"], + ["punctuation", ")"], + + ["hvariable", ["infix"]], + ["number", "4"], + ["builtin", "eq"], + ["hvariable", ["as"]], + ["operator", "≡"], + + ["hvariable", ["isMempty"]], + ["operator", "∷"], + ["keyword", "∀"], + ["hvariable", ["m"]], + ["punctuation", "."], + ["constant", ["Monoid"]], + ["hvariable", ["m"]], + ["operator", "→"], + ["constant", ["Boolean"]], + + ["hvariable", ["isMempty"]], + ["operator", "="], + ["hvariable", ["_"]], + ["operator", "≡"], + ["builtin", "mempty"] +] diff --git a/tests/languages/purescript/operator_feature.test b/tests/languages/purescript/operator_feature.test index b29cf529fa..9789ee881e 100644 --- a/tests/languages/purescript/operator_feature.test +++ b/tests/languages/purescript/operator_feature.test @@ -13,47 +13,86 @@ reverse <<< sort >> >>= >@> ~ ! @ +∷ +→ ← +⇒ ⇐ +∘ + +∘ × ÷ ≡ ≠ ⫽ ⩓ ⩔ ∧ ∨ ↝ ⨁ ⊹ + ---------------------------------------------------- [ - ["operator", ".."], - ["hvariable", "reverse"], - ["operator", "<<<"], - ["hvariable", "sort"], - ["operator", "`foo`"], - ["operator", "`Foo.bar`"], - ["operator", "+"], - ["operator", "-"], - ["operator", "*"], - ["operator", "/"], - ["operator", "^"], - ["operator", "^^"], - ["operator", "**"], - ["operator", "&&"], - ["operator", "||"], - ["operator", "<"], - ["operator", "<="], - ["operator", "=="], - ["operator", "/="], - ["operator", ">="], - ["operator", ">"], - ["operator", "\\"], - ["operator", "|"], - ["operator", "++"], - ["operator", ":"], - ["operator", "!!"], - ["operator", "\\\\"], - ["operator", "<-"], - ["operator", "->"], - ["operator", "="], - ["operator", "::"], - ["operator", "=>"], - ["operator", ">>"], - ["operator", ">>="], - ["operator", ">@>"], - ["operator", "~"], - ["operator", "!"], - ["operator", "@"] + ["operator", ".."], + + ["hvariable", ["reverse"]], + ["operator", "<<<"], + ["hvariable", ["sort"]], + + ["operator", "`foo`"], + + ["operator", "`Foo.bar`"], + + ["operator", "+"], + ["operator", "-"], + ["operator", "*"], + ["operator", "/"], + + ["operator", "^"], + ["operator", "^^"], + ["operator", "**"], + + ["operator", "&&"], + ["operator", "||"], + + ["operator", "<"], + ["operator", "<="], + ["operator", "=="], + ["operator", "/="], + + ["operator", ">="], + ["operator", ">"], + ["operator", "\\"], + ["operator", "|"], + + ["operator", "++"], + ["operator", ":"], + ["operator", "!!"], + + ["operator", "\\\\"], + ["operator", "<-"], + ["operator", "->"], + + ["operator", "="], + ["operator", "::"], + ["operator", "=>"], + + ["operator", ">>"], + ["operator", ">>="], + ["operator", ">@>"], + + ["operator", "~"], + ["operator", "!"], + ["operator", "@"], + + ["operator", "∷"], + ["operator", "→"], ["operator", "←"], + ["operator", "⇒"], ["operator", "⇐"], + ["operator", "∘"], + + ["operator", "∘"], + ["operator", "×"], + ["operator", "÷"], + ["operator", "≡"], + ["operator", "≠"], + ["operator", "⫽"], + ["operator", "⩓"], + ["operator", "⩔"], + ["operator", "∧"], + ["operator", "∨"], + ["operator", "↝"], + ["operator", "⨁"], + ["operator", "⊹"] ] ----------------------------------------------------