mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 09:40:21 +00:00
Merge pull request #1817 from pchaigno/fix-fs-heuristic
Fix .fs heuristic
This commit is contained in:
@@ -137,9 +137,9 @@ module Linguist
|
|||||||
disambiguate "F#", "Forth", "GLSL" do |data|
|
disambiguate "F#", "Forth", "GLSL" do |data|
|
||||||
if /^(: |new-device)/.match(data)
|
if /^(: |new-device)/.match(data)
|
||||||
Language["Forth"]
|
Language["Forth"]
|
||||||
elsif /^(#light|import|let|module|namespace|open|type)/.match(data)
|
elsif /^\s*(#light|import|let|module|namespace|open|type)/.match(data)
|
||||||
Language["F#"]
|
Language["F#"]
|
||||||
elsif /^(#include|#pragma|precision|uniform|varying|void)/.match(data)
|
elsif /^\s*(#include|#pragma|precision|uniform|varying|void)/.match(data)
|
||||||
Language["GLSL"]
|
Language["GLSL"]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
49
samples/F#/Combinators.fs
Normal file
49
samples/F#/Combinators.fs
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
namespace Nessos.FsPickler.Combinators
|
||||||
|
|
||||||
|
open Nessos.FsPickler
|
||||||
|
open Nessos.FsPickler.Json
|
||||||
|
|
||||||
|
/// Json pickling methods
|
||||||
|
[<RequireQualifiedAccess>]
|
||||||
|
module Json =
|
||||||
|
|
||||||
|
let private jsonSerializer = lazy(FsPickler.CreateJson(omitHeader = true))
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Pickles a value to Json.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="pickler">utilized pickler.</param>
|
||||||
|
/// <param name="value">input value.</param>
|
||||||
|
let pickle (pickler : Pickler<'T>) (value : 'T) : string =
|
||||||
|
jsonSerializer.Value.PickleToString (pickler, value)
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Unpickles a value from Json.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="pickler">utilized pickler.</param>
|
||||||
|
/// <param name="pickle">input pickle.</param>
|
||||||
|
let unpickle (pickler : Pickler<'T>) (pickle : string) : 'T =
|
||||||
|
jsonSerializer.Value.UnPickleOfString (pickler, pickle)
|
||||||
|
|
||||||
|
|
||||||
|
/// Bson pickling methods
|
||||||
|
[<RequireQualifiedAccess>]
|
||||||
|
module Bson =
|
||||||
|
|
||||||
|
let private bsonPickler = lazy(FsPickler.CreateBson())
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Pickles a value to Bson.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="pickler">utilized pickler.</param>
|
||||||
|
/// <param name="value">input value.</param>
|
||||||
|
let pickle (pickler : Pickler<'T>) (value : 'T) : byte [] =
|
||||||
|
bsonPickler.Value.Pickle (pickler, value)
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Unpickles a value from bson.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="pickler">utilized pickler.</param>
|
||||||
|
/// <param name="pickle">input pickle.</param>
|
||||||
|
let unpickle (pickler : Pickler<'T>) (pickle : byte []) : 'T =
|
||||||
|
bsonPickler.Value.UnPickle (pickler, pickle)
|
||||||
Reference in New Issue
Block a user