Compiler.Backend

Functions for working with the Haskell-based Gren compiler.

version : String

Version of the compiler blob. This might not match the version of the Gren compiler as a whole, as the Haskell- and Gren-parts are versioned seperatly.

type UnsupportedPlatform
= UnsupportedPlatform

Type used to signal that the given platform isn't supported. Meaning that there doesn't exist a pre-built compiler blob.

downloadUrl :
Platform
-> CpuArchitecture
-> Result UnsupportedPlatform String

Construct a URL from which you can download a compiler blob compatible with the given platform and cpu architecture.

download : Permission -> String -> Task (Error Bytes) (Response Bytes)

Downlod the compiler blob.

type Command
= Repl ReplFlags
| Make MakeFlags
| Docs DocsFlags
| PackageValidate PackageValidateFlags
| PackageBump PackageBumpFlags
| PackageDiff PackageDiffFlags

Commands supported by the compiler blob.

  • Repl: run a REPL.
  • Make: compile a project
  • Docs: generate a docs.json file
  • PackageValide: check if this package is ready to be deployed
  • PackageBump: bump package version to next compatible semantic version
  • PackageDiff: calculate the API-difference between this package and another version.
type alias ReplFlags =
{ interpreter : Maybe String
, projectPath : Path
, outline : Outline
, rootSources : Dict String SourceFile
, dependencies : Dict String { outline : PkgOutline, sources : Dict String String }
}
type alias MakeFlags =
{ optimize : Bool
, sourcemaps : Bool
, output : Maybe MakeOutput
, report : Maybe {}
, projectPath : Path
, entryPoints : Array ModuleName
, outline : Outline
, rootSources : Dict String SourceFile
, dependencies : Dict String { outline : PkgOutline, sources : Dict String String }
}
type MakeOutput
= StdOut
| DevNull
| Html String
| Js String
| Exe String
type alias DocsFlags =
{ output : Maybe DocsOutput
, report : Maybe {}
, projectPath : Path
, outline : Outline
, rootSources : Dict String SourceFile
, dependencies : Dict String { outline : PkgOutline, sources : Dict String String }
}
type DocsOutput
= DocsStdOut
| DocsDevNull
| DocsJson String
type alias PackageValidateFlags =
{ projectPath : Path
, knownVersions : Array SemanticVersion
, previousVersion : Maybe { outline : Outline, rootSources : Dict String SourceFile , dependencies : Dict String { outline : PkgOutline , sources : Dict String String }
}
, currentVersion : { outline : Outline, rootSources : Dict String SourceFile , dependencies : Dict String { outline : PkgOutline , sources : Dict String String }
}
}
type alias PackageDiffFlags =
{ projectPath : Path
, firstPackage : { outline : Outline, rootSources : Dict String SourceFile , dependencies : Dict String { outline : PkgOutline , sources : Dict String String }
}
, secondPackage : { outline : Outline, rootSources : Dict String SourceFile , dependencies : Dict String { outline : PkgOutline , sources : Dict String String }
}
}
type alias SourceFile = { path : Path, data : String }
encodeCommand :
{ interactiveSession : Bool
, pathToString : Path -> String
}
-> Command
-> Bytes

Encode a backend command to JSON. This should be fed to the compiler backend upon initialization.

run : Permission -> RunOptions msg -> Cmd msg

Execute the compiler backend. The backend will write to stdout and stderr. There's currently no way to redirect what is written to these streams.