open import FRP.JS.Level using ()

module FRP.JS.Primitive where

-- We define the primitive types here, to avoid cyclic module dependencies

data Bool : Set where
  true  : Bool
  false : Bool

{-# BUILTIN BOOL  Bool  #-}
{-# BUILTIN TRUE  true  #-}
{-# BUILTIN FALSE false #-}

{-# COMPILED_JS Bool function(x,v) { if (x) { return v["true"](); } else { return v["false"](); } } #-}
{-# COMPILED_JS true true #-}
{-# COMPILED_JS false false #-}

data  : Set where
  zero : 
  suc  :   

{-# BUILTIN NATURAL     #-}
{-# BUILTIN ZERO    zero #-}
{-# BUILTIN SUC     suc  #-}

{-# COMPILED_JS  function (x,v) {
  if (x < 1) { return v.zero(); } else { return v.suc(x-1); }
} #-}
{-# COMPILED_JS zero 0 #-}
{-# COMPILED_JS suc function (x) { return x+1; } #-}

postulate
  Char String   : Set

{-# BUILTIN CHAR    Char #-}
{-# BUILTIN STRING  String #-}
{-# BUILTIN FLOAT    #-}
{-# BUILTIN INTEGER  #-}