Hi there,

I'm fairly new in Functional Programming and Elm language and I was hoping 
someone could tell me if what I'm doing is correct or it goes against Elm 
and its pure functions. I have a model, defaultModel, with some values by 
default. I have a couple functions that create a new model using 
defaultModel as a template, but I'm not passing this model, which makes me 
doubt about the correct use of pure functions. Let's have a look at this 
with an example:

type alias Model =
  { prop1 : String
  , prop2 : Int
  , prop3 : Bool
  }

defaultModel : Model
defaultModel =
  { prop1 = "Test"
  , prop2 = 5
  , prop3 = True
  }



createModelWithProp1Something : Model
createModelWithProp1Something =
  { defaultModel | prop1 = "Something" }


createModelWithProp2Ten : Model
createModelWithProp2Ten =
  { defaultModel | prop2 = 10 }

createModelWithProp3False : Model
createModelWithProp3False =
  { defaultModel | prop3 = False }

So the question is, is it correct to use this defaultModel inside these 
functions without passing it in?, If it's not, could anyone explain me 
why?. I have the feeling that it goes against pure functions, but I'm 
thinking, defaultModel won't ever be mutated, so no risk of side effects.

Thanks a lot in advance

Fran

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to