1 {-# LANGUAGE OverloadedStrings, TemplateHaskell, TypeFamilies #-} 2 module Databrary.Model.Slot.Types 3 ( SlotId(..) 4 , Slot(..) 5 , slotId 6 , containerSlotId 7 , containerSlot 8 , getSlotReleaseMaybe 9 ) where 10 11 import Databrary.Has (Has(..)) 12 import Databrary.Model.Id 13 import Databrary.Model.Kind 14 import Databrary.Model.Segment 15 import Databrary.Model.Container.Types 16 import Databrary.Model.Permission.Types 17 import Databrary.Model.Release.Types 18 import Databrary.Model.Volume.Types 19 20 data SlotId = SlotId 21 { slotContainerId :: !(Id Container) 22 , slotSegmentId :: !Segment 23 } deriving (Eq, Show) 24 25 type instance IdType Slot = SlotId 26 27 containerSlotId :: Id Container -> Id Slot 28 containerSlotId c = Id $ SlotId c fullSegment 29 30 data Slot = Slot 31 { slotContainer :: !Container 32 , slotSegment :: !Segment 33 } 34 {- 35 instance Show Slot where 36 show _ = "Slot" 37 -} 38 slotId :: Slot -> Id Slot 39 slotId (Slot c s) = Id $ SlotId (containerId (containerRow c)) s 40 41 containerSlot :: Container -> Slot 42 containerSlot c = Slot c fullSegment 43 44 instance Kinded Slot where 45 kindOf _ = "slot" 46 47 instance Has Container Slot where 48 view = slotContainer 49 instance Has (Id Databrary.Model.Volume.Types.Volume) Slot where 50 view = (view . slotContainer) 51 instance Has Databrary.Model.Permission.Types.Permission Slot where 52 view = (view . slotContainer) 53 instance Has Databrary.Model.Volume.Types.Volume Slot where 54 view = (view . slotContainer) 55 instance Has (Maybe Databrary.Model.Release.Types.Release) Slot where 56 view = (view . slotContainer) 57 instance Has (Id Container) Slot where 58 view = (view . slotContainer) 59 instance Has Segment Slot where 60 view = slotSegment 61 62 getSlotReleaseMaybe :: Slot -> Maybe Release 63 getSlotReleaseMaybe = containerRelease . slotContainer 64 ERROR: ("",8,Loc 64 1,[],[(Loc 66 3,Loc 66 31,TopLevelDecl False 1),(Loc 66 3,Loc 66 31,IsTicked),(Loc 66 10,Loc 66 31,IsTicked),(Loc 66 11,Loc 66 14,IsTicked),(Loc 66 18,Loc 66 30,IsTicked),(Loc 68 3,Loc 68 31,TopLevelDecl False 0),(Loc 68 3,Loc 68 31,NotTicked),(Loc 68 10,Loc 68 31,NotTicked),(Loc 68 11,Loc 68 14,NotTicked),(Loc 68 18,Loc 68 30,NotTicked)])