[Haskell-cafe] Concept for "equal but unknown"

Olaf Klinke olf at aatal-apotheke.de
Fri Oct 2 15:36:50 UTC 2015


To me this sounds like the Reader monad: You have a value that depends on something that is yet to be decided upon. 

data SomeCargo = SomeCargo {
  decide_attribute1 :: ContainerID -> Attr1
  decide_attribute2 :: ContainerID -> Attr2
  ...
}

data ConcreteCargo = ConcreteCargo {
  attribute1 :: Attr1
  attribute2 :: Attr2
}

withID :: SomeCargo -> ContainerID -> ConcreteCargo

If the type ContainerID is searchable [1] then you can have an Eq instance even for the SomeCargo type. That is, two containers are equal if whenever the same ID gets assigned, they have the same properties. The technical term would be "indistinguishable in all contexts". 


-- Olaf

[1] http://math.andrej.com/2008/11/21/a-haskell-monad-for-infinite-search-in-finite-time/


More information about the Haskell-Cafe mailing list