Question: how do I do that?

Asked By
Asked At
2017-08-09 00:06:54

Found 15 possible answers.

User Answered At Possible Answer
jonf 2017-08-09 00:06:55 well, maybe return a maybe or a result
dterhorst 2017-08-09 00:07:57 by constructor, do you mean a make method, or do you mean the compiler?
jessta 2017-08-09 00:08:44 just a function that takes an Int and returns of value of your IntBetweenZeroAnd29 type
dterhorst 2017-08-09 00:08:52 ah, right thanks that they would even have 31 in the first place because if someone passed in 31 and got out 2, tbh, that’s probably unexpected but I think I’d rather have the custom type In the worst case, I could take an Int and just % 30 so that every possible value of Int is a valid input
jonf 2017-08-09 00:15:09
module MoonDate exposing (MoonDate, make, read)
Nothing else Just (MoonDate day) make day = if day >= 0 || day < 30 then make: Int -> Maybe MoonDate type MoonDate = MoonDate Int
dterhorst 2017-08-09 00:16:11 I think in that case, I wouldn’t want to expose MoonDate ? :thumbsup: that’s definitely more concise than what I have
jonf 2017-08-09 00:16:36 you want expose MoonData but not any of it's constructors
dterhorst 2017-08-09 00:17:35 ah, I think I see. It exposes MoonDate , but not MoonDate.MoonDate ? I was a little confused by the same name for both
jonf 2017-08-09 00:18:14 it exposed MoonDate but not MoonDate(..)
dterhorst 2017-08-09 00:18:33 excellent, thanks
alexxmde 2017-08-09 02:05:24 My crud based on the roleplaying tutorial is working. Thanks to everyone who answered my questions here! I hope I can help others in the future too
boonofcode 2017-08-09 03:41:51 I'm trying to JSON decode a JSON string (originating from C# code), I'm having difficulty parsing a bool If I could squeeze a String.toLower in there prior to decoding somehow..? @boonofcode uploaded a file: Pasted image at 2017-08-09, 1:45 PM I'm using elm-decode-pipeline, and that line of my decoder looks like this I need to decode a title case string as an Elm bool.. any suggestions? @boonofcode uploaded a file: Pasted image at 2017-08-09, 1:41 PM
jessta 2017-08-09 03:59:03 @boonofcode You want a Decoder String that you can pass map with a function to convert that string to a bool giving you a Decoder Bool
boonofcode 2017-08-09 04:03:39 thanks for that, I'll try it I just realised I also have the option of tidying up the data in the JS code prior to sending it through the port
ilias 2017-08-09 08:08:37 @boonofcode string |> map (\s -> if s == "True" then True else False) would work. You could take it further and use andThen so you can bail out of it isn't True or False , too, but this is a good first step

Related Questions