{-# LANGUAGE DataKinds #-} module Two where import Text.Read (readPrec, Lexeme(Ident), lexP) data Two (b :: Bool) where Zero :: Two False One :: Two True instance Read (Two False) where readPrec = do Ident "Zero" <- lexP pure Zero instance Read (Two True) where readPrec = do Ident "One" <- lexP pure One noConstraint :: String -> Two b noConstraint = read