From 81533bbc1505d79a5d584628d8159695ef06db21 Mon Sep 17 00:00:00 2001 From: Brian Hicks Date: Fri, 10 Jan 2020 10:11:26 -0500 Subject: [PATCH] make rules less weird --- src/Adjacency.elm | 29 ++++++----------------------- 1 file changed, 6 insertions(+), 23 deletions(-) diff --git a/src/Adjacency.elm b/src/Adjacency.elm index d7319be..055be64 100644 --- a/src/Adjacency.elm +++ b/src/Adjacency.elm @@ -1,5 +1,9 @@ module Adjacency exposing (DraftRules, Rule, Rules, combineRules, finalize, fromIds) +{-| The draft/final rules distinction is no longer necessary and should really +be cleaned up. +-} + import Array import Dict exposing (Dict) import Direction exposing (Direction) @@ -14,33 +18,12 @@ type alias Rule comparable = type alias Rules comparable = - Dict comparable (List (Rule comparable)) + Dict ( comparable, Direction ) (Set comparable) finalize : DraftRules comparable -> Rules comparable finalize (DraftRules draft) = - Dict.foldl - (\( id, direction ) values dict -> - let - rule = - { direction = direction - , to = values - } - in - Dict.update id - (\maybeRules -> - Just <| - case maybeRules of - Just rules -> - rule :: rules - - Nothing -> - [ rule ] - ) - dict - ) - Dict.empty - draft + draft combineRules : List (Rule comparable) -> List (Rule comparable)