Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Component: Ideas to Try Out #5262

Open
13 tasks
StachuDotNet opened this issue Jan 14, 2024 · 2 comments
Open
13 tasks

Component: Ideas to Try Out #5262

StachuDotNet opened this issue Jan 14, 2024 · 2 comments

Comments

@StachuDotNet
Copy link
Member

StachuDotNet commented Jan 14, 2024

This Issue is a grab-bag dumping ground for a bunch of Dark ideas that we'd like to not forget about, but aren't high enough priority to seriously consider yet. If users submit Issues that seem really interesting but would fill up GitHub Issues, we might link them here, close the issue, and reopen it once we're able to tackle it.

  • Allow users to comment on functions, like in the old days of PHP (eg see "User notes" in https://www.php.net/strip_tags)
  • WebSockets support (see Support for websockets #4046)
  • support user-defined languages (ambitious, uncertain, hard)
    • build langs on and in darklang
      • user provides AST, grammar, etc
      • all gets compiled to some darklang bytecode (or interpreted) at end of day
      • distributed treesitter (waves hands vaguely)
  • a web-hosted terminal emulator that can run Dark CLI apps
    • probably xterm.js
    • an officially-supported page where our users can log in
    • allow our users to define their own CLIs hosted like this
    • probably needs WASM runtime to come back in, and house the language server? or it could all be over HTTP
  • something like jq, in dark
    • type Error = CouldNotNavigate of pathSoFar: List<JsonPath> * failureAt: JsonPath.Part
    • let navigate (json: Json) (path: JsonPath): Result<Json, Error> = ...
    • could wrap that such that:
    • json |> Json.Nav.accessField "fieldName" |> Json.Nav.accessIndex 4
  • Add support for Mustache template system (see old Add support for Mustache template system.  #3354)
  • support seamless RPC between Darklang CLI installs (see here)
  • we have this old post where we advertise you can "build a slack app in seconds with Dark" but immediately say it's a bit of an exaggeration. Let's make it not an exaggeration. From signup to slack app in < 1min.
  • some sort of GraphQL support
@StachuDotNet
Copy link
Member Author

Dumping some personal notes here, towards (potentially-distributed) MVU apps

module Darklang =
  // TODO: I'm not sure where this would best belong
  module ModelViewUpdate =
    module Cli =
      type App<'Model, 'Msg> =
        { init: 'Model

          update: ('Model, 'Msg) -> 'Model

          view: 'Model -> String
          clearBeforeView: Bool

          readAndParseNextMsg: Unit -> Result<'Msg, String> }


      let loop (app: App<'Model, 'Msg>) (model: 'Model): Unit =
        if app.clearBeforeView then Console.Clear()

        printfn "%s" (app.view model)

        match app.readAndParseNextMsg () with
        | Ok msg ->
          let updatedModel = app.update model msg
          loop app updatedModel
        | Error errMsg ->
          printfn "Error reading or parsing message: %s" errMsg
          loop app model


      let runApp (app: App<'Model, 'Msg>): Unit =
        loop app app.init



type Model = { counter: Int }

type Msg =
  | Increment
  | Decrement

let update (state: Model) (msg: Msg) : Model =
  match msg with
  | Increment -> Model { counter = state.counter + 1 }
  | Decrement -> Model { counter = state.counter - 1 }

let view (state: Model) : String =
  $"Count: {state.counter}\ntype 'i' or 'd' to continue"

let readAndParseNextMsg () : Result<Msg, String> =
  // reads from console or something
  let line = Builtin.Stdin.readLine ()

  match line with
  | "i" -> PACKAGE.Darklang.Stdlib.Result.Result.Ok Msg.Increment
  | "d" -> PACKAGE.Darklang.Stdlib.Result.Result.Ok Ok Msg.Decrement
  | other -> PACKAGE.Darklang.Stdlib.Result.Result.Error other


let app =
  PACKAGE.Darklang.ModelViewUpdate.Cli.App
    { init = Model { counter = 0 }
      update = (fun (state, msg) -> update state msg)
      view = view
      clearBeforeView = false
      readAndParseNextMsg = readAndParseNextMsg }


runApp app







dark run x
runs Cli app named x




type CliAppHandler = 

type SimpleCliApp = 
	{ name: String
	  init: 'State
	  handleInput: 'State -> String -> 'State
	  render: 'State -> String }

type CliApp = 
	/// REPL-y - no fancy UI
	| Simple<'State> of SimpleCliApp<'State>

	//| Elmish<'State, 'Msg>
	//	of name: String 
	//	 * init: 'State
	//	 * handleInput: 'State
	//	 * render: 'State -> String

// package/user constant?
let darkRepl =
	CliApp.Simple<Int>
		{ name = "simpleCounter"
		  init = 0
		  handleInput =
		  	fun acc input ->
		  		match input with
		  		| "increase" -> acc + 1
		  		| "decrease" -> acc - 1
		  		| _ -> acc
  		  render = fun acc -> Int.toString acc }


upon `dark run x`, we try to look up any CliApp constant named `x`

@StachuDotNet
Copy link
Member Author

(Some day) would it be possible to bring back structured editing? Some relevant personal notes:

@StachuDotNet StachuDotNet added the needs-review I plan on going through each of the issues and clarifying them -- this is to mark remaining issues label Feb 14, 2024
@StachuDotNet StachuDotNet removed the needs-review I plan on going through each of the issues and clarifying them -- this is to mark remaining issues label Feb 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant