From a17f7d1cb2fbe1dd4015f9ead18eb2d09acd199a Mon Sep 17 00:00:00 2001 From: killmous Date: Sun, 27 Apr 2014 11:29:26 -0500 Subject: [PATCH 1/4] Added samples for Haskell --- samples/Haskell/Hello.hs | 6 +++++ samples/Haskell/Main.hs | 33 ++++++++++++++++++++++++++++ samples/Haskell/Sudoku.hs | 46 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 85 insertions(+) create mode 100644 samples/Haskell/Hello.hs create mode 100644 samples/Haskell/Main.hs create mode 100644 samples/Haskell/Sudoku.hs diff --git a/samples/Haskell/Hello.hs b/samples/Haskell/Hello.hs new file mode 100644 index 00000000..cef0b4a9 --- /dev/null +++ b/samples/Haskell/Hello.hs @@ -0,0 +1,6 @@ +import Data.Char + +main :: IO () +main = do + let hello = "hello world" + putStrLn $ map toUpper hello \ No newline at end of file diff --git a/samples/Haskell/Main.hs b/samples/Haskell/Main.hs new file mode 100644 index 00000000..4a37a8c0 --- /dev/null +++ b/samples/Haskell/Main.hs @@ -0,0 +1,33 @@ +module Main where + +import Sudoku +import Data.Maybe + + +sudoku :: Sudoku +sudoku = [8, 0, 1, 3, 4, 0, 0, 0, 0, + 4, 3, 0, 8, 0, 0, 1, 0, 7, + 0, 0, 0, 0, 6, 0, 0, 0, 3, + 2, 0, 8, 0, 5, 0, 0, 0, 9, + 0, 0, 9, 0, 0, 0, 7, 0, 0, + 6, 0, 0, 0, 7, 0, 8, 0, 4, + 3, 0, 0, 0, 1, 0, 0, 0, 0, + 1, 0, 5, 0, 0, 6, 0, 4, 2, + 0, 0, 0, 0, 2, 4, 3, 0, 8] + +{- +sudoku :: Sudoku +sudoku = [8, 6, 1, 3, 4, 7, 2, 9, 5, + 4, 3, 2, 8, 9, 5, 1, 6, 7, + 9, 5, 7, 1, 6, 2, 4, 8, 3, + 2, 7, 8, 4, 5, 1, 6, 3, 9, + 5, 4, 9, 6, 8, 3, 7, 2, 1, + 6, 1, 3, 2, 7, 9, 8, 5, 4, + 3, 2, 4, 9, 1, 8, 5, 7, 6, + 1, 8, 5, 7, 3, 6, 9, 4, 2, + 7, 9, 6, 5, 2, 4, 3, 1, 8] +-} +main :: IO () +main = do + putStrLn $ pPrint sudoku ++ "\n\n" + putStrLn $ pPrint $ fromMaybe [] $ solve sudoku \ No newline at end of file diff --git a/samples/Haskell/Sudoku.hs b/samples/Haskell/Sudoku.hs new file mode 100644 index 00000000..ca6122e3 --- /dev/null +++ b/samples/Haskell/Sudoku.hs @@ -0,0 +1,46 @@ +module Sudoku +( + Sudoku, + solve, + isSolved, + pPrint +) where + +import Data.Maybe +import Data.List +import Data.List.Split + +type Sudoku = [Int] + +solve :: Sudoku -> Maybe Sudoku +solve sudoku + | isSolved sudoku = Just sudoku + | otherwise = do + index <- elemIndex 0 sudoku + let sudokus = [nextTest sudoku index i | i <- [1..9], + checkRow (nextTest sudoku index i) index, + checkColumn (nextTest sudoku index i) index, + checkBox (nextTest sudoku index i) index] + listToMaybe $ mapMaybe solve sudokus + where nextTest sudoku index i = take index sudoku ++ [i] ++ drop (index+1) sudoku + checkRow sudoku index = (length $ getRow sudoku index) == (length $ nub $ getRow sudoku index) + checkColumn sudoku index = (length $ getColumn sudoku index) == (length $ nub $ getColumn sudoku index) + checkBox sudoku index = (length $ getBox sudoku index) == (length $ nub $ getBox sudoku index) + getRow sudoku index = filter (/=0) $ (chunksOf 9 sudoku) !! (quot index 9) + getColumn sudoku index = filter (/=0) $ (transpose $ chunksOf 9 sudoku) !! (mod index 9) + getBox sudoku index = filter (/=0) $ (map concat $ concatMap transpose $ chunksOf 3 $ map (chunksOf 3) $ chunksOf 9 sudoku) + !! (3 * (quot index 27) + (quot (mod index 9) 3)) + +isSolved :: Sudoku -> Bool +isSolved sudoku + | product sudoku == 0 = False + | map (length . nub) sudokuRows /= map length sudokuRows = False + | map (length . nub) sudokuColumns /= map length sudokuColumns = False + | map (length . nub) sudokuBoxes /= map length sudokuBoxes = False + | otherwise = True + where sudokuRows = chunksOf 9 sudoku + sudokuColumns = transpose sudokuRows + sudokuBoxes = map concat $ concatMap transpose $ chunksOf 3 $ map (chunksOf 3) $ chunksOf 9 sudoku + +pPrint :: Sudoku -> String +pPrint sudoku = intercalate "\n" $ map (intercalate " " . map show) $ chunksOf 9 sudoku \ No newline at end of file From 3c821318637dcc5e1f8c446d5c9b5f6c23714f8a Mon Sep 17 00:00:00 2001 From: Andrea Faulds Date: Mon, 28 Apr 2014 19:03:28 +0100 Subject: [PATCH 2/4] Gave GML a colour (its official colour) --- lib/linguist/languages.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index 70302378..c4490783 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -659,6 +659,7 @@ Frege: Game Maker Language: type: programming + color: "#8ad353" lexer: JavaScript primary_extension: .gml From f4a3636371a6edb6f72447eb527602db3536a961 Mon Sep 17 00:00:00 2001 From: Matt Brennan Date: Thu, 1 May 2014 09:33:05 +0100 Subject: [PATCH 3/4] Update PHP colour to reflect php.net Currently the PHP colour is very similar to C#, and seems to have been pull from thin air. PHP has a perfectly nice distinctive purple, used on [php.net](http://php.net) since forever. This pull request changes PHP's colour to a dark shade of that purple. Before | After -----------------------------------------|----------------------------------------- ![](http://www.colorhexa.com/6e03c1.png) | ![](http://www.colorhexa.com/4f5d95.png) --- lib/linguist/languages.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index 70302378..8a5cd7b0 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -1394,7 +1394,7 @@ PAWN: PHP: type: programming ace_mode: php - color: "#6e03c1" + color: "#4F5D95" primary_extension: .php extensions: - .aw From 49e27387b748429cca31bcd4c35e6abcbf21b086 Mon Sep 17 00:00:00 2001 From: Arfon Smith Date: Fri, 2 May 2014 13:16:58 -0500 Subject: [PATCH 4/4] Samples update --- lib/linguist/samples.json | 90 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 87 insertions(+), 3 deletions(-) diff --git a/lib/linguist/samples.json b/lib/linguist/samples.json index f174c9ab..a80a9d62 100644 --- a/lib/linguist/samples.json +++ b/lib/linguist/samples.json @@ -195,6 +195,9 @@ ".handlebars", ".hbs" ], + "Haskell": [ + ".hs" + ], "HTML": [ ".html", ".st" @@ -681,8 +684,8 @@ ".gemrc" ] }, - "tokens_total": 589756, - "languages_total": 713, + "tokens_total": 590058, + "languages_total": 716, "tokens": { "ABAP": { "*/**": 1, @@ -24917,6 +24920,85 @@ "": 1, "/each": 1 }, + "Haskell": { + "import": 6, + "Data.Char": 1, + "main": 4, + "IO": 2, + "(": 8, + ")": 8, + "do": 3, + "let": 2, + "hello": 2, + "putStrLn": 3, + "map": 13, + "toUpper": 1, + "module": 2, + "Main": 1, + "where": 4, + "Sudoku": 9, + "Data.Maybe": 2, + "sudoku": 36, + "[": 4, + "]": 3, + "pPrint": 5, + "+": 2, + "fromMaybe": 1, + "solve": 5, + "isSolved": 4, + "Data.List": 1, + "Data.List.Split": 1, + "type": 1, + "Int": 1, + "-": 3, + "Maybe": 1, + "|": 8, + "Just": 1, + "otherwise": 2, + "index": 27, + "<": 1, + "elemIndex": 1, + "sudokus": 2, + "nextTest": 5, + "i": 7, + "<->": 1, + "1": 2, + "9": 7, + "checkRow": 2, + "checkColumn": 2, + "checkBox": 2, + "listToMaybe": 1, + "mapMaybe": 1, + "take": 1, + "drop": 1, + "length": 12, + "getRow": 3, + "nub": 6, + "getColumn": 3, + "getBox": 3, + "filter": 3, + "0": 3, + "chunksOf": 10, + "quot": 3, + "transpose": 4, + "mod": 2, + "concat": 2, + "concatMap": 2, + "3": 4, + "27": 1, + "Bool": 1, + "product": 1, + "False": 4, + ".": 4, + "sudokuRows": 4, + "/": 3, + "sudokuColumns": 3, + "sudokuBoxes": 3, + "True": 1, + "String": 1, + "intercalate": 2, + "show": 1 + }, "HTML": { "": 2, "HTML": 2, @@ -62441,6 +62523,7 @@ "Groovy Server Pages": 91, "Haml": 4, "Handlebars": 69, + "Haskell": 302, "HTML": 413, "Hy": 155, "IDL": 418, @@ -62619,6 +62702,7 @@ "Groovy Server Pages": 4, "Haml": 1, "Handlebars": 2, + "Haskell": 3, "HTML": 2, "Hy": 2, "IDL": 4, @@ -62742,5 +62826,5 @@ "YAML": 2, "Zephir": 2 }, - "md5": "0ab9fe87b3d811ca32ad705d2653b98f" + "md5": "2fa5b83f62907994200462d10d4b7b70" } \ No newline at end of file