CacheSim/src/CacheSim/Hierarchy.elm

24 lines
874 B
Elm

module CacheSim.Hierarchy exposing (..)
import CacheSim.Cache exposing (..)
type alias CacheModelHierarchy = List CacheModel
type alias CacheHierarchy = List Cache
accessCacheHierarchy : WordAddr -> CacheHierarchy -> Result String (List (AccessEffect Cache))
accessCacheHierarchy wa ch =
case ch of
[] -> Ok []
c::cs ->
case accessCache wa c of
Ok { result, output } ->
case result of
Hit ->
Ok [ { result = Hit, output = output } ]
Miss ->
Result.map ((::) { result = Miss, output = output })
<| accessCacheHierarchy wa cs
Err e -> Err e
freshCacheHierarchy : CacheModelHierarchy -> CacheHierarchy
freshCacheHierarchy cmh = List.map freshCache cmh