Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
j-mie6 committed Jan 16, 2024
1 parent c3645d4 commit b50ce27
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions src/Text/Gigaparsec/Token/Numeric.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{-# LANGUAGE Safe #-}
{-# LANGUAGE DataKinds, KindSignatures, ConstraintKinds, MultiParamTypeClasses, AllowAmbiguousTypes, FlexibleInstances, FlexibleContexts, UndecidableInstances, ApplicativeDo, TypeFamilies, TypeOperators, CPP #-}
{-# LANGUAGE DataKinds, ConstraintKinds, MultiParamTypeClasses, AllowAmbiguousTypes, FlexibleInstances, FlexibleContexts, UndecidableInstances, ApplicativeDo, TypeFamilies, TypeOperators, CPP #-}
-- TODO: refine, move to Internal
module Text.Gigaparsec.Token.Numeric (module Text.Gigaparsec.Token.Numeric) where

Expand Down Expand Up @@ -54,9 +54,8 @@ type family BitWidth t where
BitWidth Word16 = 'B16
BitWidth Int8 = 'B8
BitWidth Word8 = 'B8
BitWidth a
= TypeError ('Text "The type '" ' :<>: 'ShowType a
' :<>: 'Text "' is not a numeric type supported by Gigaparsec")
BitWidth a = TypeError ('Text "The type '" ' :<>: 'ShowType a
':<>: 'Text "' is not a numeric type supported by Gigaparsec")

Check warning on line 58 in src/Text/Gigaparsec/Token/Numeric.hs

View workflow job for this annotation

GitHub Actions / GHC latest, Cabal latest

The suffix use of a ‘:<>:’ might be repurposed as special syntax

Check warning on line 58 in src/Text/Gigaparsec/Token/Numeric.hs

View workflow job for this annotation

GitHub Actions / GHC latest, Cabal latest

The suffix use of a ‘:<>:’ might be repurposed as special syntax

Check warning on line 58 in src/Text/Gigaparsec/Token/Numeric.hs

View workflow job for this annotation

GitHub Actions / GHC latest, Cabal latest

The suffix use of a ‘:<>:’ might be repurposed as special syntax

Check warning on line 58 in src/Text/Gigaparsec/Token/Numeric.hs

View workflow job for this annotation

GitHub Actions / GHC latest, Cabal latest

The suffix use of a ‘:<>:’ might be repurposed as special syntax

type Signedness :: *
data Signedness = Signed | Unsigned
Expand All @@ -74,34 +73,33 @@ type family IsSigned t s where
IsSigned Word16 'Unsigned = ()
IsSigned Int8 'Signed = ()
IsSigned Word8 'Unsigned = ()
IsSigned a 'Signed
= TypeError ('Text "The type '" ' :<>: 'ShowType a ' :<>: 'Text "' does not hold signed data")
IsSigned a 'Unsigned
= TypeError ('Text "The type '" ' :<>: 'ShowType a
' :<>: 'Text "' does not hold unsigned data")
IsSigned a 'Signed = TypeError ('Text "The type '" ':<>: 'ShowType a

Check warning on line 76 in src/Text/Gigaparsec/Token/Numeric.hs

View workflow job for this annotation

GitHub Actions / GHC latest, Cabal latest

The suffix use of a ‘:<>:’ might be repurposed as special syntax

Check warning on line 76 in src/Text/Gigaparsec/Token/Numeric.hs

View workflow job for this annotation

GitHub Actions / GHC latest, Cabal latest

The suffix use of a ‘:<>:’ might be repurposed as special syntax

Check warning on line 76 in src/Text/Gigaparsec/Token/Numeric.hs

View workflow job for this annotation

GitHub Actions / GHC latest, Cabal latest

The suffix use of a ‘:<>:’ might be repurposed as special syntax

Check warning on line 76 in src/Text/Gigaparsec/Token/Numeric.hs

View workflow job for this annotation

GitHub Actions / GHC latest, Cabal latest

The suffix use of a ‘:<>:’ might be repurposed as special syntax
':<>: 'Text "' does not hold signed data")

Check warning on line 77 in src/Text/Gigaparsec/Token/Numeric.hs

View workflow job for this annotation

GitHub Actions / GHC latest, Cabal latest

The suffix use of a ‘:<>:’ might be repurposed as special syntax

Check warning on line 77 in src/Text/Gigaparsec/Token/Numeric.hs

View workflow job for this annotation

GitHub Actions / GHC latest, Cabal latest

The suffix use of a ‘:<>:’ might be repurposed as special syntax

Check warning on line 77 in src/Text/Gigaparsec/Token/Numeric.hs

View workflow job for this annotation

GitHub Actions / GHC latest, Cabal latest

The suffix use of a ‘:<>:’ might be repurposed as special syntax

Check warning on line 77 in src/Text/Gigaparsec/Token/Numeric.hs

View workflow job for this annotation

GitHub Actions / GHC latest, Cabal latest

The suffix use of a ‘:<>:’ might be repurposed as special syntax
IsSigned a 'Unsigned = TypeError ('Text "The type '" ' :<>: 'ShowType a
':<>: 'Text "' does not hold unsigned data")

Check warning on line 79 in src/Text/Gigaparsec/Token/Numeric.hs

View workflow job for this annotation

GitHub Actions / GHC latest, Cabal latest

The suffix use of a ‘:<>:’ might be repurposed as special syntax

Check warning on line 79 in src/Text/Gigaparsec/Token/Numeric.hs

View workflow job for this annotation

GitHub Actions / GHC latest, Cabal latest

The suffix use of a ‘:<>:’ might be repurposed as special syntax

Check warning on line 79 in src/Text/Gigaparsec/Token/Numeric.hs

View workflow job for this annotation

GitHub Actions / GHC latest, Cabal latest

The suffix use of a ‘:<>:’ might be repurposed as special syntax

Check warning on line 79 in src/Text/Gigaparsec/Token/Numeric.hs

View workflow job for this annotation

GitHub Actions / GHC latest, Cabal latest

The suffix use of a ‘:<>:’ might be repurposed as special syntax

type ShowBits :: Bits -> ErrorMessage
type ShowBits b = 'ShowType (BitsNat b)

-- This is intentionally not a type alias. On GHC versions < 9.4.1 it appears that TypeErrors are
-- reported slightly more eagerly and we get an error on this definition because
-- reported slightly more eagerly and we get an error on this definition because
-- > BitsNat b <=? BitsNat (BitWidth t)
-- cannot be solved
type SatisfiesBound :: * -> Bits -> Constraint
type family SatisfiesBound t b where
SatisfiesBound t b
= Assert (BitsNat b <=? BitsNat (BitWidth t)) (TypeError ('Text "The type '"
' :<>: 'ShowType t ' :<>: 'Text "' does not have enough bit-width to store "
' :<>: ShowBits (BitWidth t) ' :<>: 'Text " bits of data (can only store up to "
' :<>: ShowBits b ' :<>: 'Text " bits)."))
SatisfiesBound t b = Assert (BitsNat b <=? BitsNat (BitWidth t))
(TypeError ('Text "The type '"
':<>: 'ShowType t ' :<>: 'Text "' does not have enough bit-width to store "

Check warning on line 92 in src/Text/Gigaparsec/Token/Numeric.hs

View workflow job for this annotation

GitHub Actions / GHC latest, Cabal latest

The suffix use of a ‘:<>:’ might be repurposed as special syntax

Check warning on line 92 in src/Text/Gigaparsec/Token/Numeric.hs

View workflow job for this annotation

GitHub Actions / GHC latest, Cabal latest

The suffix use of a ‘:<>:’ might be repurposed as special syntax

Check warning on line 92 in src/Text/Gigaparsec/Token/Numeric.hs

View workflow job for this annotation

GitHub Actions / GHC latest, Cabal latest

The suffix use of a ‘:<>:’ might be repurposed as special syntax

Check warning on line 92 in src/Text/Gigaparsec/Token/Numeric.hs

View workflow job for this annotation

GitHub Actions / GHC latest, Cabal latest

The suffix use of a ‘:<>:’ might be repurposed as special syntax
':<>: ShowBits (BitWidth t) ' :<>: 'Text " bits of data (can only store up to "

Check warning on line 93 in src/Text/Gigaparsec/Token/Numeric.hs

View workflow job for this annotation

GitHub Actions / GHC latest, Cabal latest

The suffix use of a ‘:<>:’ might be repurposed as special syntax

Check warning on line 93 in src/Text/Gigaparsec/Token/Numeric.hs

View workflow job for this annotation

GitHub Actions / GHC latest, Cabal latest

The suffix use of a ‘:<>:’ might be repurposed as special syntax
':<>: ShowBits b ' :<>: 'Text " bits)."))

Check warning on line 94 in src/Text/Gigaparsec/Token/Numeric.hs

View workflow job for this annotation

GitHub Actions / GHC latest, Cabal latest

The suffix use of a ‘:<>:’ might be repurposed as special syntax

Check warning on line 94 in src/Text/Gigaparsec/Token/Numeric.hs

View workflow job for this annotation

GitHub Actions / GHC latest, Cabal latest

The suffix use of a ‘:<>:’ might be repurposed as special syntax

type BitBounds :: Bits -> Constraint
class BitBounds b where
upperSigned :: Integer
lowerSigned :: Integer
upperUnsigned :: Integer
bits :: Int
type BitsNat b :: Nat
type BitsNat b :: Nat
instance BitBounds 'B8 where
upperSigned = fromIntegral (maxBound @Int8)
lowerSigned = fromIntegral (minBound @Int8)
Expand Down

0 comments on commit b50ce27

Please sign in to comment.