Class: Dhall::Builtins::Optional_build

Inherits:
Dhall::Builtin show all
Defined in:
lib/dhall/builtins.rb

Instance Method Summary collapse

Methods inherited from Dhall::Builtin

#as_json, #unfill

Methods inherited from Expression

#&, #*, #+, #as_dhall, #cache_key, #concat, decode, #deep_merge, #deep_merge_type, #dhall_eq, #digest, #fetch, #merge, #normalize, #resolve, #shift, #slice, #substitute, #to_cbor, #to_proc, #to_s, #|

Instance Method Details

#call(arg) ⇒ Object



356
357
358
359
360
361
362
363
364
# File 'lib/dhall/builtins.rb', line 356

def call(arg)
  fill_or_call(arg) do
    arg.call(
      Optional.new.call(type),
      some,
      OptionalNone.new(value_type: type)
    )
  end
end

#fusion(*args) ⇒ Object



345
346
347
348
349
350
351
352
353
354
# File 'lib/dhall/builtins.rb', line 345

def fusion(*args)
  _, arg, = args
  if arg.is_a?(Application) &&
     arg.function.is_a?(Application) &&
     arg.function.function == Optional_fold.new
    arg.argument
  else
    super
  end
end