mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-05-26 11:18:55 -06:00
Add Nothing' to Maybe.gf, including warning
This commit is contained in:
@@ -9,21 +9,27 @@ resource Maybe = open Prelude, Predef in {
|
|||||||
-- Constructors
|
-- Constructors
|
||||||
Maybe : (t : Type) -> Type = \t -> {
|
Maybe : (t : Type) -> Type = \t -> {
|
||||||
inner : t ;
|
inner : t ;
|
||||||
exists : Bool
|
exists : Bool ;
|
||||||
} ;
|
} ;
|
||||||
Just : (T : Type) -> T -> Maybe T = \_,t -> {
|
Just : (T : Type) -> T -> Maybe T = \_,t -> {
|
||||||
inner = t ;
|
inner = t ;
|
||||||
exists = True
|
exists = True ;
|
||||||
} ;
|
} ;
|
||||||
-- Nothing : (T : Type) -> Maybe T = \_ -> {
|
|
||||||
-- inner = variants {} ;
|
|
||||||
-- exists = False
|
|
||||||
-- } ;
|
|
||||||
Nothing : (T : Type) -> T -> Maybe T = \_,t -> {
|
Nothing : (T : Type) -> T -> Maybe T = \_,t -> {
|
||||||
inner = t ;
|
inner = t ;
|
||||||
exists = False
|
exists = False ;
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
-- IMPORTANT
|
||||||
|
-- This version of Nothing would be preferred, but it may not work as expected.
|
||||||
|
-- This happens when using Nothing within a record. For discussion of this see:
|
||||||
|
-- https://groups.google.com/d/msg/gf-dev/KAQEttN-0Cs/EjGHjOXEKO0J
|
||||||
|
Nothing' : (T : Type) -> Maybe T = \_ -> {
|
||||||
|
inner = variants {} ;
|
||||||
|
exists = False ;
|
||||||
|
} ;
|
||||||
|
-- You have been warned!
|
||||||
|
|
||||||
-- Functions
|
-- Functions
|
||||||
exists : (T : Type) -> Maybe T -> Bool = \_,m -> m.exists ;
|
exists : (T : Type) -> Maybe T -> Bool = \_,m -> m.exists ;
|
||||||
isJust : (T : Type) -> Maybe T -> Bool = \_,m -> m.exists ;
|
isJust : (T : Type) -> Maybe T -> Bool = \_,m -> m.exists ;
|
||||||
|
|||||||
Reference in New Issue
Block a user