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
module Bug where | |
type Adress = {city :: String} | |
type Person = {adress::Adress} | |
getCity :: Person -> String | |
getCity { adress = {city = c} } = c | |
billy = {adress: {city : "SFO" }} |
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 toSystemPath (s:String) = s.Split([|'/'|])|> String.concat (System.IO.Path.DirectorySeparatorChar.ToString()) |
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 DataTipElement(wrapped:obj) = | |
member x.Wrapped = wrapped | |
let (|DataTipElementNone|DataTipElement|DataTipElementGroup|DataTipElementCompositionError|) (el:DataTipElement) = | |
if el.Wrapped?IsDataTipElementNone then | |
DataTipElementNone | |
elif el.Wrapped?IsDataTipElement then | |
let (s:string) = el.Wrapped?Item1 | |
let xml = XmlComment(el.Wrapped?Item2) | |
DataTipElement(s, xml) |
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
module test = | |
open Zipper | |
let t = Branch("a", Branch("b", Leaf, Branch("c", Leaf, Leaf)), Leaf) | |
let focus1 = t |> fromTree |> move [Left;Right] | |
let same1 = t |> fromTree |> move [Left;Right;Right;Up;Up;Up] | |
let same2 = t |> fromTree |> move [Left;Right;Right] |> Zipper.top | |
let xx = focus1 |> top | |
let newz = {(move [Left;Right;Right] xx) with focus = t} |> top |
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
[<CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>] | |
module Zipper = | |
let up z = match z.path with | |
| (d,v,other)::ep -> match d with | |
| TDirection.Left -> {focus=Branch(v,z.focus,other); path=ep} | |
| TDirection.Right -> {focus=Branch(v,other,z.focus); path=ep} | |
| [] -> failwith "can't go up" // because ep only goes down and is empty | |
let rec top z = match z.path with [] -> z | _ -> top (up z) |
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 'a Zipper = { focus:'a Tree; path: (TDirection * 'a * 'a Tree) list} | |
type ZDirection = Up | Left | Right |
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 insertBST x = function | |
| Leaf -> Branch(x , Leaf, Leaf) | |
| Branch(v, l, r) when x < v -> Branch(v, insertBST x l, r ) | |
| Branch(v, l, r) as b when x > v -> Branch(v, l, insertBST x r ) | |
| b -> b |
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 'a Tree= | |
| Leaf | |
| Branch of 'a * 'a Tree * 'a Tree |
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
//This script generates | |
//a file named __project.fsx, for each proejct which can be #load "__project.fsx" in script intending to use the same dependency graph as the code in VS | |
//a file named __solmerged.fsx, at the solution root which can be #load "__solmerged.fsx" in script intending to use the same dependency graph as the code in VS | |
//In both cases, this enforce that a script compiling in VS should work from within FSI | |
#if INTERACTIVE | |
#r "System.Xml" | |
#r "System.Xml.Linq" | |
#endif |
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
#if INTERACTIVE | |
#r "System.Xml" | |
#r "System.Xml.Linq" | |
#endif | |
open System | |
open System.IO | |
open System.Xml.Linq | |
open System.Text.RegularExpressions |