mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-05-20 00:22:51 -06:00
record order bug fix
This commit is contained in:
@@ -156,9 +156,6 @@ redTerm :: Type -> Err G.Exp
|
|||||||
redTerm t = return $ rtExp t
|
redTerm t = return $ rtExp t
|
||||||
|
|
||||||
-- to normalize records and record types
|
-- to normalize records and record types
|
||||||
sortByLabel :: (a -> Label) -> [a] -> [a]
|
|
||||||
sortByLabel f = sortBy (\ x y -> compare (f x) (f y))
|
|
||||||
|
|
||||||
sortByFst :: Ord a => [(a,b)] -> [(a,b)]
|
sortByFst :: Ord a => [(a,b)] -> [(a,b)]
|
||||||
sortByFst = sortBy (\ x y -> compare (fst x) (fst y))
|
sortByFst = sortBy (\ x y -> compare (fst x) (fst y))
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ import GF.Grammar.Abstract
|
|||||||
import GF.Infra.Modules
|
import GF.Infra.Modules
|
||||||
import GF.Grammar.Lockfield
|
import GF.Grammar.Lockfield
|
||||||
|
|
||||||
import Data.List (nub)
|
import Data.List (nub,sortBy)
|
||||||
import Control.Monad
|
import Control.Monad
|
||||||
|
|
||||||
-- whether lock fields are added in reuse
|
-- whether lock fields are added in reuse
|
||||||
@@ -137,12 +137,14 @@ allParamValues cnc ptyp = case ptyp of
|
|||||||
return [EInt i | i <- [0..n]]
|
return [EInt i | i <- [0..n]]
|
||||||
QC p c -> lookupParamValues cnc p c
|
QC p c -> lookupParamValues cnc p c
|
||||||
RecType r -> do
|
RecType r -> do
|
||||||
let (ls,tys) = unzip r
|
let (ls,tys) = unzip $ sortByFst r
|
||||||
tss <- mapM allPV tys
|
tss <- mapM allPV tys
|
||||||
return [R (zipAssign ls ts) | ts <- combinations tss]
|
return [R (zipAssign ls ts) | ts <- combinations tss]
|
||||||
_ -> prtBad "cannot find parameter values for" ptyp
|
_ -> prtBad "cannot find parameter values for" ptyp
|
||||||
where
|
where
|
||||||
allPV = allParamValues cnc
|
allPV = allParamValues cnc
|
||||||
|
-- to normalize records and record types
|
||||||
|
sortByFst = sortBy (\ x y -> compare (fst x) (fst y))
|
||||||
|
|
||||||
qualifAnnot :: Ident -> Term -> Term
|
qualifAnnot :: Ident -> Term -> Term
|
||||||
qualifAnnot _ = id
|
qualifAnnot _ = id
|
||||||
|
|||||||
Reference in New Issue
Block a user