# Exercise: Option Type
#
# The Option type represents a value that might or might not exist.
#
# union Option {
#   Some { value: Int }
#   None
# }
#
# The compiler generates:
#   Make-Some  ( Int -- Option )
#   Make-None  ( -- Option )
#
# Examples:
#   42 Make-Some     # An Option containing 42
#   Make-None        # An empty Option
#
# Use match to check which variant:
#   my-option match
#     Some { >value } -> value   # extracts the value field
#     None -> 0                  # handle empty case
#   end
#
# NOTE: We define our own Option here to learn how variants work.
# The stdlib has a built-in Option type - and it's implemented in
# Seq just like this! Most of the stdlib is written in Seq itself.
#
# Seq 4.0 auto-generates for each variant:
#   - Predicates: is-Some?, is-None?
#   - Field accessors: Some-value (extracts the value field)
# We implement our own to understand how match works internally.
#
# Your task: Implement is-some? and is-none? using match
#
# When done, delete the marker line below.

union Option {
    Some { value: Int }
    None
}

# I AM NOT DONE

: is-some? ( Option -- Bool )
    # Return true if Some, false if None
    # Your code here - use match
    drop false
;

: is-none? ( Option -- Bool )
    # Return true if None, false if Some
    # Your code here - use match
    drop false
;

: test-some ( -- )
    100 Make-Some is-some?
    # Do not edit below this line
    test.assert
;

: test-none ( -- )
    Make-None is-none?
    # Do not edit below this line
    test.assert
;

: test-some-not-none ( -- )
    42 Make-Some is-none?
    # Do not edit below this line
    not test.assert
;
