Hacker News new | ask | show | jobs
by Tarean 3246 days ago
That's reasonably similar to handwritten haskell json parsing:

    instance FromJson HintTemplate where
        parseJson = withObject $ \o ->
           HintTemplate
             <$> o .: "ID"
             <*> o .: "Text"
             <*> o .:  "Image"
I wrote <$> and <> out but there is a definition like map3:

    liftA3 f a b = f <$> a <*> b
This works for all applicatives, though. Is it normal for elm libraries to copy paste code like the map3 definition?
1 comments

Not sure what you mean. It's normal that different packages have their own version of a given function, like List.map3, Json.map3 etc. But the implementation is different, so it's not copy-paste. It has to be this way in cases where generic types is not enough and something like interfaces/typeclasses is required.