Skip to content

Wingman goes into auto when attempting to derive semigroup #1678

@isovector

Description

@isovector
data Var = Var
  { t_group :: OneOf Int
  , t_index :: OneOf (Maybe Int)
  }

instance Semigroup Var where
  (<>) = _


data OneOf a
  = Anything
  | NoneOf (Set a)
  | OneOf (Set a)
  deriving (Eq, Ord, Show, Foldable)

instance Ord a => Semigroup (OneOf a) where
  (<>) Anything b = b
  (<>) a Anything = a
  (<>) (NoneOf sa3) (NoneOf sa) = NoneOf $ sa3 <> sa
  (<>) (OneOf sa3)  (NoneOf sa) = OneOf  $ sa3 S.\\ sa
  (<>) (NoneOf sa3) (OneOf sa)  = OneOf  $ sa S.\\ sa3
  (<>) (OneOf sa3)  (OneOf sa)  = OneOf  $ S.intersection sa3 sa

instance Ord a => Monoid (OneOf a) where
  mempty = Anything

Not sure why

Metadata

Metadata

Assignees

No one assigned

    Labels

    component: wingmantype: bugSomething isn't right: doesn't work as intended, documentation is missing/outdated, etc..

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions