Skip to content

Instantly share code, notes, and snippets.

View janwirth's full-sized avatar
🎯

Jan Nikolaus Wirth janwirth

🎯
View GitHub Profile
@janwirth
janwirth / Result.d.ts
Last active January 6, 2020 06:22
JS Result Data Type with Typescript Typings
/**
* An either type with more specific semantics
*/
type Result<O, E> = Ok<O> | Err<E>;
interface Ok<O> {
type: "Ok";
value: O;
}
@janwirth
janwirth / RemoteData.d.ts
Last active January 6, 2020 06:22
JS Remote Data Type with Typescript Typings
// Example: RemoteData<HttpError, VehicleList>
export type RemoteData<E, D> = NotAsked | Loading | Failure<E> | Success<D>;
// Example: RemoteDataMatchers<HttpError, VehicleList>
export interface RemoteDataMatchers<E, D, R> {
NotAsked: () => R;
Loading: () => R;
Failure: (E) => R;
Success: (D) => R;
}
Codec libary
- code generation in your IDE
- encoder/decoder pairs for 50% simpler code structure
- codec-independent (codec adapters for JSON, protobuf, cap'n'proto)
- interactive debugger
❯ elm make src/Benchmark.elm
Compiling ...
Success!
-- ERROR -----------------------------------------------------------------------
I ran into something that bypassed the normal error reporting process! I
extracted whatever information I could from the internal error:
> Error from `Benchmark` should have been reported already.
> CallStack (from HasCallStack):
@janwirth
janwirth / gist:2724f3e2bf77f251eb098d8fc102ba97
Last active April 5, 2020 18:16
development environment elm
- embedded unit tests
- commit hooks (prettier, unit tests etc.)
- impfix & format
- docsify integration
- transparent coder generation
- nicer debug log https://discourse.elm-lang.org/t/nicer-debug-log-console-output/3780
- dead code cleanup
Additional features
@janwirth
janwirth / elm-toolbox.md
Last active April 30, 2022 05:34
A productive elm programmers toolbox
@janwirth
janwirth / elm.cabal
Last active June 17, 2023 02:40
Build elm for M1
Name: elm
Version: 0.19.1
Synopsis:
The `elm` command line interface.
Description:
This includes commands like `elm make`, `elm repl`, and many others
for helping make Elm developers happy and productive.
@janwirth
janwirth / gist:13ef3b0fa09d0c85cbd0a2885e234445
Created March 19, 2022 15:52
Elm slack conversation on Widget APIs and Return helpers.
erlandsona 1 month ago
Feel like I keep running into this as I’m building widget API’s based on other widget API’s…
I keep wishing I had a function with a type signature of msg -> msg -> msg that would behave like Cmd.batch but not require me to make my view signature Html (Cmd msg).
jessta 1 month ago
type Msg = Batch (List Msg) | Pizza | Pies
jessta 1 month ago
Is that what you mean?
SiriusStarr:bird: 12 hours ago
Is there any community consensus on the 14 different Dicts that allow custom types? Or a comparison of them all? Not really sure which to go with.
Jan Wirth 12 hours ago
Welcome to the growing elm ecosystem.
/* common */
.funk-dropdown-contents {
z-index: 1000;
}
funk-dropdown:not(.open) .funk-dropdown-contents {
pointer-events: none !important;
opacity: 0;
display: none;
}