[Haskell-cafe] An arrow transformer
Roman Cheplyaka
roma at ro-che.info
Sat Feb 8 17:12:47 UTC 2014
I wrote (and found useful) the following arrow transformer:
data Partial ar a b
= Partial (ErrorArrow () ar a b)
| Total (ar a b)
toPartial :: ArrowChoice ar => Partial ar a b -> ErrorArrow () ar a b
toPartial (Partial f) = f
toPartial (Total sf) = liftError sf
instance ArrowChoice ar => Category (Partial ar) where
id = Total id
Total f . Total g = Total $ f . g
f . g = Partial $ toPartial f . toPartial g
instance ArrowChoice ar => Arrow (Partial ar) where
arr = Total . arr
first (Total f) = Total $ first f
first (Partial f) = Partial $ first f
It allows to work with partial functions/arrows and at the same time
tracks which of them are actually total.
I wonder if it is already defined somewhere or is perhaps an instance of
a more general construction.
Roman
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20140208/35a54ea6/attachment.sig>
More information about the Haskell-Cafe
mailing list