Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move the getter to before type args, add variant3 and variant4 #97

Merged
merged 1 commit into from
Aug 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 58 additions & 6 deletions src/Elm/Declare.elm
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module Elm.Declare exposing
, Annotation, alias, customType
, toFile, include, withSubmodule
, customTypeAdvanced, CustomType
, variant0, variant1, variant2
, variant0, variant1, variant2, variant3, variant4
, CustomTypeBuilder, customVariant, finishCustomType
, Internal
)
Expand Down Expand Up @@ -157,7 +157,7 @@ As an example, here's how to create a helper for the `Maybe` type.

@docs customTypeAdvanced, CustomType

@docs variant0, variant1, variant2
@docs variant0, variant1, variant2, variant3, variant4

@docs CustomTypeBuilder, customVariant, finishCustomType

Expand Down Expand Up @@ -356,11 +356,11 @@ variant0 name toBranch custom =
{-| -}
variant1 :
String
-> Elm.Annotation.Annotation
-> (case_ -> (Expression -> Expression))
-> Elm.Annotation.Annotation
-> CustomTypeBuilder case_ ((Expression -> Expression) -> make_)
-> CustomTypeBuilder case_ make_
variant1 name type0 toBranch custom =
variant1 name toBranch type0 custom =
let
args : Elm.Arg (Expression -> Expression) -> Elm.Arg Expression
args record =
Expand All @@ -377,12 +377,12 @@ variant1 name type0 toBranch custom =
{-| -}
variant2 :
String
-> (case_ -> (Expression -> Expression -> Expression))
-> Elm.Annotation.Annotation
-> Elm.Annotation.Annotation
-> (case_ -> (Expression -> Expression -> Expression))
-> CustomTypeBuilder case_ ((Expression -> Expression -> Expression) -> make_)
-> CustomTypeBuilder case_ make_
variant2 name type0 type1 toBranch custom =
variant2 name toBranch type0 type1 custom =
let
args : Elm.Arg (Expression -> Expression -> Expression) -> Elm.Arg Expression
args record =
Expand All @@ -397,6 +397,58 @@ variant2 name type0 type1 toBranch custom =
standardVariant name [ type0, type1 ] toBranch args make custom


{-| -}
variant3 :
String
-> (case_ -> (Expression -> Expression -> Expression -> Expression))
-> Elm.Annotation.Annotation
-> Elm.Annotation.Annotation
-> Elm.Annotation.Annotation
-> CustomTypeBuilder case_ ((Expression -> Expression -> Expression -> Expression) -> make_)
-> CustomTypeBuilder case_ make_
variant3 name toBranch type0 type1 type2 custom =
let
args : Elm.Arg (Expression -> Expression -> Expression -> Expression) -> Elm.Arg Expression
args record =
record
|> Elm.Arg.item (Elm.Arg.varWith "arg0" type0)
|> Elm.Arg.item (Elm.Arg.varWith "arg1" type1)
|> Elm.Arg.item (Elm.Arg.varWith "arg2" type2)

make : (List Expression -> Expression) -> Expression -> Expression -> Expression -> Expression
make makeValue arg0 arg1 arg2 =
makeValue [ arg0, arg1, arg2 ]
in
standardVariant name [ type0, type1, type2 ] toBranch args make custom


{-| -}
variant4 :
String
-> (case_ -> (Expression -> Expression -> Expression -> Expression -> Expression))
-> Elm.Annotation.Annotation
-> Elm.Annotation.Annotation
-> Elm.Annotation.Annotation
-> Elm.Annotation.Annotation
-> CustomTypeBuilder case_ ((Expression -> Expression -> Expression -> Expression -> Expression) -> make_)
-> CustomTypeBuilder case_ make_
variant4 name toBranch type0 type1 type2 type3 custom =
let
args : Elm.Arg (Expression -> Expression -> Expression -> Expression -> Expression) -> Elm.Arg Expression
args record =
record
|> Elm.Arg.item (Elm.Arg.varWith "arg0" type0)
|> Elm.Arg.item (Elm.Arg.varWith "arg1" type1)
|> Elm.Arg.item (Elm.Arg.varWith "arg2" type2)
|> Elm.Arg.item (Elm.Arg.varWith "arg3" type3)

make : (List Expression -> Expression) -> Expression -> Expression -> Expression -> Expression -> Expression
make makeValue arg0 arg1 arg2 arg3 =
makeValue [ arg0, arg1, arg2, arg3 ]
in
standardVariant name [ type0, type1, type2, type3 ] toBranch args make custom


standardVariant :
String
-> List Elm.Annotation.Annotation
Expand Down
Loading