Skip to content

Commit

Permalink
Use an explicit literal
Browse files Browse the repository at this point in the history
  • Loading branch information
dnadales committed Aug 31, 2023
1 parent 24f0c47 commit 2e5e60f
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions cborg/src/Codec/CBOR/FlatTerm.hs
Original file line number Diff line number Diff line change
Expand Up @@ -562,28 +562,28 @@ fromFlatTerm decoder ft =
-- | Map a 'TermToken' to the underlying CBOR 'TokenType'
tokenTypeOf :: TermToken -> TokenType
tokenTypeOf (TkInt n)
| n >= 0 = TypeUInt
| otherwise = TypeNInt
| n >= 0 = TypeUInt
| otherwise = TypeNInt
tokenTypeOf (TkInteger n) -- See https://github.com/well-typed/cborg/issues/324
| n >= 0 && n < 2^64 = TypeUInt64
| n < 0 && n > -2^64 = TypeNInt64
| otherwise = TypeInteger
tokenTypeOf TkBytes{} = TypeBytes
tokenTypeOf TkBytesBegin{} = TypeBytesIndef
tokenTypeOf TkString{} = TypeString
tokenTypeOf TkStringBegin{} = TypeStringIndef
tokenTypeOf TkListLen{} = TypeListLen
tokenTypeOf TkListBegin{} = TypeListLenIndef
tokenTypeOf TkMapLen{} = TypeMapLen
tokenTypeOf TkMapBegin{} = TypeMapLenIndef
tokenTypeOf TkTag{} = TypeTag
tokenTypeOf TkBool{} = TypeBool
tokenTypeOf TkNull = TypeNull
tokenTypeOf TkBreak = TypeBreak
tokenTypeOf TkSimple{} = TypeSimple
tokenTypeOf TkFloat16{} = TypeFloat16
tokenTypeOf TkFloat32{} = TypeFloat32
tokenTypeOf TkFloat64{} = TypeFloat64
| 0 <= n && n <= 0xffffffffffffffff = TypeUInt64
| -0xffffffffffffffff <= n && n < 0 = TypeNInt64
| otherwise = TypeInteger
tokenTypeOf TkBytes{} = TypeBytes
tokenTypeOf TkBytesBegin{} = TypeBytesIndef
tokenTypeOf TkString{} = TypeString
tokenTypeOf TkStringBegin{} = TypeStringIndef
tokenTypeOf TkListLen{} = TypeListLen
tokenTypeOf TkListBegin{} = TypeListLenIndef
tokenTypeOf TkMapLen{} = TypeMapLen
tokenTypeOf TkMapBegin{} = TypeMapLenIndef
tokenTypeOf TkTag{} = TypeTag
tokenTypeOf TkBool{} = TypeBool
tokenTypeOf TkNull = TypeNull
tokenTypeOf TkBreak = TypeBreak
tokenTypeOf TkSimple{} = TypeSimple
tokenTypeOf TkFloat16{} = TypeFloat16
tokenTypeOf TkFloat32{} = TypeFloat32
tokenTypeOf TkFloat64{} = TypeFloat64

--------------------------------------------------------------------------------

Expand Down

0 comments on commit 2e5e60f

Please sign in to comment.