Turtle

Turtle graphics library implemented as an internal DSL, providing a very similar syntax to Logo, it is runnable inside TryFSharp.org.

Copy Source
Copy Link
Tools:
  1: Skip namespace definition on TryFSharp.org
  2: 
  3: open System
  4: open System.Windows
  5: open System.Windows.Controls
  6: open System.Windows.Media
  7: open System.Windows.Shapes
  8:     
  9: [<AutoOpen>]
 10: module AST =    
 11:     type reference = string
 12:     type distance = int
 13:     type degrees = int
 14:     type instruction =
 15:         | Forward of distance
 16:         | Left of degrees
 17:         | Right of degrees
 18:         | Repeat of int * instruction list    
 19:         | PenDown 
 20:         | PenUp
 21:         | PenColor of Color
 22:         | PenWidth of distance
 23:         | ClearScreen
 24:         | ShowTurtle
 25:         | HideTurtle
 26:     
 27: [<AutoOpen>]
 28: module Lang =
 29:     let forward n = Forward n
 30:     let fd = forward
 31:     let left n = Left n
 32:     let lt = left
 33:     let right n = Right n
 34:     let rt = right
 35:     let repeat n (instructions:instruction list) =
 36:         Repeat(n,instructions)
 37:     let once (instructions:instruction list) =
 38:         Repeat(1,instructions)
 39:     let run = once
 40:     let output x = x
 41:     let pencolor color = PenColor color
 42:     let penup = PenUp
 43:     let pendown = PenDown
 44:     let penwidth n = PenWidth n
 45:     let clearscreen = ClearScreen
 46:     let cs = clearscreen
 47:     let hideturtle = HideTurtle
 48:     let ht = hideturtle
 49:     let showturtle = ShowTurtle
 50:     let st = showturtle
 51:    
 52: [<AutoOpen>]
 53: module Colors =
 54:     let red = Colors.Red
 55:     let green = Colors.Green
 56:     let blue = Colors.Blue
 57:     let white = Colors.White
 58:     let black = Colors.Black
 59:     let gray = Colors.Gray
 60:     let yellow = Colors.Yellow
 61:     let orange = Colors.Orange
 62:     let brown = Colors.Brown
 63:     let cyan = Colors.Cyan
 64:     let magenta = Colors.Magenta
 65:     let purple = Colors.Purple
 66: 
 67: type Turtle private () =
 68:     inherit UserControl(Width = 400.0, Height = 300.0)    
 69:     let screen = Canvas(Background = SolidColorBrush Colors.Black)
 70:     do  base.Content <- screen
 71:     let mutable penColor = white
 72:     let mutable penWidth = 1.0
 73:     let mutable isPenDown = true
 74:     let mutable x, y = 0.0, 0.0
 75:     let mutable a = 270
 76:     let addLine (canvas:Canvas) x' y' =
 77:         let line = Line(X1=x,Y1=y,X2=x',Y2=y')
 78:         line.StrokeThickness <- penWidth
 79:         line.Stroke <- SolidColorBrush penColor 
 80:         canvas.Children.Add line
 81:     let clearLines () = screen.Children.Clear()
 82:     let turtle = Canvas()
 83:     let rotation = RotateTransform(Angle=float a)
 84:     do  turtle.RenderTransform <- rotation    
 85:     do  screen.Children.Add turtle
 86:     let rec execute canvas = function
 87:         | Forward n ->
 88:             let n = float n
 89:             let r = float a * Math.PI / 180.0
 90:             let dx, dy = float n * cos(r), float n * sin(r)
 91:             let x', y' = x + dx, y + dy
 92:             if isPenDown then addLine canvas x' y'
 93:             x <- x'
 94:             y <- y'
 95:         | Left n -> 
 96:             a <- a - n
 97:             rotation.Angle <- float a
 98:         | Right n -> 
 99:             a <- a + n
100:             rotation.Angle <- float a
101:         | Repeat(n,instructions) ->
102:             for i = 1 to n do
103:                 instructions |> List.iter (execute canvas)
104:         | PenDown -> isPenDown <- true
105:         | PenUp -> isPenDown <- false
106:         | PenColor color -> penColor <- color
107:         | PenWidth width -> penWidth <- float width
108:         | ClearScreen -> clearLines ()
109:         | ShowTurtle ->
110:             turtle.Visibility <- Visibility.Visible
111:         | HideTurtle ->
112:             turtle.Visibility <- Visibility.Collapsed
113:     let drawTurtle () =
114:         [penup; forward 5; pendown; 
115:          right 150;  forward 10; 
116:          right 120; forward 10; 
117:          right 120; forward 10; 
118:          right 150; penup; forward 5; right 180; pendown]
119:         |> List.iter (execute turtle)    
120:     do  drawTurtle ()
121:         x <- base.Width/2.0
122:         y <- base.Height/2.0
123:     do  Canvas.SetLeft(turtle,x)
124:         Canvas.SetTop(turtle,y)
125:     static let control = lazy(Turtle ())    
126:     member private this.Execute instruction = 
127:         execute screen instruction
128:     /// Turtle screen
129:     static member Screen = control.Force()    
130:     /// Runs turtle instruction
131:     static member Run (instruction:instruction) =
132:         let run () = control.Force().Execute instruction
133: #if INTERACTIVE
134:         App.Dispatch(fun () -> run ()) |> ignore
135: #else
136:         run ()
137: #endif
138:     /// Runs sequence of turtle instructions
139:     static member Run (instructions:instruction seq) =
140:         let run () = instructions |> Seq.iter (control.Force().Execute)
141: #if INTERACTIVE
142:         App.Dispatch(fun () -> run ()) |> ignore
143: #else
144:         run ()
145: #endif
146:         
147:     
148: Run script on TryFSharp.org
149: 
150: module Test =
151:    
152:     do  pencolor red
153:         |> Turtle.Run 
154:     
155:     do  [for a = 0 to 1000 do yield! [fd 6; rt (a*7)]]
156:         |> Turtle.Run
#if INTERACTIVE
open Microsoft.TryFSharp
#else
namespace Turtle
#endif
namespace System
namespace System.Windows
namespace System.Windows.Controls
namespace System.Windows.Media
namespace System.Windows.Shapes
type AutoOpenAttribute =
  class
    inherit Attribute
    new : unit -> AutoOpenAttribute
    new : path:string -> AutoOpenAttribute
    member Path : string
  end

Full name: Microsoft.FSharp.Core.AutoOpenAttribute

  type: AutoOpenAttribute
  implements: Runtime.InteropServices._Attribute
  inherits: Attribute
type reference = string

Full name: Snippet.AST.reference

  type: reference
  implements: IComparable
  implements: ICloneable
  implements: IConvertible
  implements: IComparable<string>
  implements: seq<char>
  implements: Collections.IEnumerable
  implements: IEquatable<string>
Multiple items
val string : 'T -> string

Full name: Microsoft.FSharp.Core.Operators.string

--------------------

type string = String

Full name: Microsoft.FSharp.Core.string

  type: string
  implements: IComparable
  implements: ICloneable
  implements: IConvertible
  implements: IComparable<string>
  implements: seq<char>
  implements: Collections.IEnumerable
  implements: IEquatable<string>
type distance = int

Full name: Snippet.AST.distance

  type: distance
  implements: IComparable
  implements: IFormattable
  implements: IConvertible
  implements: IComparable<int>
  implements: IEquatable<int>
  inherits: ValueType
Multiple items
val int : 'T -> int (requires member op_Explicit)

Full name: Microsoft.FSharp.Core.Operators.int

--------------------

type int<'Measure> = int

Full name: Microsoft.FSharp.Core.int<_>

  type: int<'Measure>
  implements: IComparable
  implements: IConvertible
  implements: IFormattable
  implements: IComparable<int<'Measure>>
  implements: IEquatable<int<'Measure>>
  inherits: ValueType


--------------------

type int = int32

Full name: Microsoft.FSharp.Core.int

  type: int
  implements: IComparable
  implements: IFormattable
  implements: IConvertible
  implements: IComparable<int>
  implements: IEquatable<int>
  inherits: ValueType
type degrees = int

Full name: Snippet.AST.degrees

  type: degrees
  implements: IComparable
  implements: IFormattable
  implements: IConvertible
  implements: IComparable<int>
  implements: IEquatable<int>
  inherits: ValueType
type instruction =
  | Forward of distance
  | Left of degrees
  | Right of degrees
  | Repeat of int * instruction list
  | PenDown
  | PenUp
  | PenColor of Color
  | PenWidth of distance
  | ClearScreen
  | ShowTurtle
  | HideTurtle

Full name: Snippet.AST.instruction

  type: instruction
  implements: IEquatable<instruction>
  implements: Collections.IStructuralEquatable
union case instruction.Forward: distance -> instruction
union case instruction.Left: degrees -> instruction
union case instruction.Right: degrees -> instruction
union case instruction.Repeat: int * instruction list -> instruction
type 'T list = List<'T>

Full name: Microsoft.FSharp.Collections.list<_>

  type: 'T list
  implements: Collections.IStructuralEquatable
  implements: IComparable<List<'T>>
  implements: IComparable
  implements: Collections.IStructuralComparable
  implements: Collections.Generic.IEnumerable<'T>
  implements: Collections.IEnumerable
union case instruction.PenDown: instruction
union case instruction.PenUp: instruction
union case instruction.PenColor: Color -> instruction
type Color =
  struct
    member A : System.Byte with get, set
    member B : System.Byte with get, set
    member Clamp : unit -> unit
    member ColorContext : System.Windows.Media.ColorContext
    member Equals : System.Windows.Media.Color -> bool
    member Equals : obj -> bool
    member G : System.Byte with get, set
    member GetHashCode : unit -> int
    member GetNativeColorValues : unit -> float32 []
    member R : System.Byte with get, set
    member ScA : float32 with get, set
    member ScB : float32 with get, set
    member ScG : float32 with get, set
    member ScR : float32 with get, set
    member ToString : unit -> string
    member ToString : System.IFormatProvider -> string
    static member Add : System.Windows.Media.Color * System.Windows.Media.Color -> System.Windows.Media.Color
    static member AreClose : System.Windows.Media.Color * System.Windows.Media.Color -> bool
    static member Equals : System.Windows.Media.Color * System.Windows.Media.Color -> bool
    static member FromAValues : float32 * float32 [] * System.Uri -> System.Windows.Media.Color
    static member FromArgb : System.Byte * System.Byte * System.Byte * System.Byte -> System.Windows.Media.Color
    static member FromRgb : System.Byte * System.Byte * System.Byte -> System.Windows.Media.Color
    static member FromScRgb : float32 * float32 * float32 * float32 -> System.Windows.Media.Color
    static member FromValues : float32 [] * System.Uri -> System.Windows.Media.Color
    static member Multiply : System.Windows.Media.Color * float32 -> System.Windows.Media.Color
    static member Subtract : System.Windows.Media.Color * System.Windows.Media.Color -> System.Windows.Media.Color
  end

Full name: System.Windows.Media.Color

  type: Color
  implements: IFormattable
  implements: IEquatable<Color>
  inherits: ValueType
union case instruction.PenWidth: distance -> instruction
union case instruction.ClearScreen: instruction
union case instruction.ShowTurtle: instruction
union case instruction.HideTurtle: instruction
val forward : distance -> instruction

Full name: Snippet.Lang.forward
val n : distance

  type: distance
  implements: IComparable
  implements: IFormattable
  implements: IConvertible
  implements: IComparable<int>
  implements: IEquatable<int>
  inherits: ValueType
val fd : (distance -> instruction)

Full name: Snippet.Lang.fd
val left : degrees -> instruction

Full name: Snippet.Lang.left
val n : degrees

  type: degrees
  implements: IComparable
  implements: IFormattable
  implements: IConvertible
  implements: IComparable<int>
  implements: IEquatable<int>
  inherits: ValueType
val lt : (degrees -> instruction)

Full name: Snippet.Lang.lt
val right : degrees -> instruction

Full name: Snippet.Lang.right
val rt : (degrees -> instruction)

Full name: Snippet.Lang.rt
val repeat : int -> instruction list -> instruction

Full name: Snippet.Lang.repeat
val n : int

  type: int
  implements: IComparable
  implements: IFormattable
  implements: IConvertible
  implements: IComparable<int>
  implements: IEquatable<int>
  inherits: ValueType
val instructions : instruction list

  type: instruction list
  implements: Collections.IStructuralEquatable
  implements: IComparable<List<instruction>>
  implements: IComparable
  implements: Collections.IStructuralComparable
  implements: Collections.Generic.IEnumerable<instruction>
  implements: Collections.IEnumerable
val once : instruction list -> instruction

Full name: Snippet.Lang.once
val run : (instruction list -> instruction)

Full name: Snippet.Lang.run
val output : 'a -> 'a

Full name: Snippet.Lang.output
val x : 'a
val pencolor : Color -> instruction

Full name: Snippet.Lang.pencolor
val color : Color

  type: Color
  implements: IFormattable
  implements: IEquatable<Color>
  inherits: ValueType
val penup : instruction

Full name: Snippet.Lang.penup

  type: instruction
  implements: IEquatable<instruction>
  implements: Collections.IStructuralEquatable
val pendown : instruction

Full name: Snippet.Lang.pendown

  type: instruction
  implements: IEquatable<instruction>
  implements: Collections.IStructuralEquatable
val penwidth : distance -> instruction

Full name: Snippet.Lang.penwidth
val clearscreen : instruction

Full name: Snippet.Lang.clearscreen

  type: instruction
  implements: IEquatable<instruction>
  implements: Collections.IStructuralEquatable
val cs : instruction

Full name: Snippet.Lang.cs

  type: instruction
  implements: IEquatable<instruction>
  implements: Collections.IStructuralEquatable
val hideturtle : instruction

Full name: Snippet.Lang.hideturtle

  type: instruction
  implements: IEquatable<instruction>
  implements: Collections.IStructuralEquatable
val ht : instruction

Full name: Snippet.Lang.ht

  type: instruction
  implements: IEquatable<instruction>
  implements: Collections.IStructuralEquatable
val showturtle : instruction

Full name: Snippet.Lang.showturtle

  type: instruction
  implements: IEquatable<instruction>
  implements: Collections.IStructuralEquatable
val st : instruction

Full name: Snippet.Lang.st

  type: instruction
  implements: IEquatable<instruction>
  implements: Collections.IStructuralEquatable
type Colors =
  class
    static member AliceBlue : System.Windows.Media.Color
    static member AntiqueWhite : System.Windows.Media.Color
    static member Aqua : System.Windows.Media.Color
    static member Aquamarine : System.Windows.Media.Color
    static member Azure : System.Windows.Media.Color
    static member Beige : System.Windows.Media.Color
    static member Bisque : System.Windows.Media.Color
    static member Black : System.Windows.Media.Color
    static member BlanchedAlmond : System.Windows.Media.Color
    static member Blue : System.Windows.Media.Color
    static member BlueViolet : System.Windows.Media.Color
    static member Brown : System.Windows.Media.Color
    static member BurlyWood : System.Windows.Media.Color
    static member CadetBlue : System.Windows.Media.Color
    static member Chartreuse : System.Windows.Media.Color
    static member Chocolate : System.Windows.Media.Color
    static member Coral : System.Windows.Media.Color
    static member CornflowerBlue : System.Windows.Media.Color
    static member Cornsilk : System.Windows.Media.Color
    static member Crimson : System.Windows.Media.Color
    static member Cyan : System.Windows.Media.Color
    static member DarkBlue : System.Windows.Media.Color
    static member DarkCyan : System.Windows.Media.Color
    static member DarkGoldenrod : System.Windows.Media.Color
    static member DarkGray : System.Windows.Media.Color
    static member DarkGreen : System.Windows.Media.Color
    static member DarkKhaki : System.Windows.Media.Color
    static member DarkMagenta : System.Windows.Media.Color
    static member DarkOliveGreen : System.Windows.Media.Color
    static member DarkOrange : System.Windows.Media.Color
    static member DarkOrchid : System.Windows.Media.Color
    static member DarkRed : System.Windows.Media.Color
    static member DarkSalmon : System.Windows.Media.Color
    static member DarkSeaGreen : System.Windows.Media.Color
    static member DarkSlateBlue : System.Windows.Media.Color
    static member DarkSlateGray : System.Windows.Media.Color
    static member DarkTurquoise : System.Windows.Media.Color
    static member DarkViolet : System.Windows.Media.Color
    static member DeepPink : System.Windows.Media.Color
    static member DeepSkyBlue : System.Windows.Media.Color
    static member DimGray : System.Windows.Media.Color
    static member DodgerBlue : System.Windows.Media.Color
    static member Firebrick : System.Windows.Media.Color
    static member FloralWhite : System.Windows.Media.Color
    static member ForestGreen : System.Windows.Media.Color
    static member Fuchsia : System.Windows.Media.Color
    static member Gainsboro : System.Windows.Media.Color
    static member GhostWhite : System.Windows.Media.Color
    static member Gold : System.Windows.Media.Color
    static member Goldenrod : System.Windows.Media.Color
    static member Gray : System.Windows.Media.Color
    static member Green : System.Windows.Media.Color
    static member GreenYellow : System.Windows.Media.Color
    static member Honeydew : System.Windows.Media.Color
    static member HotPink : System.Windows.Media.Color
    static member IndianRed : System.Windows.Media.Color
    static member Indigo : System.Windows.Media.Color
    static member Ivory : System.Windows.Media.Color
    static member Khaki : System.Windows.Media.Color
    static member Lavender : System.Windows.Media.Color
    static member LavenderBlush : System.Windows.Media.Color
    static member LawnGreen : System.Windows.Media.Color
    static member LemonChiffon : System.Windows.Media.Color
    static member LightBlue : System.Windows.Media.Color
    static member LightCoral : System.Windows.Media.Color
    static member LightCyan : System.Windows.Media.Color
    static member LightGoldenrodYellow : System.Windows.Media.Color
    static member LightGray : System.Windows.Media.Color
    static member LightGreen : System.Windows.Media.Color
    static member LightPink : System.Windows.Media.Color
    static member LightSalmon : System.Windows.Media.Color
    static member LightSeaGreen : System.Windows.Media.Color
    static member LightSkyBlue : System.Windows.Media.Color
    static member LightSlateGray : System.Windows.Media.Color
    static member LightSteelBlue : System.Windows.Media.Color
    static member LightYellow : System.Windows.Media.Color
    static member Lime : System.Windows.Media.Color
    static member LimeGreen : System.Windows.Media.Color
    static member Linen : System.Windows.Media.Color
    static member Magenta : System.Windows.Media.Color
    static member Maroon : System.Windows.Media.Color
    static member MediumAquamarine : System.Windows.Media.Color
    static member MediumBlue : System.Windows.Media.Color
    static member MediumOrchid : System.Windows.Media.Color
    static member MediumPurple : System.Windows.Media.Color
    static member MediumSeaGreen : System.Windows.Media.Color
    static member MediumSlateBlue : System.Windows.Media.Color
    static member MediumSpringGreen : System.Windows.Media.Color
    static member MediumTurquoise : System.Windows.Media.Color
    static member MediumVioletRed : System.Windows.Media.Color
    static member MidnightBlue : System.Windows.Media.Color
    static member MintCream : System.Windows.Media.Color
    static member MistyRose : System.Windows.Media.Color
    static member Moccasin : System.Windows.Media.Color
    static member NavajoWhite : System.Windows.Media.Color
    static member Navy : System.Windows.Media.Color
    static member OldLace : System.Windows.Media.Color
    static member Olive : System.Windows.Media.Color
    static member OliveDrab : System.Windows.Media.Color
    static member Orange : System.Windows.Media.Color
    static member OrangeRed : System.Windows.Media.Color
    static member Orchid : System.Windows.Media.Color
    static member PaleGoldenrod : System.Windows.Media.Color
    static member PaleGreen : System.Windows.Media.Color
    static member PaleTurquoise : System.Windows.Media.Color
    static member PaleVioletRed : System.Windows.Media.Color
    static member PapayaWhip : System.Windows.Media.Color
    static member PeachPuff : System.Windows.Media.Color
    static member Peru : System.Windows.Media.Color
    static member Pink : System.Windows.Media.Color
    static member Plum : System.Windows.Media.Color
    static member PowderBlue : System.Windows.Media.Color
    static member Purple : System.Windows.Media.Color
    static member Red : System.Windows.Media.Color
    static member RosyBrown : System.Windows.Media.Color
    static member RoyalBlue : System.Windows.Media.Color
    static member SaddleBrown : System.Windows.Media.Color
    static member Salmon : System.Windows.Media.Color
    static member SandyBrown : System.Windows.Media.Color
    static member SeaGreen : System.Windows.Media.Color
    static member SeaShell : System.Windows.Media.Color
    static member Sienna : System.Windows.Media.Color
    static member Silver : System.Windows.Media.Color
    static member SkyBlue : System.Windows.Media.Color
    static member SlateBlue : System.Windows.Media.Color
    static member SlateGray : System.Windows.Media.Color
    static member Snow : System.Windows.Media.Color
    static member SpringGreen : System.Windows.Media.Color
    static member SteelBlue : System.Windows.Media.Color
    static member Tan : System.Windows.Media.Color
    static member Teal : System.Windows.Media.Color
    static member Thistle : System.Windows.Media.Color
    static member Tomato : System.Windows.Media.Color
    static member Transparent : System.Windows.Media.Color
    static member Turquoise : System.Windows.Media.Color
    static member Violet : System.Windows.Media.Color
    static member Wheat : System.Windows.Media.Color
    static member White : System.Windows.Media.Color
    static member WhiteSmoke : System.Windows.Media.Color
    static member Yellow : System.Windows.Media.Color
    static member YellowGreen : System.Windows.Media.Color
  end

Full name: System.Windows.Media.Colors
val red : Color

Full name: Snippet.Colors.red

  type: Color
  implements: IFormattable
  implements: IEquatable<Color>
  inherits: ValueType
property Colors.Red: Color
val green : Color

Full name: Snippet.Colors.green

  type: Color
  implements: IFormattable
  implements: IEquatable<Color>
  inherits: ValueType
property Colors.Green: Color
val blue : Color

Full name: Snippet.Colors.blue

  type: Color
  implements: IFormattable
  implements: IEquatable<Color>
  inherits: ValueType
property Colors.Blue: Color
val white : Color

Full name: Snippet.Colors.white

  type: Color
  implements: IFormattable
  implements: IEquatable<Color>
  inherits: ValueType
property Colors.White: Color
val black : Color

Full name: Snippet.Colors.black

  type: Color
  implements: IFormattable
  implements: IEquatable<Color>
  inherits: ValueType
property Colors.Black: Color
val gray : Color

Full name: Snippet.Colors.gray

  type: Color
  implements: IFormattable
  implements: IEquatable<Color>
  inherits: ValueType
property Colors.Gray: Color
val yellow : Color

Full name: Snippet.Colors.yellow

  type: Color
  implements: IFormattable
  implements: IEquatable<Color>
  inherits: ValueType
property Colors.Yellow: Color
val orange : Color

Full name: Snippet.Colors.orange

  type: Color
  implements: IFormattable
  implements: IEquatable<Color>
  inherits: ValueType
property Colors.Orange: Color
val brown : Color

Full name: Snippet.Colors.brown

  type: Color
  implements: IFormattable
  implements: IEquatable<Color>
  inherits: ValueType
property Colors.Brown: Color
val cyan : Color

Full name: Snippet.Colors.cyan

  type: Color
  implements: IFormattable
  implements: IEquatable<Color>
  inherits: ValueType
property Colors.Cyan: Color
val magenta : Color

Full name: Snippet.Colors.magenta

  type: Color
  implements: IFormattable
  implements: IEquatable<Color>
  inherits: ValueType
property Colors.Magenta: Color
val purple : Color

Full name: Snippet.Colors.purple

  type: Color
  implements: IFormattable
  implements: IEquatable<Color>
  inherits: ValueType
property Colors.Purple: Color
type Turtle =
  class
    inherit UserControl
    private new : unit -> Turtle
    member private Execute : instruction:instruction -> unit
    static member Run : instruction:instruction -> unit
    static member Run : instructions:seq<instruction> -> unit
    static member Screen : Turtle
  end

Full name: Snippet.Turtle

  type: Turtle
  implements: Composition.DUCE.IResource
  implements: Animation.IAnimatable
  implements: IFrameworkInputElement
  implements: IInputElement
  implements: ComponentModel.ISupportInitialize
  implements: Markup.IHaveResources
  implements: Markup.IQueryAmbient
  implements: Markup.IAddChild
  inherits: UserControl
  inherits: ContentControl
  inherits: Control
  inherits: FrameworkElement
  inherits: UIElement
  inherits: Visual
  inherits: DependencyObject
  inherits: Threading.DispatcherObject
type UserControl =
  class
    inherit System.Windows.Controls.ContentControl
    new : unit -> System.Windows.Controls.UserControl
  end

Full name: System.Windows.Controls.UserControl

  type: UserControl
  implements: Composition.DUCE.IResource
  implements: Animation.IAnimatable
  implements: IFrameworkInputElement
  implements: IInputElement
  implements: ComponentModel.ISupportInitialize
  implements: Markup.IHaveResources
  implements: Markup.IQueryAmbient
  implements: Markup.IAddChild
  inherits: ContentControl
  inherits: Control
  inherits: FrameworkElement
  inherits: UIElement
  inherits: Visual
  inherits: DependencyObject
  inherits: Threading.DispatcherObject
val screen : Canvas

  type: Canvas
  implements: Composition.DUCE.IResource
  implements: Animation.IAnimatable
  implements: IFrameworkInputElement
  implements: IInputElement
  implements: ComponentModel.ISupportInitialize
  implements: Markup.IHaveResources
  implements: Markup.IQueryAmbient
  implements: Markup.IAddChild
  inherits: Panel
  inherits: FrameworkElement
  inherits: UIElement
  inherits: Visual
  inherits: DependencyObject
  inherits: Threading.DispatcherObject
type Canvas =
  class
    inherit System.Windows.Controls.Panel
    new : unit -> System.Windows.Controls.Canvas
    static val LeftProperty : System.Windows.DependencyProperty
    static val TopProperty : System.Windows.DependencyProperty
    static val RightProperty : System.Windows.DependencyProperty
    static val BottomProperty : System.Windows.DependencyProperty
    static member GetBottom : System.Windows.UIElement -> float
    static member GetLeft : System.Windows.UIElement -> float
    static member GetRight : System.Windows.UIElement -> float
    static member GetTop : System.Windows.UIElement -> float
    static member SetBottom : System.Windows.UIElement * float -> unit
    static member SetLeft : System.Windows.UIElement * float -> unit
    static member SetRight : System.Windows.UIElement * float -> unit
    static member SetTop : System.Windows.UIElement * float -> unit
  end

Full name: System.Windows.Controls.Canvas

  type: Canvas
  implements: Composition.DUCE.IResource
  implements: Animation.IAnimatable
  implements: IFrameworkInputElement
  implements: IInputElement
  implements: ComponentModel.ISupportInitialize
  implements: Markup.IHaveResources
  implements: Markup.IQueryAmbient
  implements: Markup.IAddChild
  inherits: Panel
  inherits: FrameworkElement
  inherits: UIElement
  inherits: Visual
  inherits: DependencyObject
  inherits: Threading.DispatcherObject
type SolidColorBrush =
  class
    inherit System.Windows.Media.Brush
    new : unit -> System.Windows.Media.SolidColorBrush
    new : System.Windows.Media.Color -> System.Windows.Media.SolidColorBrush
    member Clone : unit -> System.Windows.Media.SolidColorBrush
    member CloneCurrentValue : unit -> System.Windows.Media.SolidColorBrush
    member Color : System.Windows.Media.Color with get, set
    static val ColorProperty : System.Windows.DependencyProperty
    static member DeserializeFrom : System.IO.BinaryReader -> obj
  end

Full name: System.Windows.Media.SolidColorBrush

  type: SolidColorBrush
  implements: ISealable
  implements: Animation.IAnimatable
  implements: IFormattable
  implements: Composition.DUCE.IResource
  inherits: Brush
  inherits: Animation.Animatable
  inherits: Freezable
  inherits: DependencyObject
  inherits: Threading.DispatcherObject
val mutable penColor : Color

  type: Color
  implements: IFormattable
  implements: IEquatable<Color>
  inherits: ValueType
val mutable penWidth : float

  type: float
  implements: IComparable
  implements: IFormattable
  implements: IConvertible
  implements: IComparable<float>
  implements: IEquatable<float>
  inherits: ValueType
val mutable isPenDown : bool

  type: bool
  implements: IComparable
  implements: IConvertible
  implements: IComparable<bool>
  implements: IEquatable<bool>
  inherits: ValueType
val mutable x : float

  type: float
  implements: IComparable
  implements: IFormattable
  implements: IConvertible
  implements: IComparable<float>
  implements: IEquatable<float>
  inherits: ValueType
val mutable y : float

  type: float
  implements: IComparable
  implements: IFormattable
  implements: IConvertible
  implements: IComparable<float>
  implements: IEquatable<float>
  inherits: ValueType
val mutable a : int

  type: int
  implements: IComparable
  implements: IFormattable
  implements: IConvertible
  implements: IComparable<int>
  implements: IEquatable<int>
  inherits: ValueType
val addLine : (Canvas -> float -> float -> int)
val canvas : Canvas

  type: Canvas
  implements: Composition.DUCE.IResource
  implements: Animation.IAnimatable
  implements: IFrameworkInputElement
  implements: IInputElement
  implements: ComponentModel.ISupportInitialize
  implements: Markup.IHaveResources
  implements: Markup.IQueryAmbient
  implements: Markup.IAddChild
  inherits: Panel
  inherits: FrameworkElement
  inherits: UIElement
  inherits: Visual
  inherits: DependencyObject
  inherits: Threading.DispatcherObject
val x' : float

  type: float
  implements: IComparable
  implements: IFormattable
  implements: IConvertible
  implements: IComparable<float>
  implements: IEquatable<float>
  inherits: ValueType
val y' : float

  type: float
  implements: IComparable
  implements: IFormattable
  implements: IConvertible
  implements: IComparable<float>
  implements: IEquatable<float>
  inherits: ValueType
val line : Line

  type: Line
  implements: Composition.DUCE.IResource
  implements: Animation.IAnimatable
  implements: IFrameworkInputElement
  implements: IInputElement
  implements: ComponentModel.ISupportInitialize
  implements: Markup.IHaveResources
  implements: Markup.IQueryAmbient
  inherits: Shape
  inherits: FrameworkElement
  inherits: UIElement
  inherits: Visual
  inherits: DependencyObject
  inherits: Threading.DispatcherObject
type Line =
  class
    inherit System.Windows.Shapes.Shape
    new : unit -> System.Windows.Shapes.Line
    member X1 : float with get, set
    member X2 : float with get, set
    member Y1 : float with get, set
    member Y2 : float with get, set
    static val X1Property : System.Windows.DependencyProperty
    static val Y1Property : System.Windows.DependencyProperty
    static val X2Property : System.Windows.DependencyProperty
    static val Y2Property : System.Windows.DependencyProperty
  end

Full name: System.Windows.Shapes.Line

  type: Line
  implements: Composition.DUCE.IResource
  implements: Animation.IAnimatable
  implements: IFrameworkInputElement
  implements: IInputElement
  implements: ComponentModel.ISupportInitialize
  implements: Markup.IHaveResources
  implements: Markup.IQueryAmbient
  inherits: Shape
  inherits: FrameworkElement
  inherits: UIElement
  inherits: Visual
  inherits: DependencyObject
  inherits: Threading.DispatcherObject
property Shape.StrokeThickness: float
property Shape.Stroke: Brush
property Panel.Children: UIElementCollection
UIElementCollection.Add(element: UIElement) : int
val clearLines : (unit -> unit)
UIElementCollection.Clear() : unit
val turtle : Canvas

  type: Canvas
  implements: Composition.DUCE.IResource
  implements: Animation.IAnimatable
  implements: IFrameworkInputElement
  implements: IInputElement
  implements: ComponentModel.ISupportInitialize
  implements: Markup.IHaveResources
  implements: Markup.IQueryAmbient
  implements: Markup.IAddChild
  inherits: Panel
  inherits: FrameworkElement
  inherits: UIElement
  inherits: Visual
  inherits: DependencyObject
  inherits: Threading.DispatcherObject
val rotation : RotateTransform

  type: RotateTransform
  implements: ISealable
  implements: Animation.IAnimatable
  implements: IFormattable
  implements: Composition.DUCE.IResource
  inherits: Transform
  inherits: GeneralTransform
  inherits: Animation.Animatable
  inherits: Freezable
  inherits: DependencyObject
  inherits: Threading.DispatcherObject
type RotateTransform =
  class
    inherit System.Windows.Media.Transform
    new : unit -> System.Windows.Media.RotateTransform
    new : float -> System.Windows.Media.RotateTransform
    new : float * float * float -> System.Windows.Media.RotateTransform
    member Angle : float with get, set
    member CenterX : float with get, set
    member CenterY : float with get, set
    member Clone : unit -> System.Windows.Media.RotateTransform
    member CloneCurrentValue : unit -> System.Windows.Media.RotateTransform
    member Value : System.Windows.Media.Matrix
    static val AngleProperty : System.Windows.DependencyProperty
    static val CenterXProperty : System.Windows.DependencyProperty
    static val CenterYProperty : System.Windows.DependencyProperty
  end

Full name: System.Windows.Media.RotateTransform

  type: RotateTransform
  implements: ISealable
  implements: Animation.IAnimatable
  implements: IFormattable
  implements: Composition.DUCE.IResource
  inherits: Transform
  inherits: GeneralTransform
  inherits: Animation.Animatable
  inherits: Freezable
  inherits: DependencyObject
  inherits: Threading.DispatcherObject
Multiple items
val float : 'T -> float (requires member op_Explicit)

Full name: Microsoft.FSharp.Core.Operators.float

--------------------

type float<'Measure> = float

Full name: Microsoft.FSharp.Core.float<_>

  type: float<'Measure>
  implements: IComparable
  implements: IConvertible
  implements: IFormattable
  implements: IComparable<float<'Measure>>
  implements: IEquatable<float<'Measure>>
  inherits: ValueType


--------------------

type float = Double

Full name: Microsoft.FSharp.Core.float

  type: float
  implements: IComparable
  implements: IFormattable
  implements: IConvertible
  implements: IComparable<float>
  implements: IEquatable<float>
  inherits: ValueType
property UIElement.RenderTransform: Transform
val execute : ('a -> instruction -> unit)
val canvas : 'a
val n : float

  type: float
  implements: IComparable
  implements: IFormattable
  implements: IConvertible
  implements: IComparable<float>
  implements: IEquatable<float>
  inherits: ValueType
val r : float

  type: float
  implements: IComparable
  implements: IFormattable
  implements: IConvertible
  implements: IComparable<float>
  implements: IEquatable<float>
  inherits: ValueType
type Math =
  class
    static val PI : float
    static val E : float
    static member Abs : System.SByte -> System.SByte
    static member Abs : int16 -> int16
    static member Abs : int -> int
    static member Abs : int64 -> int64
    static member Abs : float32 -> float32
    static member Abs : float -> float
    static member Abs : decimal -> decimal
    static member Acos : float -> float
    static member Asin : float -> float
    static member Atan : float -> float
    static member Atan2 : float * float -> float
    static member BigMul : int * int -> int64
    static member Ceiling : decimal -> decimal
    static member Ceiling : float -> float
    static member Cos : float -> float
    static member Cosh : float -> float
    static member DivRem : int * int * int -> int
    static member DivRem : int64 * int64 * int64 -> int64
    static member Exp : float -> float
    static member Floor : decimal -> decimal
    static member Floor : float -> float
    static member IEEERemainder : float * float -> float
    static member Log : float -> float
    static member Log : float * float -> float
    static member Log10 : float -> float
    static member Max : System.SByte * System.SByte -> System.SByte
    static member Max : System.Byte * System.Byte -> System.Byte
    static member Max : int16 * int16 -> int16
    static member Max : uint16 * uint16 -> uint16
    static member Max : int * int -> int
    static member Max : uint32 * uint32 -> uint32
    static member Max : int64 * int64 -> int64
    static member Max : uint64 * uint64 -> uint64
    static member Max : float32 * float32 -> float32
    static member Max : float * float -> float
    static member Max : decimal * decimal -> decimal
    static member Min : System.SByte * System.SByte -> System.SByte
    static member Min : System.Byte * System.Byte -> System.Byte
    static member Min : int16 * int16 -> int16
    static member Min : uint16 * uint16 -> uint16
    static member Min : int * int -> int
    static member Min : uint32 * uint32 -> uint32
    static member Min : int64 * int64 -> int64
    static member Min : uint64 * uint64 -> uint64
    static member Min : float32 * float32 -> float32
    static member Min : float * float -> float
    static member Min : decimal * decimal -> decimal
    static member Pow : float * float -> float
    static member Round : float -> float
    static member Round : decimal -> decimal
    static member Round : float * int -> float
    static member Round : float * System.MidpointRounding -> float
    static member Round : decimal * int -> decimal
    static member Round : decimal * System.MidpointRounding -> decimal
    static member Round : float * int * System.MidpointRounding -> float
    static member Round : decimal * int * System.MidpointRounding -> decimal
    static member Sign : System.SByte -> int
    static member Sign : int16 -> int
    static member Sign : int -> int
    static member Sign : int64 -> int
    static member Sign : float32 -> int
    static member Sign : float -> int
    static member Sign : decimal -> int
    static member Sin : float -> float
    static member Sinh : float -> float
    static member Sqrt : float -> float
    static member Tan : float -> float
    static member Tanh : float -> float
    static member Truncate : decimal -> decimal
    static member Truncate : float -> float
  end

Full name: System.Math
field Math.PI = 3.14159265359
val dx : float

  type: float
  implements: IComparable
  implements: IFormattable
  implements: IConvertible
  implements: IComparable<float>
  implements: IEquatable<float>
  inherits: ValueType
val dy : float

  type: float
  implements: IComparable
  implements: IFormattable
  implements: IConvertible
  implements: IComparable<float>
  implements: IEquatable<float>
  inherits: ValueType
val cos : 'T -> 'T (requires member Cos)

Full name: Microsoft.FSharp.Core.Operators.cos
val sin : 'T -> 'T (requires member Sin)

Full name: Microsoft.FSharp.Core.Operators.sin
property RotateTransform.Angle: float
val i : int

  type: int
  implements: IComparable
  implements: IFormattable
  implements: IConvertible
  implements: IComparable<int>
  implements: IEquatable<int>
  inherits: ValueType
Multiple items
module List

from Microsoft.FSharp.Collections

--------------------

type List<'T> =
  | ( [] )
  | ( :: ) of 'T * 'T list
  with
    interface Collections.IEnumerable
    interface Collections.Generic.IEnumerable<'T>
    member Head : 'T
    member IsEmpty : bool
    member Item : index:int -> 'T with get
    member Length : int
    member Tail : 'T list
    static member Cons : head:'T * tail:'T list -> 'T list
    static member Empty : 'T list
  end

Full name: Microsoft.FSharp.Collections.List<_>

  type: List<'T>
  implements: Collections.IStructuralEquatable
  implements: IComparable<List<'T>>
  implements: IComparable
  implements: Collections.IStructuralComparable
  implements: Collections.Generic.IEnumerable<'T>
  implements: Collections.IEnumerable
val iter : ('T -> unit) -> 'T list -> unit

Full name: Microsoft.FSharp.Collections.List.iter
val width : distance

  type: distance
  implements: IComparable
  implements: IFormattable
  implements: IConvertible
  implements: IComparable<int>
  implements: IEquatable<int>
  inherits: ValueType
property UIElement.Visibility: Visibility
type Visibility =
  | Visible = (* value unavailable *)
  | Hidden = (* value unavailable *)
  | Collapsed = (* value unavailable *)

Full name: System.Windows.Visibility

  type: Visibility
  inherits: Enum
  inherits: ValueType
field Visibility.Visible = 0uy
field Visibility.Collapsed = 2uy
val drawTurtle : (unit -> unit)
Canvas.SetLeft(element: UIElement, length: float) : unit
Canvas.SetTop(element: UIElement, length: float) : unit
val control : Lazy<Turtle>
val this : Turtle

  type: Turtle
  implements: Composition.DUCE.IResource
  implements: Animation.IAnimatable
  implements: IFrameworkInputElement
  implements: IInputElement
  implements: ComponentModel.ISupportInitialize
  implements: Markup.IHaveResources
  implements: Markup.IQueryAmbient
  implements: Markup.IAddChild
  inherits: UserControl
  inherits: ContentControl
  inherits: Control
  inherits: FrameworkElement
  inherits: UIElement
  inherits: Visual
  inherits: DependencyObject
  inherits: Threading.DispatcherObject
member private Turtle.Execute : instruction:instruction -> unit

Full name: Snippet.Turtle.Execute
Multiple items
val instruction : instruction

  type: instruction
  implements: IEquatable<instruction>
  implements: Collections.IStructuralEquatable


--------------------

type instruction =
  | Forward of distance
  | Left of degrees
  | Right of degrees
  | Repeat of int * instruction list
  | PenDown
  | PenUp
  | PenColor of Color
  | PenWidth of distance
  | ClearScreen
  | ShowTurtle
  | HideTurtle

Full name: Snippet.AST.instruction

  type: instruction
  implements: IEquatable<instruction>
  implements: Collections.IStructuralEquatable
static member Turtle.Screen : Turtle

Full name: Snippet.Turtle.Screen

Turtle screen
member Lazy.Force : unit -> 'T
static member Turtle.Run : instruction:instruction -> unit

Full name: Snippet.Turtle.Run

Runs turtle instruction
val run : (unit -> unit)
static member Turtle.Run : instructions:seq<instruction> -> unit

Full name: Snippet.Turtle.Run

Runs sequence of turtle instructions
val instructions : seq<instruction>

  type: seq<instruction>
  inherits: Collections.IEnumerable
Multiple items
val seq : seq<'T> -> seq<'T>

Full name: Microsoft.FSharp.Core.Operators.seq

--------------------

type seq<'T> = Collections.Generic.IEnumerable<'T>

Full name: Microsoft.FSharp.Collections.seq<_>

  type: seq<'T>
  inherits: Collections.IEnumerable
module Seq

from Microsoft.FSharp.Collections
val iter : ('T -> unit) -> seq<'T> -> unit

Full name: Microsoft.FSharp.Collections.Seq.iter
#if INTERACTIVE
App.Dispatch (fun() ->
    App.Console.ClearCanvas()
    let canvas = App.Console.Canvas
    let control = Turtle.Screen
    control |> canvas.Children.Add
    App.Console.CanvasPosition <- CanvasPosition.Right
    control.Focus() |> ignore
)
#else
type App() as app =
  inherit System.Windows.Application()
  do app.Startup.Add(fun _ -> app.RootVisual <- Turtle.Screen)
#endif
Multiple overloads
static member Turtle.Run : instruction:instruction -> unit

Runs turtle instruction
static member Turtle.Run : instructions:seq<instruction> -> unit

Runs sequence of turtle instructions
val a : int

  type: int
  implements: IComparable
  implements: IFormattable
  implements: IConvertible
  implements: IComparable<int>
  implements: IEquatable<int>
  inherits: ValueType

More information

Link: http://fssnip.net/6y
Posted: 3 years ago
Author: Phillip Trelford (website)
Tags: DSL