This file contains hidden or 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
-- decode.enable1.stm.hs | |
-- inspired by a word guessing game | |
-- https://www.futurelearn.com/courses/functional-programming-haskell/1/steps/116475 | |
import qualified Data.ByteString.Lazy as BL | |
import qualified Data.ByteString as B | |
import Data.Binary.Get | |
import Data.Word | |
This file contains hidden or 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
-- https://www.youtube.com/watch?v=r_Enynu_TV0 | |
-- Hey, I parsed the largest JSON on my hard drive! | |
import Text.ParserCombinators.Parsec hiding ((<|>),many) | |
import Control.Applicative | |
import Control.Monad | |
matchTrue :: Parser String | |
matchTrue = string "true" | |
alwaysTrue :: Parser Bool |
This file contains hidden or 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
// from http://stackoverflow.com/questions/21194565/null-coalescing-operator-in-f | |
// modified to support DBNull | |
open System | |
let inline isNull value = obj.ReferenceEquals(value, null) | |
let inline isDBNull value = obj.ReferenceEquals(value, DBNull.Value) | |
type NullCoalesce = | |
static member Coalesce(a: 'a option, b: 'a Lazy) = match a with Some a -> a | _ -> b.Value | |
static member Coalesce(a: 'a Nullable, b: 'a Lazy) = if a.HasValue then a.Value else b.Value |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
NewerOlder