Skip to content

Newtype constructor erroneously removed #320

@bwbush

Description

@bwbush

Agda

record Hash (a : Set) : Set where
  constructor MakeHash
  field hashBytes : ByteString
open Hash public
{-# COMPILE AGDA2HS Hash newtype deriving (Generic, Show) #-}

instance
  iMaybeHashable : ⦃ i : Hashable a ⦄  Hashable (Maybe a)
  iMaybeHashable {{_}} .hash Nothing = MakeHash (hashBytes (hash iUnitHashable tt))
  iMaybeHashable {{i}} .hash (Just x) = MakeHash (hashBytes (hash iPairHashable (tt , x)))
{-# COMPILE AGDA2HS iMaybeHashable #-}

becomes Haskell

newtype Hash a = MakeHash{hashBytes :: ByteString}
                   deriving (Generic, Show)

instance (Hashable a) => Hashable (Maybe a) where
    hash Nothing = hash ()
    hash (Just x) = hash ((), x)

even though MakeHash . hashBytes != id since in this case we had MakeHash :: ByteString -> Maybe a but hashBytes :: () -> ByteString etc.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions