From af37fd6bbd62e790d0c11bfd41ac46ecd9872291 Mon Sep 17 00:00:00 2001 From: Attila Mihaly Date: Fri, 2 Oct 2020 11:17:44 -0400 Subject: [PATCH] Reverted function to method mapping. #163 --- src/Morphir/Scala/Backend.elm | 95 +---------------------------------- 1 file changed, 2 insertions(+), 93 deletions(-) diff --git a/src/Morphir/Scala/Backend.elm b/src/Morphir/Scala/Backend.elm index 844589dff..d63cc4698 100644 --- a/src/Morphir/Scala/Backend.elm +++ b/src/Morphir/Scala/Backend.elm @@ -136,17 +136,7 @@ mapModuleDefinition opt distribution currentPackagePath currentModulePath access ) |> List.singleton , extends = [] - , members = - mapFunctionsToMethods currentPackagePath - currentModulePath - typeName - (accessControlledModuleDef.value.values - |> Dict.toList - |> List.map - (\( valueName, valueDef ) -> - ( valueName, valueDef.value |> Value.definitionToSpecification ) - ) - ) + , members = [] } ) ] @@ -289,17 +279,7 @@ mapCustomTypeDefinition currentPackagePath currentModulePath moduleDef typeName , name = typeName |> Name.toTitleCase , typeArgs = typeParams |> List.map (Name.toTitleCase >> Scala.TypeVar) , extends = [] - , members = - mapFunctionsToMethods currentPackagePath - currentModulePath - typeName - (moduleDef.values - |> Dict.toList - |> List.map - (\( valueName, valueDef ) -> - ( valueName, valueDef.value |> Value.definitionToSpecification ) - ) - ) + , members = [] } ] , accessControlledCtors.value @@ -328,77 +308,6 @@ mapCustomTypeDefinition currentPackagePath currentModulePath moduleDef typeName sealedTraitHierarchy |> List.map Scala.MemberTypeDecl -{-| Collect functions where the last input argument is this type and turn them into methods on the type. --} -mapFunctionsToMethods : Path -> Path -> Name -> List ( Name, Value.Specification ta ) -> List Scala.MemberDecl -mapFunctionsToMethods currentPackageName currentModuleName currentTypeName valueSpecifications = - valueSpecifications - |> List.filterMap - (\( valueName, valueSpec ) -> - case List.reverse valueSpec.inputs of - [] -> - -- if this is a value (function with no arguments) then we don't turn it into a method - Nothing - - ( _, lastInputType ) :: restOfInputsReversed -> - -- if the last argument type of the function is - let - inputs = - List.reverse restOfInputsReversed - in - case lastInputType of - Type.Reference _ fQName [] -> - if fQName == FQName currentPackageName currentModuleName currentTypeName then - Just - (FunctionDecl - { modifiers = [] - , name = valueName |> Name.toCamelCase - , typeArgs = [] - , args = - if List.isEmpty inputs then - [] - - else - [ inputs - |> List.map - (\( argName, argType ) -> - { modifiers = [] - , tpe = mapType argType - , name = argName |> Name.toCamelCase - , defaultValue = Nothing - } - ) - ] - , returnType = - Just (mapType valueSpec.output) - , body = - let - ( path, name ) = - mapFQNameToPathAndName (FQName currentPackageName currentModuleName valueName) - in - Just - (Scala.Apply (Scala.Ref path (name |> Name.toCamelCase)) - (List.append - (inputs - |> List.map - (\( argName, _ ) -> - Scala.ArgValue Nothing (Scala.Variable (argName |> Name.toCamelCase)) - ) - ) - [ Scala.ArgValue Nothing Scala.This ] - ) - ) - } - ) - - else - Nothing - - _ -> - Nothing - ) - - mapType : Type a -> Scala.Type mapType tpe = case tpe of