forked from PrismJS/prism
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added PureScript language definition (PrismJS#2526)
- Loading branch information
1 parent
4de3d29
commit b04ab91
Showing
19 changed files
with
448 additions
and
3 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
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': { | ||
// The imported or hidden names are not included in this import | ||
// statement. This is because we want to highlight those exactly like | ||
// we do for the names in the program. | ||
pattern: /(^\s*)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/ | ||
} | ||
}, | ||
|
||
// 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/, | ||
}); | ||
|
||
Prism.languages.purs = Prism.languages.purescript; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<h2>Comments</h2> | ||
<pre><code>-- Single line comment | ||
{- Multi-line | ||
comment -}</code></pre> | ||
|
||
<h2>Strings and characters</h2> | ||
<pre><code>'a' | ||
'\n' | ||
'\^A' | ||
'\^]' | ||
'\NUL' | ||
'\23' | ||
'\o75' | ||
'\xFE' | ||
"Here is a backslant \\ as well as \137, \ | ||
\a numeric escape character, and \^X, a control character."</code></pre> | ||
|
||
<h2>Numbers</h2> | ||
<pre><code>42 | ||
123.456 | ||
123.456e-789 | ||
1e+3 | ||
0o74 | ||
0XAF</code></pre> | ||
|
||
<h2>Full example</h2> | ||
<pre><code>module Codewars.Kata.SumFracts (sumFracts) where | ||
|
||
import Prelude | ||
|
||
import Data.Foldable (foldl) | ||
import Data.BigInt (BigInt, fromInt, toString) | ||
import Data.List (List, length) | ||
import Data.Tuple (Tuple(..)) | ||
import Data.Maybe (Maybe(..)) | ||
import Data.Ord (abs, signum) | ||
|
||
reduce :: Tuple BigInt BigInt -> Tuple BigInt BigInt | ||
reduce (Tuple num den) = | ||
let gcd' = gcd num den | ||
den' = den / gcd' | ||
in Tuple (num / gcd' * (signum den')) (abs den') | ||
|
||
sumFracts :: List (Tuple Int Int) -> Maybe String | ||
sumFracts fracts = | ||
let fracts' = fracts <#> (\(Tuple n d) -> Tuple (fromInt n) (fromInt d)) >>> reduce | ||
|
||
den = foldl (\acc (Tuple _ d) -> lcm acc d) one fracts' | ||
num = foldl (\acc (Tuple n d) -> acc + n * (den / d)) zero fracts' | ||
|
||
Tuple n d = reduce $ Tuple num den | ||
|
||
in if length fracts == 0 | ||
then Nothing | ||
else if d == one | ||
then Just $ toString n | ||
else Just $ (toString n) >< " " >< (toString d)</code></pre> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.