开云体育

ctrl + shift + ? for shortcuts
© 2025 开云体育

Ordering In Bluespec


 

Does Bluespec Haskell have an equivalent for the following Haskell code?

```hs
data Size = Small | Medium | Large deriving (Eq, Show)
instance Ord Size where
? ? compare Small ?Small ?= EQ
? ? compare Small ?_ ? ? ?= LT
? ? compare Medium Small ?= GT
? ? compare Medium Medium = EQ
? ? compare Medium Large ?= LT
? ? compare Large ?Large ?= EQ
? ? compare Large ?_ ? ? ?= GT
```


 

I don't believe there's a Size type in the library, if that's what you're asking?? You can define an equivalent in BH, of course:

data Size = Small | Medium | Large deriving (Eq)


instance Ord Size where

? ? compare Small? Small? = EQ

? ? compare Small? _? ? ? = LT

? ? compare Medium Small? = GT

? ? compare Medium Medium = EQ

? ? compare Medium Large? = LT

? ? compare Large? Large? = EQ

? ? compare Large? _? ? ? = GT


(I only derived Eq, because CShow is available for types automatically without having to derive anything, because it's defined on Generic which is autoderived for everything.? You could derive FShow, if you wanted, though.)

J

On Wed, Mar 5, 2025 at 1:09?AM Yehowshua Immanuel via <programmed4jesus=[email protected]> wrote:
Does Bluespec Haskell have an equivalent for the following Haskell code?

```hs
data Size = Small | Medium | Large deriving (Eq, Show)
instance Ord Size where
? ? compare Small ?Small ?= EQ
? ? compare Small ?_ ? ? ?= LT
? ? compare Medium Small ?= GT
? ? compare Medium Medium = EQ
? ? compare Medium Large ?= LT
? ? compare Large ?Large ?= EQ
? ? compare Large ?_ ? ? ?= GT
```