Skip to content

Commit

Permalink
Fixed a couple of bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyakooo0 committed Aug 2, 2023
1 parent 4c68317 commit f7c504d
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
10 changes: 5 additions & 5 deletions src/BitWriter.elm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -35,7 +35,7 @@ type BitWriter
, length : Int
}
, offset : Int
, collected : BE.Encoder
, collected : List BE.Encoder
}


Expand Down Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion src/Ur/Requests.elm
Original file line number Diff line number Diff line change
Expand Up @@ -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 } ->
Expand Down
4 changes: 2 additions & 2 deletions src/Ur/Run.elm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) )

Expand Down
14 changes: 7 additions & 7 deletions src/Ur/Uw.elm
Original file line number Diff line number Diff line change
Expand Up @@ -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)


{-| -}
Expand Down

0 comments on commit f7c504d

Please sign in to comment.