Here's a port of one of the examples I used in the old-and-now-deprecated lib:
http://share-elm.com/sprout/54ebc9aae4b09711f39c2d6e
However, do try to figure out the lib from the function signatures. They should tell you everything you need to know – with the exception of `String` which is a useless type when it comes to documentation, but in e.g. the Decode module you know it's all about JSON decoding, so you can assume `String` means "any string with raw JSON".
And more importantly, the types tell you more about the possibilities of usage than any given anecdotal example.
See the first thing you have in the
docs:
decodeString : Decoder a -> String -> Result String a
Ok, the function needs a `Decoder a` and a `String`. That's easy, we just need a `Decoder` and a `String`.
For the `String` we can just make up any garbage just to see what happens. But where to get a `Decoder` from? Well, there better be a function somewhere that produces one! And indeed in the docs you see plenty of them in the "Primitives" section.
So let's try it with `int`:
import Graphics.Element (Element, flow, down)
import Text as T
import Json.Decode (..)
x = decodeString int "xczcxzcz"
main = T.asText x
You get Err ("Unexpected token x") as a result.
OK so it couldn't decode the string "xczcxzcz" into an int. Makes sense!
How about decodeString int "42"?
You get Ok 42
And so on.