Commit 006e0e08 by Zachary Snow

fixed struct pattern field ordering

parent 346d7efb
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
module Convert.Struct (convert) where module Convert.Struct (convert) where
import Data.Maybe (isJust) import Data.Maybe (fromJust, isJust)
import Data.List (sortOn) import Data.List (elemIndex, sortOn)
import Data.Tuple (swap) import Data.Tuple (swap)
import Control.Monad.Writer import Control.Monad.Writer
import qualified Data.Map.Strict as Map import qualified Data.Map.Strict as Map
...@@ -229,8 +229,9 @@ convertAsgn structs types (lhs, expr) = ...@@ -229,8 +229,9 @@ convertAsgn structs types (lhs, expr) =
then zip (map (Just. snd) fields) (map snd items) then zip (map (Just. snd) fields) (map snd items)
else items else items
items'' = map subMap items' items'' = map subMap items'
fieldRange = \(Just x, _) -> lookupUnstructRange structTf x fieldNames = map snd fields
exprs = map snd $ reverse $ sortOn fieldRange items'' itemPosition = \(Just x, _) -> fromJust $ elemIndex x fieldNames
exprs = map snd $ sortOn itemPosition items''
convertExpr _ other = other convertExpr _ other = other
-- try expression conversion by looking at the *innermost* type first -- try expression conversion by looking at the *innermost* type first
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment