Report a paste

Please put a quick comment for the admin.

If it looks like spam, the admin will mark it as spam so that the spam filter picks it up in the future.

If the paste contains something private or offensive, it'll probably just be deleted.

No title

data Item = Item
    { _item_title :: Text
    , _item_author :: Text
    } deriving (Eq, Show)
makeLenses ''Item

data ItemModification
    = UpdateTitle Text
    | UpdateAuthor Text
data ItemPatch = ItemPatch [ItemModification]
instance Patch ItemPatch where
    type PatchTarget ItemPatch = Item -- Make it better use DMap?
    apply (ItemPatch mods) orig = Just $ mods <&> (\case (UpdateTitle t) -> item_title .~ t; (UpdateAuthor t) -> item_author .~ t) & foldl (&) orig
data ItemPatch2 = ItemPatch2 (DMap ItemTag Identity)

instance Patch ItemPatch2 where
    type PatchTarget ItemPatch2 = Item
    apply (ItemPatch2 mods) orig = Just $
        [ (item_title .~) <$> (mods & DM.lookup TitleTag <&> runIdentity)
        , (item_author .~) <$> (mods & DM.lookup AuthorTag <&> runIdentity) ] & catMaybes & foldl (&) orig

data ItemTag a where
    TitleTag :: ItemTag Text
    AuthorTag :: ItemTag Text