Skip to content
Permalink
Browse files

Add `Text/default{,Map}` to Prelude (#713)

Fixes #705
  • Loading branch information...
Gabriel439 committed Sep 2, 2019
1 parent 5fea454 commit cf74e7cfe999595d5f9c1683e75a226ca1288147
Showing with 48 additions and 11 deletions.
  1. +12 −0 Prelude/Text/default
  2. +15 −0 Prelude/Text/defaultMap
  3. +6 −0 Prelude/Text/package.dhall
  4. +1 −1 Prelude/package.dhall
  5. +14 −10 tests/typecheck/success/preludeB.dhall
@@ -0,0 +1,12 @@
{-
Unwrap an `Optional` `Text` value, defaulting `None` to `""`
-}
let default
: Optional Text Text
= λ(o : Optional Text) Optional/fold Text o Text (λ(t : Text) t) ""

let example0 = assert : default (Some "ABC") "ABC"

let example1 = assert : default (None Text) ""

in default
@@ -0,0 +1,15 @@
{-
Transform the value in an `Optional` into `Text`, defaulting `None` to `""`
-}
let defaultMap
: (a : Type) (a Text) Optional a Text
= λ(a : Type)
λ(f : a Text)
λ(o : Optional a)
Optional/fold a o Text f ""

let example0 = assert : defaultMap Natural Natural/show (Some 0) "0"

let example1 = assert : defaultMap Natural Natural/show (None Natural) ""

in defaultMap
@@ -10,6 +10,12 @@
, concatSep =
./concatSep sha256:e4401d69918c61b92a4c0288f7d60a6560ca99726138ed8ebc58dca2cd205e58
? ./concatSep
, default =
./default sha256:e26d120fe57a4b61259d1149d938a66d335e1eb263196c30311c117073e4f92f
? ./default
, defaultMap =
./defaultMap sha256:a35c0e1db25e9223223b0beba0fcefeba7cd06a0edfa3994ccc9f82f6b86ff79
? ./defaultMap
, show =
./show sha256:c9dc5de3e5f32872dbda57166804865e5e80785abe358ff61f1d8ac45f1f4784
? ./show
@@ -26,7 +26,7 @@
./JSON/package.dhall sha256:34a613c89df3f314c606a813f592d1a09fedb3e5f5e63fcc0ae9c88245e8bdad
? ./JSON/package.dhall
, Text =
./Text/package.dhall sha256:3b6ed813caf2388b91056d625c6b958b72009f85a6af262d4a7b935b18caf62b
./Text/package.dhall sha256:0a0ad9f649aed94c2680491efb384925b5b2bb5b353f1b8a7eb134955c1ffe45
? ./Text/package.dhall
, XML =
./XML/package.dhall sha256:6aed7e845c29bc528ced19b99f860c5bcd50f24a1394631fe66f751999f85361
@@ -297,6 +297,8 @@
Natural
, enumerate :
(n : Natural) List Natural
, equal :
(a : Natural) (b : Natural) Bool
, even :
Natural Bool
, fold :
@@ -305,8 +307,16 @@
(succ : natural natural)
(zero : natural)
natural
, greaterThan :
(x : Natural) (y : Natural) Bool
, greaterThanEqual :
(x : Natural) (y : Natural) Bool
, isZero :
Natural Bool
, lessThan :
(x : Natural) (y : Natural) Bool
, lessThanEqual :
(x : Natural) (y : Natural) Bool
, odd :
Natural Bool
, product :
@@ -319,16 +329,6 @@
(n : Natural) Double
, toInteger :
Natural Integer
, lessThan :
Natural Natural Bool
, lessThanEqual :
Natural Natural Bool
, equal :
Natural Natural Bool
, greaterThan :
Natural Natural Bool
, greaterThanEqual :
Natural Natural Bool
}
, Optional :
{ all :
@@ -389,6 +389,10 @@
Text
, concatSep :
(separator : Text) (elements : List Text) Text
, default :
(o : Optional Text) Text
, defaultMap :
(a : Type) (f : a Text) (o : Optional a) Text
, show :
Text Text
}

0 comments on commit cf74e7c

Please sign in to comment.
You can’t perform that action at this time.