Transformers
Published in

Transformers

How To Use ChatGPT to Code: Part 1

This is a tipping point. All coders can either get creative or rest in shattered pieces.

I’ll keep everything as short as possible. Italics means ChatGPT output.

Bold means my input to the chat to keep things going.

The website is:

https://chat.openai.com/chat

Question 1)

Source code of a cross-platform Avalonia FuncUI CRUD application using F#.NET

Answer: 1)

open Avalonia
open Avalonia.Controls
open Avalonia.Markup.Xaml

type MainWindow() =
inherit Window()

let mutable _items = ["Item 1"; "Item 2"; "Item 3"]
let mutable _selectedItem = ""

let listBox = new ListBox()
let textBox = new TextBox()
let addButton = new Button()
let deleteButton = new Button()

do
listBox.Items <- _items
listBox.SelectionChanged.Add(fun _ ->
_selectedItem <- listBox.SelectedItem.ToString()
textBox.Text <- _selectedItem)

addButton.Content <- "Add"
addButton.Click.Add(fun _ ->
_items <- _items @ [textBox.Text]
listBox.Items <- _items)

deleteButton.Content <- "Delete"
deleteButton.Click.Add(fun _ ->
_items <- _items |> List.filter (fun item -> item <> _selectedItem)
listBox.Items <- _items)

AvaloniaXamlLoader.Load(self)

type App() =
inherit Application()

override this.OnFrameworkInitializationCompleted() =
base.OnFrameworkInitializationCompleted()
let window = new MainWindow()
window.Show()
this.MainWindow <- window

[<STAThread; EntryPoint>]
let main argv =
App().Start(argv)
0

This code defines a MainWindow class that contains a list box for displaying a list of items, a text box for adding or modifying items, and two buttons for adding and deleting items. The MainWindow class also has a list of items and a selected item that are used to update the list box and text box.

The App class is the entry point for the application and creates an instance of MainWindow and displays it.

To use this code, you will need to create an Avalonia project and add the code to the appropriate files. You can find more information about creating Avalonia projects and using FuncUI in the Avalonia documentation: https://avaloniaui.net/docs/getting-started.

All F#.NET coders — how does getting replaced by automation feel like? And this is the beta, not the final version.

Continued at https://thomascherickal.hashnode.dev/how-to-code-with-chatgpt-part-2

Because neither Medium or HackerNoon has the code support that HashNode has.

--

--

Transformers Neural Networks are going to reshape the very nature of human life. They can be used for a lot more than language. They can be used by any sort of data. Watch this space to see the next AI revolution!

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Thomas Cherickal

Jesus Youth on a mission to eternity. a gospel vocalist, a gospel violinist, & a research coder & author all by God’s infinite grace alone.