mirror of
https://github.com/higherkindness/mu-haskell.git
synced 2024-10-26 15:49:00 +03:00
Better constructor for enumerations in optics (#115)
This commit is contained in:
parent
4444d6d85d
commit
acfc7281b5
@ -1,9 +1,10 @@
|
||||
{-# language AllowAmbiguousTypes #-}
|
||||
{-# language DataKinds #-}
|
||||
{-# language FlexibleInstances #-}
|
||||
{-# language FunctionalDependencies #-}
|
||||
{-# language GADTs #-}
|
||||
{-# language KindSignatures #-}
|
||||
{-# language LambdaCase #-}
|
||||
{-# language PolyKinds #-}
|
||||
{-# language ScopedTypeVariables #-}
|
||||
{-# language TypeApplications #-}
|
||||
{-# language TypeOperators #-}
|
||||
@ -31,8 +32,7 @@ as values in the schema type.
|
||||
-}
|
||||
module Mu.Schema.Optics (
|
||||
-- * Build a term
|
||||
record
|
||||
, record1
|
||||
record, record1, enum
|
||||
, _U0, _Next, _U1, _U2, _U3
|
||||
-- * Re-exported for convenience.
|
||||
, module Optics.Core
|
||||
@ -176,6 +176,11 @@ instance (r ~ NS (FieldValue w sch) choices)
|
||||
typeLensGet (FUnion x) = x
|
||||
typeLensSet = FUnion
|
||||
|
||||
enum :: forall (choiceName :: Symbol) choices w sch name.
|
||||
EnumLabel choices choiceName
|
||||
=> Term w sch ('DEnum name choices)
|
||||
enum = TEnum $ enumPrismBuild (Proxy @choiceName)
|
||||
|
||||
instance (EnumLabel choices choiceName, r ~ ())
|
||||
=> LabelOptic choiceName A_Prism
|
||||
(Term w sch ('DEnum name choices))
|
||||
|
Loading…
Reference in New Issue
Block a user