TODO: after we delete old code generator, we should replace `@[alwaysInline, inline]` with `@[alwaysInline]`. Remainder: we want the old code generator to ignore `@[alwaysInline]` annotations, in particular, the new ones on `instance` commands that are actually annotations for the instance methods.
32 lines
559 B
Text
32 lines
559 B
Text
/-
|
||
Copyright (c) 2017 Microsoft Corporation. All rights reserved.
|
||
Released under Apache 2.0 license as described in the file LICENSE.
|
||
Authors: Sebastian Ullrich
|
||
|
||
The identity Monad.
|
||
-/
|
||
prelude
|
||
import Init.Core
|
||
|
||
universe u
|
||
|
||
def Id (type : Type u) : Type u := type
|
||
|
||
namespace Id
|
||
|
||
@[alwaysInline]
|
||
instance : Monad Id where
|
||
pure x := x
|
||
bind x f := f x
|
||
map f x := f x
|
||
|
||
def hasBind : Bind Id :=
|
||
inferInstance
|
||
|
||
@[alwaysInline, inline]
|
||
protected def run (x : Id α) : α := x
|
||
|
||
instance [OfNat α n] : OfNat (Id α) n :=
|
||
inferInstanceAs (OfNat α n)
|
||
|
||
end Id
|