|
|
|
|
|
by charlieflowers
3507 days ago
|
|
Ah, I found it: https://wiki.haskell.org/Type_witness In my own words, a "type witness" is a Haskell idiom (maybe broader?) that allows you to perform dynamic casts. Here's the first example from that link: A simple witness type might be defined over the Int, Bool and Char types like so: data Witness a where
IntWitness :: Witness Int
BoolWitness :: Witness Bool
CharWitness :: Witness Char dynamicCast IntWitness IntWitness pa = Just pa dynamicCast BoolWitness BoolWitness pa = Just pa dynamicCast CharWitness CharWitness pa = Just pa dynamicCast _ _ _ = Nothing |
|