Sha256: 46a98a9660f04decbe33f90b00487d1586c8d1e950be0c26a034fcb22e602674
Contents?: true
Size: 1.82 KB
Versions: 2
Compression:
Stored size: 1.82 KB
Contents
module Steep module AST module Types class Proc attr_reader :location attr_reader :params attr_reader :return_type def initialize(params:, return_type:, location: nil) @location = location @params = params @return_type = return_type end def ==(other) other.is_a?(self.class) && other.params == params && other.return_type == return_type end def hash self.class.hash && params.hash && return_type.hash end alias eql? == def subst(s) self.class.new( params: params.subst(s), return_type: return_type.subst(s), location: location ) end def to_s "^#{params} -> #{return_type}" end def free_variables params.free_variables + return_type.free_variables end def level children = params.each_type.to_a + [return_type] [0] + level_of_children(children) end def closed? params.closed? && return_type.closed? end def with_location(new_location) self.class.new(location: new_location) end def map_type(&block) self.class.new( params: params.map_type(&block), return_type: yield(return_type), location: location ) end def one_arg? params.required.size == 1 && params.optional.empty? && !params.rest && params.required_keywords.empty? && params.optional_keywords.empty? && !params.rest_keywords end def back_type Name.new_instance(name: "::Proc", location: location) end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
steep-0.5.1 | lib/steep/ast/types/proc.rb |
steep-0.5.0 | lib/steep/ast/types/proc.rb |