Agda type checker rejecting simple definition of a semigroup

49 Views Asked by At

I have defined a Semigroup as follows:

record Semigroup : Set1 where
    field
        X : Set
        e : X
        _◇_  :  X -> X -> X
        assoc : ∀ {x y z} -> (x ◇ y) ◇ z -> x ◇ (y ◇ z)

But I get the following error:

X should be a sort, but it isn't
when checking that the expression (x ◇ y) ◇ z has type _52

Can anyone help me determine what's wrong?

1

There are 1 best solutions below

0
user1023733 On

Never mind, the problem was that (x ◇ y) ◇ z and x ◇ (y ◇ z) were of type X and Agda was expecting them to be of type Set. This code works:

record Semigroup {X} (_≈_ : Rel X): Set1 where
    field
        e : X
        _◇_  :  X -> X -> X
        equivalence : Equivalence _≈_
        assoc : ∀ {x y z} -> ((x ◇ y) ◇ z) ≈ (x ◇ (y ◇ z))