diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index 9c754c96..43ac7a83 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -63,6 +63,16 @@ Ada: - .adb - .ads +ApacheConf: + type: markup + aliases: + - apache + primary_extension: .conf + filenames: + - .htaccess + - httpd.conf + - apache2.conf + Apex: type: programming lexer: Text only @@ -180,8 +190,10 @@ C++: - cpp primary_extension: .cpp extensions: + - .C - .c++ - .cxx + - .H - .h++ - .hh - .hxx @@ -244,6 +256,7 @@ CoffeeScript: color: "#244776" aliases: - coffee + - coffee-script primary_extension: .coffee extensions: - ._coffee @@ -392,6 +405,12 @@ Elixir: - .ex - .exs +Elm: + type: programming + lexer: Haskell + group: Haskell + primary_extension: .elm + Emacs Lisp: type: programming lexer: Scheme @@ -545,6 +564,8 @@ Groovy Server Pages: HTML: type: markup ace_mode: html + aliases: + - xhtml primary_extension: .html extensions: - .htm @@ -563,6 +584,8 @@ HTML+ERB: type: markup group: HTML lexer: RHTML + aliases: + - erb primary_extension: .erb extensions: - .erb @@ -575,16 +598,9 @@ HTML+PHP: extensions: - .phtml -HaXe: - type: programming - lexer: haXe - ace_mode: haxe - color: "#346d51" - primary_extension: .hx - extensions: - - .hx - - .hxml - - .mtt +HTTP: + type: data + primary_extension: .http Haml: group: HTML @@ -599,6 +615,15 @@ Haskell: - .hs - .hsc +Haxe: + type: programming + lexer: haXe + ace_mode: haxe + color: "#346d51" + primary_extension: .hx + extensions: + - .hxsl + INI: type: data extensions: @@ -723,6 +748,8 @@ Lua: - .nse Makefile: + aliases: + - make extensions: - .mak - .mk @@ -798,6 +825,13 @@ Nemerle: color: "#0d3c6e" primary_extension: .n +Nginx: + type: markup + lexer: Nginx configuration file + primary_extension: .conf + filenames: + - nginx.conf + Nimrod: type: programming color: "#37775b" @@ -843,6 +877,9 @@ ObjDump: Objective-C: type: programming color: "#438eff" + aliases: + - obj-c + - objc primary_extension: .m extensions: - .mm @@ -850,6 +887,8 @@ Objective-C: Objective-J: type: programming color: "#ff0c5a" + aliases: + - obj-j primary_extension: .j extensions: - .j @@ -1126,7 +1165,13 @@ Shell: primary_extension: .sh filenames: - .zsh + - bash_logout + - bash_profile - bashrc + - zlogin + - zlogout + - zshenv + - zprofile - zshrc Smalltalk: @@ -1172,6 +1217,8 @@ Tcsh: TeX: type: markup ace_mode: latex + aliases: + - latex primary_extension: .tex extensions: - .aux @@ -1261,6 +1308,11 @@ Visual Basic: XML: type: markup ace_mode: xml + aliases: + - rss + - xsd + - xsl + - wsdl primary_extension: .xml extensions: - .glade @@ -1306,6 +1358,8 @@ XSLT: YAML: type: markup + aliases: + - yml primary_extension: .yml extensions: - .yaml diff --git a/lib/linguist/samples.json b/lib/linguist/samples.json index a6a3c827..acd866c5 100644 --- a/lib/linguist/samples.json +++ b/lib/linguist/samples.json @@ -44,6 +44,9 @@ "Ecl": [ ".ecl" ], + "Elm": [ + ".elm" + ], "Emacs Lisp": [ ".el" ], @@ -140,7 +143,8 @@ ], "PHP": [ ".module", - ".php" + ".php", + ".script!" ], "PowerShell": [ ".ps1", @@ -260,8 +264,8 @@ ".gemrc" ] }, - "tokens_total": 271188, - "languages_total": 276, + "tokens_total": 271826, + "languages_total": 281, "tokens": { "Apex": { "global": 70, @@ -9238,6 +9242,123 @@ "a": 1, "self": 1 }, + "Elm": { + "import": 3, + "List": 1, + "(": 119, + "intercalate": 2, + "intersperse": 3, + ")": 116, + "Website.Skeleton": 1, + "Website.ColorScheme": 1, + "addFolder": 4, + "folder": 2, + "lst": 6, + "let": 2, + "add": 2, + "x": 13, + "y": 7, + "+": 14, + "in": 2, + "f": 8, + "n": 2, + "xs": 9, + "map": 11, + "elements": 2, + "[": 31, + "]": 31, + "functional": 2, + "reactive": 2, + "-": 11, + "example": 3, + "name": 6, + "loc": 2, + "Text.link": 1, + "toText": 6, + "toLinks": 2, + "title": 2, + "links": 2, + "flow": 4, + "right": 8, + "width": 3, + "text": 4, + "italic": 1, + "bold": 2, + ".": 9, + "Text.color": 1, + "accent4": 1, + "insertSpace": 2, + "case": 5, + "of": 7, + "{": 1, + "spacer": 2, + ";": 1, + "}": 1, + "subsection": 2, + "w": 7, + "info": 2, + "down": 3, + "words": 2, + "markdown": 1, + "|": 3, + "###": 1, + "Basic": 1, + "Examples": 1, + "Each": 1, + "listed": 1, + "below": 1, + "focuses": 1, + "on": 1, + "a": 5, + "single": 1, + "function": 1, + "or": 1, + "concept.": 1, + "These": 1, + "examples": 1, + "demonstrate": 1, + "all": 1, + "the": 1, + "basic": 1, + "building": 1, + "blocks": 1, + "Elm.": 1, + "content": 2, + "exampleSets": 2, + "plainText": 1, + "main": 3, + "lift": 1, + "skeleton": 1, + "Window.width": 1, + "asText": 1, + "qsort": 4, + "filter": 2, + "<)x)>": 1, + "data": 1, + "Tree": 3, + "Node": 8, + "Empty": 8, + "empty": 2, + "singleton": 2, + "v": 8, + "insert": 4, + "tree": 7, + "left": 7, + "if": 2, + "then": 2, + "else": 2, + "<": 1, + "fromList": 3, + "foldl": 1, + "depth": 5, + "max": 1, + "t1": 2, + "t2": 3, + "display": 4, + "monospace": 1, + "concat": 1, + "show": 2 + }, "Emacs Lisp": { "(": 1, "print": 1, @@ -21629,13 +21750,13 @@ "AUTHOR": 1 }, "PHP": { - "<": 9, - "php": 6, + "<": 11, + "php": 8, "namespace": 28, "Symfony": 24, "Component": 24, "Console": 17, - ";": 1380, + ";": 1382, "use": 23, "Input": 6, "InputInterface": 4, @@ -22647,7 +22768,9 @@ "nest": 1, "isUnique": 1, "is_bool": 1, - "sql": 1 + "sql": 1, + "SHEBANG#!php": 2, + "echo": 2 }, "PowerShell": { "Write": 2, @@ -27753,6 +27876,7 @@ "Delphi": 30, "Diff": 16, "Ecl": 281, + "Elm": 628, "Emacs Lisp": 3, "GAS": 133, "Gosu": 413, @@ -27781,7 +27905,7 @@ "Parrot Assembly": 6, "Parrot Internal Representation": 5, "Perl": 17113, - "PHP": 20637, + "PHP": 20647, "PowerShell": 12, "Prolog": 4040, "Python": 4020, @@ -27824,6 +27948,7 @@ "Delphi": 1, "Diff": 1, "Ecl": 1, + "Elm": 3, "Emacs Lisp": 1, "GAS": 1, "Gosu": 5, @@ -27852,7 +27977,7 @@ "Parrot Assembly": 1, "Parrot Internal Representation": 1, "Perl": 13, - "PHP": 6, + "PHP": 8, "PowerShell": 2, "Prolog": 6, "Python": 4, @@ -27881,5 +28006,5 @@ "XSLT": 1, "YAML": 1 }, - "md5": "384f02c0bd223479bf750d4cd36daf71" + "md5": "ef9b9c6f8312a9f029edf9b7df6e9751" } \ No newline at end of file diff --git a/samples/Elm/Basic.elm b/samples/Elm/Basic.elm new file mode 100644 index 00000000..ea6f61cb --- /dev/null +++ b/samples/Elm/Basic.elm @@ -0,0 +1,127 @@ + +import List (intercalate,intersperse) +import Website.Skeleton +import Website.ColorScheme + +addFolder folder lst = + let add (x,y) = (x, folder ++ y ++ ".elm") in + let f (n,xs) = (n, map add xs) in + map f lst + +elements = addFolder "Elements/" + [ ("Primitives", + [ ("Text" , "HelloWorld") + , ("Images", "Image") + , ("Fitted Images", "FittedImage") + , ("Videos", "Video") + , ("Markdown", "Markdown") + ]) + , ("Formatting", + [ ("Size" , "Size") + , ("Opacity" , "Opacity") + , ("Text" , "Text") + , ("Typeface", "Typeface") + ]) + , ("Layout", + [ ("Simple Flow", "FlowDown1a") + , ("Flow Down" , "FlowDown2") + , ("Layers" , "Layers") + , ("Positioning", "Position") + , ("Spacers" , "Spacer") + ]) + , ("Collage", [ ("Lines" , "Lines") + , ("Shapes" , "Shapes") + , ("Sprites" , "Sprite") + , ("Elements" , "ToForm") + , ("Colors" , "Color") + , ("Textures" , "Texture") + , ("Transforms", "Transforms") + ]) + ] + + +functional = addFolder "Functional/" + [ ("Recursion", + [ ("Factorial" , "Factorial") + , ("List Length", "Length") + , ("Zip" , "Zip") + , ("Quick Sort" , "QuickSort") + ]) + , ("Functions", + [ ("Anonymous Functions", "Anonymous") + , ("Application" , "Application") + , ("Composition" , "Composition") + , ("Infix Operators" , "Infix") + ]) + , ("Higher-Order", + [ ("Map" , "Map") + , ("Fold" , "Sum") + , ("Filter" , "Filter") + , ("ZipWith", "ZipWith") + ]) + , ("Data Types", + [ ("Maybe", "Maybe") + , ("Boolean Expressions", "BooleanExpressions") + , ("Tree", "Tree") + ]) + ] + +reactive = addFolder "Reactive/" + [ ("Mouse", [ ("Position", "Position") + , ("Presses" , "IsDown") + , ("Clicks" , "CountClicks") + , ("Position+Image", "ResizeYogi") + , ("Position+Collage" , "Transforms") + -- , ("Hover" , "IsAbove") + ]) + ,("Keyboard",[ ("Keys Down" , "KeysDown") + , ("Key Presses", "CharPressed") + ]) + , ("Window", [ ("Size", "ResizePaint") + , ("Centering", "Centering") + ]) + , ("Time", [ ("Before and After", "Between") + , ("Every" , "Every") + , ("Clock" , "Clock") + ]) + , ("Input", [ ("Text Fields", "TextField") + , ("Passwords" , "Password") + , ("Check Boxes", "CheckBox") + , ("String Drop Down", "StringDropDown") + , ("Drop Down", "DropDown") + ]) + , ("Random", [ ("Randomize", "Randomize") ]) + , ("HTTP", [ ("Zip Codes", "ZipCodes") ]) + , ("Filters",[ ("Sample", "SampleOn") + , ("Keep If", "KeepIf") + , ("Drop Repeats", "DropRepeats") + ]) + ] + +example (name, loc) = Text.link ("/edit/examples/" ++ loc) (toText name) +toLinks (title, links) = + flow right [ width 130 (text $ toText " " ++ italic (toText title)) + , text (intercalate (bold . Text.color accent4 $ toText " · ") $ map example links) + ] + +insertSpace lst = case lst of { x:xs -> x : spacer 1 5 : xs ; [] -> [] } + +subsection w (name,info) = + flow down . insertSpace . intersperse (spacer 1 1) . map (width w) $ + (text . bold $ toText name) : map toLinks info + +words = [markdown| + +### Basic Examples + +Each example listed below focuses on a single function or concept. +These examples demonstrate all of the basic building blocks of Elm. + +|] + +content w = + words : map (subsection w) [ ("Display",elements), ("React",reactive), ("Compute",functional) ] + +exampleSets w = flow down . map (width w) . intersperse (plainText " ") $ content w + +main = lift (skeleton exampleSets) Window.width diff --git a/samples/Elm/QuickSort.elm b/samples/Elm/QuickSort.elm new file mode 100644 index 00000000..8221d3fb --- /dev/null +++ b/samples/Elm/QuickSort.elm @@ -0,0 +1,32 @@ + +main = asText (qsort [3,9,1,8,5,4,7]) + +qsort lst = + case lst of + x:xs -> qsort (filter ((>=)x) xs) ++ [x] ++ qsort (filter ((<)x) xs) + [] -> [] + + +{--------------------- + +QuickSort works as follows: + - Choose a pivot element which be placed in the "middle" of the sorted list. + In our case we are choosing the first element as the pivot. + - Gather all of the elements less than the pivot (the first filter). + We know that these must come before our pivot element in the sorted list. + Note: ((>=)x) === (\y -> (>=) x y) === (\y -> x >= y) + - Gather all of the elements greater than the pivot (the second filter). + We know that these must come after our pivot element in the sorted list. + - Run `qsort` on the lesser elements, producing a sorted list that contains + only elements less than the pivot. Put these before the pivot. + - Run `qsort` on the greater elements, producing a sorted list. Put these + after the pivot. + +Note that choosing a bad pivot can have bad effects. Take a sorted list with +N elements. The pivot will always be the lowest member, meaning that it does +not divide the list very evenly. The list of lessers has 0 elements +and the list of greaters has N-1 elemens. This means qsort will be called +N times, each call looking through the entire list. This means, in the worst +case, QuickSort will make N^2 comparisons. + +----------------------} diff --git a/samples/Elm/Tree.elm b/samples/Elm/Tree.elm new file mode 100644 index 00000000..9e85d1c5 --- /dev/null +++ b/samples/Elm/Tree.elm @@ -0,0 +1,91 @@ + +{----------------------------------------------------------------- + +Overview: A "Tree" represents a binary tree. A "Node" in a binary +tree always has two children. A tree can also be "Empty". Below +I have defined "Tree" and a number of useful functions. + +This example also includes some challenge problems :) + +-----------------------------------------------------------------} + + +data Tree a = Node a (Tree a) (Tree a) | Empty + +empty = Empty +singleton v = Node v Empty Empty + +insert x tree = + case tree of + Empty -> singleton x + Node y left right -> + if x == y then tree else + if x < y then Node y (insert x left) right + else Node y left (insert x right) + +fromList xs = foldl insert empty xs + +depth tree = + case tree of + Node v left right -> 1 + max (depth left) (depth right) + Empty -> 0 + +map f tree = + case tree of + Node v left right -> Node (f v) (map f left) (map f right) + Empty -> Empty + +t1 = fromList [1,2,3] +t2 = fromList [2,1,3] + +main = flow down [ display "depth" depth t1 + , display "depth" depth t2 + , display "map ((+)1)" (map ((+)1)) t2 + ] + +display name f v = + text . monospace . toText $ + concat [ show (f v), " ⇐ ", name, " ", show v ] + +{----------------------------------------------------------------- + +Exercises: + +(1) Sum all of the elements of a tree. + + sum :: Tree Number -> Number + +(2) Flatten a tree into a list. + + flatten :: Tree a -> [a] + +(3) Check to see if an element is in a given tree. + + isElement :: a -> Tree a -> Bool + +(4) Write a general fold function that acts on trees. The fold + function does not need to guarantee a particular order of + traversal. + + fold :: (a -> b -> b) -> b -> Tree a -> b + +(5) Use "fold" to do exercises 1-3 in one line each. The best + readable versions I have come up have the following length + in characters including spaces and function name: + sum: 16 + flatten: 21 + isElement: 46 + See if you can match or beat me! Don't forget about currying + and partial application! + +(6) Can "fold" be used to implement "map" or "depth"? + +(7) Try experimenting with different ways to traverse a + tree: pre-order, in-order, post-order, depth-first, etc. + More info at: http://en.wikipedia.org/wiki/Tree_traversal + +-----------------------------------------------------------------} + + + + diff --git a/samples/PHP/php-script.script! b/samples/PHP/php-script.script! new file mode 100644 index 00000000..567b9a80 --- /dev/null +++ b/samples/PHP/php-script.script! @@ -0,0 +1,4 @@ +#!/usr/bin/php +