A music player that connects to your cloud/distributed storage.
at main 1.9 kB view raw
1module Tracks.Collection exposing (add, arrange, harvest, identifiedTracksChanged, identify, map, replace, tracksChanged) 2 3import Tracks exposing (IdentifiedTrack, Parcel, Track, emptyCollection) 4import Tracks.Collection.Internal as Internal 5 6 7 8-- 🔱 9 10 11identify : Parcel -> Parcel 12identify = 13 Internal.identify >> Internal.arrange >> Internal.harvest 14 15 16arrange : Parcel -> Parcel 17arrange = 18 Internal.arrange >> Internal.harvest 19 20 21harvest : Parcel -> Parcel 22harvest = 23 Internal.harvest 24 25 26map : (List IdentifiedTrack -> List IdentifiedTrack) -> Parcel -> Parcel 27map fn ( model, collection ) = 28 ( model 29 , { collection 30 | identified = fn collection.identified 31 , arranged = fn collection.arranged 32 , harvested = fn collection.harvested 33 } 34 ) 35 36 37 38-- ⚗️ 39 40 41add : List Track -> Parcel -> Parcel 42add tracks ( deps, { untouched } ) = 43 identify 44 ( deps 45 , { emptyCollection | untouched = untouched ++ tracks } 46 ) 47 48 49replace : List Track -> Parcel -> Parcel 50replace tracks ( deps, { untouched } ) = 51 identify 52 ( deps 53 , { emptyCollection | untouched = tracks } 54 ) 55 56 57 58-- ⚗️ 59 60 61tracksChanged : List Track -> List Track -> Bool 62tracksChanged listA listB = 63 case ( listA, listB ) of 64 ( [], [] ) -> 65 False 66 67 ( a :: restA, b :: restB ) -> 68 if a.id /= b.id then 69 True 70 71 else 72 tracksChanged restA restB 73 74 _ -> 75 True 76 77 78identifiedTracksChanged : List IdentifiedTrack -> List IdentifiedTrack -> Bool 79identifiedTracksChanged listA listB = 80 case ( listA, listB ) of 81 ( [], [] ) -> 82 False 83 84 ( ( _, a ) :: restA, ( _, b ) :: restB ) -> 85 if a.id /= b.id then 86 True 87 88 else 89 identifiedTracksChanged restA restB 90 91 _ -> 92 True