Fixed a couple of bugs

This commit is contained in:
iko 2023-08-02 16:57:41 +03:00
parent 4c68317223
commit f7c504d0e2
Signed by untrusted user: iko
GPG Key ID: 82C257048D1026F2
4 changed files with 15 additions and 15 deletions

View File

@ -14,17 +14,17 @@ import Bytes.Encode as BE
empty : BitWriter
empty =
BitWriter { running = Nothing, collected = BE.sequence [], offset = 0 }
BitWriter { running = Nothing, collected = [], offset = 0 }
run : BitWriter -> Bytes
run (BitWriter { running, collected }) =
case running of
Nothing ->
BE.encode collected
BE.encode (collected |> List.reverse |> BE.sequence)
Just { value } ->
BE.sequence [ collected, BE.unsignedInt8 value ] |> BE.encode
BE.sequence (BE.unsignedInt8 value :: collected |> List.reverse) |> BE.encode
type BitWriter
@ -35,7 +35,7 @@ type BitWriter
, length : Int
}
, offset : Int
, collected : BE.Encoder
, collected : List BE.Encoder
}
@ -68,7 +68,7 @@ bit b (BitWriter { running, collected, offset }) =
if length == 7 then
BitWriter
{ running = Nothing
, collected = BE.sequence [ collected, BE.unsignedInt8 newValue ]
, collected = BE.unsignedInt8 newValue :: collected
, offset = newOffset
}

View File

@ -98,7 +98,7 @@ toNoun eventId req =
C.cell (C.cord app) (C.listOf C.cord path)
Unsubscribe subId ->
C.cell (C.cord "usubscribe") <|
C.cell (C.cord "unsubscribe") <|
C.cell (C.int eventId) (C.int subId)
Poke { ship, agent, mark, noun } ->

View File

@ -178,7 +178,7 @@ update inp msg model =
processUrSubs
model.eventId
model.subscriptions
(inp.urbitSubscriptions model.app |> (\(Ur.Sub.Internal.Sub x) -> x))
(inp.urbitSubscriptions appModel |> (\(Ur.Sub.Internal.Sub x) -> x))
( eventId_, cmds, urReqs ) =
processCmd subsResult.eventId appCmds
@ -282,7 +282,7 @@ update inp msg model =
( model, Cmd.none )
else
case D.run (D.cell D.ignore (D.cell D.ignore deconstructor) |> D.map (\((), ((), m)) -> m)) rest of
case D.run (D.cell D.ignore (D.cell D.ignore deconstructor) |> D.map (\( (), ( (), m ) ) -> m)) rest of
Just subMsg ->
( model_, pureCmd (AppMsg subMsg) )

View File

@ -29,24 +29,24 @@ decode string =
-- 0w
|> List.drop 2
go : List Char -> BW.BitWriter -> BW.BitWriter
go cs writer =
go : List Char -> List Int -> BW.BitWriter -> BW.BitWriter
go cs append writer =
case cs of
[] ->
writer
BW.bits append writer
'.' :: rest ->
go rest writer
go rest append writer
c :: rest ->
case Dict.get c charToBits of
Just bits ->
go rest writer |> BW.bits bits
go rest (bits ++ append) writer
Nothing ->
go rest writer
go rest [] writer
in
BW.run (go chars BW.empty)
BW.run (go chars [] BW.empty)
{-| -}