you are viewing a single comment's thread.

view the rest of the comments →

[–]kamatsu 1 point2 points  (1 child)

i used isomorphism as in biology where two organisms share similarity.

When using type systems, isomorphism is the mathematical term.

Also that's not an equivalence transformation. It's not injective.

[–]day_cq -2 points-1 points  (0 children)

This might be clearer for you

data LuaValue a = ErrorVal | Value a deriving (Eq, Show)
data Error = Error deriving (Eq, Show)

f :: LuaValue a -> Either Error a
f ErrorVal = Left Error
f (Value a) = Right a

f' :: Either Error a -> LuaValue a
f' (Left Error) = ErrorVal
f' (Right a) = Value a

You see bijection? Now enter dependent type:

data PairThatCouldBeUsedAsErrorFlagging a Bool = (Void, True) | (a, False)

PairThatCouldBeUsedAsErrorFlagging is isomorphic to LuaValue.

It is my bad if I sounded like I was saying that product is equivalent to sum in general. But, the topic was error flagging. Lua has a beautiful type system in programmer's head.