Verified Commit 9fe0136c authored by Camil Staps's avatar Camil Staps 🚀

Rename recordsToFunctions to selectorsToFunctions; correct strictness attributes on the result

parent 952d2341
Pipeline #27182 passed with stage
in 3 minutes and 19 seconds
......@@ -259,7 +259,7 @@ constructorsToFunctions :: !TypeDef -> [(String,Type,Maybe Priority)]
* @param The type definition
* @result A list of tuples of the name and type of the record fields
*/
recordsToFunctions :: !TypeDef -> [(String,Type)]
selectorsToFunctions :: !TypeDef -> [(String,Type)]
/**
* Wrapper around the {{`td_name`}} field of the {{`TypeDef`}} record.
......@@ -276,6 +276,11 @@ td_uniq :: !TypeDef -> Bool
*/
td_rhs :: !TypeDef -> TypeDefRhs
/**
* Make a type strict if it is not strict already.
*/
strict :: !Type -> Type
/**
* Wrapper to create a {{`TypeDef`}} record.
*/
......
......@@ -190,11 +190,15 @@ where
consfun c = (c.cons_name, Func c.cons_args ret c.cons_context, c.cons_priority)
where ret = if td_uniq Uniq id $ Type td_name td_args
recordsToFunctions :: !TypeDef -> [(String,Type)]
recordsToFunctions {td_name,td_uniq,td_args,td_rhs=TDRRecord _ _ fields}
= [(f.rf_name, Func [arg] f.rf_type []) \\ f <- fields]
where arg = if td_uniq Uniq id $ Type td_name td_args
recordsToFunctions _ = []
selectorsToFunctions :: !TypeDef -> [(String,Type)]
selectorsToFunctions {td_name,td_uniq,td_args,td_rhs=TDRRecord _ _ fields}
= [(f.rf_name, Func [strict arg] (unStrict f.rf_type) []) \\ f <- fields]
where
arg = if td_uniq Uniq id $ Type td_name td_args
unStrict t = case t of
Strict t -> t
t -> t
selectorsToFunctions _ = []
td_name :: !TypeDef -> String
td_name {td_name} = td_name
......@@ -205,6 +209,11 @@ td_uniq {td_uniq} = td_uniq
td_rhs :: !TypeDef -> TypeDefRhs
td_rhs {td_rhs} = td_rhs
strict :: !Type -> Type
strict t = case t of
Strict _ -> t
_ -> Strict t
typedef :: !String !Bool ![Type] !TypeDefRhs -> TypeDef
typedef name uniq args rhs
= {td_name=name, td_uniq=uniq, td_args=args, td_rhs=rhs}
......
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