Implement Valuable for all Value constructors
This commit is contained in:
parent
fa06f0685a
commit
b84e45ed8f
|
@ -61,12 +61,36 @@ instance Valuable Bool where
|
|||
Bool a -> a
|
||||
_ -> error "unexpected"
|
||||
|
||||
instance Valuable Image where
|
||||
toValue = Image
|
||||
fromValue = \case
|
||||
Image a -> a
|
||||
_ -> error "unexpected"
|
||||
|
||||
instance Valuable ImageConversionSettings where
|
||||
toValue = ImageConversionSettings
|
||||
fromValue = \case
|
||||
ImageConversionSettings a -> a
|
||||
_ -> error "unexpected"
|
||||
|
||||
instance Valuable Template where
|
||||
toValue = Template
|
||||
fromValue = \case
|
||||
Template a -> a
|
||||
_ -> error "unexpected"
|
||||
|
||||
instance Valuable () where
|
||||
toValue () = Empty
|
||||
fromValue = \case
|
||||
Empty -> ()
|
||||
_ -> error "unexpected"
|
||||
|
||||
instance (Valuable a, Valuable b) => Valuable (a, b) where
|
||||
toValue (a, b) = Tuple (toValue a, toValue b)
|
||||
fromValue = \case
|
||||
Tuple (va, vb) -> (fromValue va, fromValue vb)
|
||||
_ -> error "unexpected"
|
||||
|
||||
instance Valuable a => Valuable [a] where
|
||||
toValue = List . map toValue
|
||||
fromValue = \case
|
||||
|
|
Loading…
Reference in New Issue