Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] View of /branches/vis15/src/compiler/common/create.sml
ViewVC logotype

View of /branches/vis15/src/compiler/common/create.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4045 - (download) (annotate)
Sun Jun 26 14:54:01 2016 UTC (3 years, 5 months ago) by jhr
File size: 924 byte(s)
  Working on merge: factor out common representation for strand creation
(* create.sml
 *
 * Generic representation of the initial-strand creation code in a Diderot program.
 *
 * This code is part of the Diderot Project (http://diderot-language.cs.uchicago.edu)
 *
 * COPYRIGHT (c) 2016 The University of Chicago
 * All rights reserved.
 *)

structure Create =
  struct

    datatype 'a t = Create of {
	dim : int option,
	code : 'a
      }

    fun grid (d, code) = Create{dim = SOME d, code = code}

    fun collection code = Create{dim = NONE, code = code}

  (* are the strands in a grid? *)
    fun isGrid (Create{dim=SOME _, ...}) = true
      | isGrid _ = false

  (* get the grid dimension *)
    fun gridDim (Create{dim, ...}) = dim

  (* get the creation code *)
    fun createCode (Create{code, ...}) = code

    fun map f (Create{dim, code}) = Create{dim = dim, code = f code}
    fun app f (Create{dim, code}) = f code
    fun fold f init (Create{dim, code}) = f (code, init)

  end

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0