on master help sign in
Added more docs
cd4f7e5iko
src/Ur.elm+18−2
@@ -56,7 +56,22 @@ getShipName root =
56 }
56 }
57
57
58
58
59+{-| Scry an agent at some path
60+
61+ scry
62+ { url = "http://localhost:8080"
63+ , agent = "journal"
64+ , path = [ "entries", "all" ]
65+ , error = Noop
66+ , success =
67+ D.cell D.ignore
68+ (D.cell (D.const D.cord "jrnl")
69+ (D.list (D.cell D.bigint D.cord |> D.map (\a b -> ( a, b ))))
70+ |> D.map GotListings
71+ )
72+ }
73+
59−{-| -}
74+-}
60scry :
75scry :
61 { url : String
76 { url : String
62 , agent : Agent
77 , agent : Agent
@@ -69,7 +84,8 @@ scry args =
69 scryTask args |> Task.perform identity
84 scryTask args |> Task.perform identity
70
85
71
86
87+{-| Same as `scry` but returns a `Task` instead of a `Cmd`.
72−{-| -}
88+-}
73scryTask :
89scryTask :
74 { url : String
90 { url : String
75 , agent : Agent
91 , agent : Agent
src/Ur/Cmd.elm+18−5
@@ -10,30 +10,43 @@ import Ur.Cmd.Internal
10import Ur.Types exposing (Agent, Mark, Noun, Ship)
10import Ur.Types exposing (Agent, Mark, Noun, Ship)
11
11
12
12
13+{-| Like `Cmd` from `Platform.Cmd`, but for Urbit commands.
13−{-| -}
14+-}
14type alias Cmd msg =
15type alias Cmd msg =
15 List (Ur.Cmd.Internal.Cmd msg)
16 List (Ur.Cmd.Internal.Cmd msg)
16
17
17
18
19+{-| A command that does exactly nothing.
18−{-| -}
20+-}
19none : Cmd msg
21none : Cmd msg
20none =
22none =
21 []
23 []
22
24
23
25
26+{-| Sends a %poke to a Gall Agent.
27+
28+ poke
29+ { ship = "~zod"
30+ , agent = "journal"
31+ , mark = "journal-action"
32+ , noun = C.cell (C.cord "del") (C.bigint id)
33+ }
34+
24−{-| -}
35+-}
25poke : { ship : Ship, agent : Agent, mark : Mark, noun : Noun } -> Cmd msg
36poke : { ship : Ship, agent : Agent, mark : Mark, noun : Noun } -> Cmd msg
26poke p =
37poke p =
27 [ Ur.Cmd.Internal.Poke p ]
38 [ Ur.Cmd.Internal.Poke p ]
28
39
29
40
41+{-| Turns a `Platform.Cmd` command into a `Ur.Cmd` command.
30−{-| -}
42+-}
31cmd : Cmd.Cmd msg -> Cmd msg
43cmd : Cmd.Cmd msg -> Cmd msg
32cmd c =
44cmd c =
33 [ Ur.Cmd.Internal.Cmd c ]
45 [ Ur.Cmd.Internal.Cmd c ]
34
46
35
47
48+{-| Batches multiple commands into one. Similar to `Platform.Cmd.batch`.
36−{-| -}
49+-}
37batch : List (Cmd msg) -> Cmd msg
50batch : List (Cmd msg) -> Cmd msg
38batch =
51batch =
39 List.concat
52 List.concat
src/Ur/Da.elm+1−1
@@ -26,7 +26,7 @@ second =
26 BigInt.fromIntString "18446744073709551616" |> Maybe.withDefault (BigInt.fromInt 0)
26 BigInt.fromIntString "18446744073709551616" |> Maybe.withDefault (BigInt.fromInt 0)
27
27
28
28
29−{-| Converts `Posix` to a `@da`
29+{-| Converts `Posix` to a `@da`.
30-}
30-}
31posixToDa : Posix -> Da
31posixToDa : Posix -> Da
32posixToDa p =
32posixToDa p =
src/Ur/Run.elm+2−2
@@ -1,6 +1,6 @@
1module Ur.Run exposing (element, document, application, Program, Model, Msg)
1module Ur.Run exposing (element, document, application, Program, Model, Msg)
2
2
3−{-|
3+{-| This module contains functions to run your application with Urbit integration.
4
4
5@docs element, document, application, Program, Model, Msg
5@docs element, document, application, Program, Model, Msg
6
6
@@ -64,7 +64,7 @@ type Msg msg
64 | RetryRequests
64 | RetryRequests
65
65
66
66
67−{-| A wrapper around your application `Program`
67+{-| A wrapper around your application `Program`.
68-}
68-}
69type alias Program model msg =
69type alias Program model msg =
70 Platform.Program Flags (Model model msg) (Msg msg)
70 Platform.Program Flags (Model model msg) (Msg msg)
src/Ur/Sub.elm+16−4
@@ -11,24 +11,36 @@ import Ur.Deconstructor as D
11import Ur.Sub.Internal
11import Ur.Sub.Internal
12
12
13
13
14+{-| Like `Sub` from `Platform.Sub`, but for Urbit subscriptions.
14−{-| -}
15+-}
15type alias Sub msg =
16type alias Sub msg =
16 Ur.Sub.Internal.Sub msg
17 Ur.Sub.Internal.Sub msg
17
18
18
19
20+{-| Creates an Urbit subscription.
21+
22+ subscribe
23+ { ship = ship
24+ , app = "journal"
25+ , path = [ "updates" ]
26+ , deconstructor = decodeJournalUpdate |> D.map GotUpdate
27+ }
28+
19−{-| -}
29+-}
20subscribe : { ship : String, app : String, path : List String, deconstructor : D.Deconstructor (msg -> msg) msg } -> Sub msg
30subscribe : { ship : String, app : String, path : List String, deconstructor : D.Deconstructor (msg -> msg) msg } -> Sub msg
21subscribe { ship, app, path, deconstructor } =
31subscribe { ship, app, path, deconstructor } =
22 Dict.singleton ( ship, app, path ) deconstructor |> Ur.Sub.Internal.Sub
32 Dict.singleton ( ship, app, path ) deconstructor |> Ur.Sub.Internal.Sub
23
33
24
34
35+{-| A subscription that does exactly nothing. (Does not subscribe to anything)
25−{-| -}
36+-}
26none : Sub msg
37none : Sub msg
27none =
38none =
28 Ur.Sub.Internal.Sub Dict.empty
39 Ur.Sub.Internal.Sub Dict.empty
29
40
30
41
42+{-| Batch multiple subscriptions into one.
31−{-| -}
43+-}
32batch : List (Sub msg) -> Sub msg
44batch : List (Sub msg) -> Sub msg
33batch subs =
45batch subs =
34 subs |> List.map (\(Ur.Sub.Internal.Sub dict) -> dict) |> List.foldl Dict.union Dict.empty |> Ur.Sub.Internal.Sub
46 subs |> List.map (\(Ur.Sub.Internal.Sub dict) -> dict) |> List.foldl Dict.union Dict.empty |> Ur.Sub.Internal.Sub