Package hydra.haskell
Interface Utils
-
public interface UtilsUtilities for working with Haskell syntax trees
-
-
Method Summary
Static Methods Modifier and Type Method Description static PatternapplicationPattern(Name name, java.util.List<Pattern> args)Create an application pattern from a name and argument patternsstatic NameelementReference(ModuleNames<ModuleName> namespaces, Name name)Generate a Haskell name reference for a Hydra elementstatic Expressionhsapp(Expression l, Expression r)Create a Haskell function application expressionstatic Expressionhslambda(Name name, Expression rhs)Create a Haskell lambda expressionstatic Expressionhslit(Literal lit)Create a Haskell literal expressionstatic Expressionhsvar(java.lang.String s)Create a Haskell variable expression from a stringstatic <T0> Either<Error_,ModuleNames<ModuleName>>namespacesForModule(Module mod, T0 cx, Graph g)Compute the Haskell module namespaces for a Hydra modulestatic <T1> java.util.Map<ModuleName,java.lang.Integer>namespacesForModule_growStep(java.util.function.Function<java.util.List<java.lang.String>,java.util.function.Function<java.lang.Integer,ModuleName>> aliasFromSuffix, java.util.List<ModuleName> nssAsList, java.util.function.Function<ModuleName,java.util.List<java.lang.String>> segsFor, java.util.Map<ModuleName,java.lang.Integer> state, T1 _ign)static <T1> java.lang.IntegernamespacesForModule_takenFor(java.util.Map<T1,java.lang.Integer> state, T1 nm)static java.lang.StringnewtypeAccessorName(Name name)Generate an accessor name for a newtype wrapper (e.g., 'unFoo' for Foo)static NamerawName(java.lang.String n)Create a raw Haskell name from a string without sanitizationstatic NamerecordFieldReference(ModuleNames<ModuleName> namespaces, Name sname, Name fname)Generate a Haskell name for a record field accessorstatic java.lang.StringsanitizeHaskellName(java.lang.String v1)Sanitize a string to be a valid Haskell identifier, escaping reserved wordsstatic NamesimpleName(java.lang.String arg_)Create a sanitized Haskell name from a stringstatic ValueBindingsimpleValueBinding(Name hname, Expression rhs, Optional<LocalBindings> bindings)Create a simple value binding (e.g., 'foo = expr' or 'foo = expr where ...')static TypetoTypeApplication(java.util.List<Type> types)Convert a list of types into a nested type applicationstatic java.lang.StringtypeNameForRecord(Name sname)Extract the local type name from a fully qualified record type namestatic NameunionFieldReference(java.util.Set<Name> boundNames, ModuleNames<ModuleName> namespaces, Name sname, Name fname)Generate a Haskell name for a union variant constructor, with disambiguationstatic Pair<java.util.List<Name>,Type>unpackForallType(Type t)Unpack nested forall types into a list of type variables and the inner type
-
-
-
Method Detail
-
applicationPattern
static Pattern applicationPattern(Name name, java.util.List<Pattern> args)
Create an application pattern from a name and argument patterns
-
elementReference
static Name elementReference(ModuleNames<ModuleName> namespaces, Name name)
Generate a Haskell name reference for a Hydra element
-
hsapp
static Expression hsapp(Expression l, Expression r)
Create a Haskell function application expression
-
hslambda
static Expression hslambda(Name name, Expression rhs)
Create a Haskell lambda expression
-
hslit
static Expression hslit(Literal lit)
Create a Haskell literal expression
-
hsvar
static Expression hsvar(java.lang.String s)
Create a Haskell variable expression from a string
-
namespacesForModule
static <T0> Either<Error_,ModuleNames<ModuleName>> namespacesForModule(Module mod, T0 cx, Graph g)
Compute the Haskell module namespaces for a Hydra module
-
namespacesForModule_growStep
static <T1> java.util.Map<ModuleName,java.lang.Integer> namespacesForModule_growStep(java.util.function.Function<java.util.List<java.lang.String>,java.util.function.Function<java.lang.Integer,ModuleName>> aliasFromSuffix, java.util.List<ModuleName> nssAsList, java.util.function.Function<ModuleName,java.util.List<java.lang.String>> segsFor, java.util.Map<ModuleName,java.lang.Integer> state, T1 _ign)
-
namespacesForModule_takenFor
static <T1> java.lang.Integer namespacesForModule_takenFor(java.util.Map<T1,java.lang.Integer> state, T1 nm)
-
newtypeAccessorName
static java.lang.String newtypeAccessorName(Name name)
Generate an accessor name for a newtype wrapper (e.g., 'unFoo' for Foo)
-
rawName
static Name rawName(java.lang.String n)
Create a raw Haskell name from a string without sanitization
-
recordFieldReference
static Name recordFieldReference(ModuleNames<ModuleName> namespaces, Name sname, Name fname)
Generate a Haskell name for a record field accessor
-
sanitizeHaskellName
static java.lang.String sanitizeHaskellName(java.lang.String v1)
Sanitize a string to be a valid Haskell identifier, escaping reserved words
-
simpleName
static Name simpleName(java.lang.String arg_)
Create a sanitized Haskell name from a string
-
simpleValueBinding
static ValueBinding simpleValueBinding(Name hname, Expression rhs, Optional<LocalBindings> bindings)
Create a simple value binding (e.g., 'foo = expr' or 'foo = expr where ...')
-
toTypeApplication
static Type toTypeApplication(java.util.List<Type> types)
Convert a list of types into a nested type application
-
typeNameForRecord
static java.lang.String typeNameForRecord(Name sname)
Extract the local type name from a fully qualified record type name
-
unionFieldReference
static Name unionFieldReference(java.util.Set<Name> boundNames, ModuleNames<ModuleName> namespaces, Name sname, Name fname)
Generate a Haskell name for a union variant constructor, with disambiguation
-
-