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
(****** works ******) | |
type foo = [`A of int | `B of int] | |
module type K = sig | |
type t | |
val value: t -> int | |
end | |
module J (K: K) = struct | |
let value = K.value | |
end | |
module FooJ = J(struct |
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
type _ foo = | |
| A : int -> int foo | |
| B : int -> int foo | |
module FooSet = Set.Make(struct | |
type t | |
let compare a b = | |
let a' = match a with A x -> x | B x -> x in | |
let b' = match b with A x -> x | B x -> x in | |
Pervasives.compare a' b' | |
end) |
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
let rec sweep responsibility t = | |
let neighbors = of_list t.members | |
|> filter (G.bounds %> extentEligible) | |
|> filter (distinct seenMembers G.bounds) in | |
|> persistent | |
if not @@ is_empty neighbors | |
then neighbors | |
else do_something_else |
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
open Containers | |
let _ = let lst = [1;2;3] in | |
let open Sequence in | |
let open Format in | |
let s = of_list lst in | |
if not @@ is_empty s | |
then print_endline "not empty"; | |
Format.printf "%a" (List.pp pp_print_int) (to_list s) | |
(* |
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
image: ocaml/opam2:ubuntu-lts | |
stages: | |
- build | |
- test | |
build: | |
# https://docs.gitlab.com/ee/ci/yaml/#cache | |
stage: build | |
cache: |
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
-- mostly ripped off from https://teh.id.au/posts/2017/02/13/interactive-print/index.html | |
:{ | |
:def pp (\_ -> return | |
$ unlines ["import qualified Text.Show.Pretty as SP", | |
"import qualified Language.Haskell.HsColour as HSC", | |
"import Language.Haskell.HsColour.Colourise (defaultColourPrefs)", | |
"_colorPrint = putStrLn . HSC.hscolour HSC.TTY defaultColourPrefs False False \"\" False . SP.ppShow", | |
":set -interactive-print _colorPrint"]) | |
:} |
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
class Foo a where | |
bar :: a -> String | |
instance {-# OVERLAPPING #-} Foo String where | |
bar = id | |
instance (Num a, Show a) => Foo a where | |
bar = show |
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
data Val = Val { foobar :: Int } deriving (Generic, Show) | |
instance JSON.FromJSON Val where | |
parseJSON = JSON.genericParseJSON | |
$ JSON.defaultOptions { JSON.fieldLabelModifier = filter (/= '-') } | |
{- | |
$ eitherDecode "{\"foo-bar\": 1}" :: Either String Val | |
Left "Error in $: key \"foobar\" not present" | |
-} |
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
data Validity = Invalid | Valid deriving (Eq, Show, Generic, NFData) | |
data Readiness = NotReady | Ready deriving (Eq, Show, Generic, NFData) | |
asValid x = if x then Valid else Invalid | |
asReady x = if x then Ready else NotReady | |
data DFIO a = DFIO { valid :: Validity, ready :: Readiness, val :: a } deriving (Eq, Show, Generic, NFData) | |
dfio iV oR dat = DFIO (asValid iV) (asReady oR) dat | |
pending placeholder = DFIO Invalid NotReady placeholder | |
done result = DFIO Valid Ready result |
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
;; Clutch provides a pretty comprehensive API, but I'm frustated that 95% of database | |
;; interactions require using something other than the typical Clojure vocabulary of | |
;; assoc/conj/dissoc/get/seq/reduce/etc, even though those semantics are entirely appropriate | |
;; (modulo the whole stateful database thing). | |
;; | |
;; This is (the start of) an attempt to create a type to provide most of the | |
;; functionality of Clutch with a more pleasant, concise API (it uses the Clutch API | |
;; under the covers, and rare operations would generally remain accessible only | |
;; at that lower level). | |
;; |