Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Provide Prelude
-like environment when using RebindableSyntax
If you want to use large-records
with OverloadedRecordDot
and
OverloadedRecordUpdate
, you need to enable the RebindableSyntax
language
extension. You can then import this module to get a standard environment
back, with one exception; see getField
for details.
Synopsis
- module Prelude
- app :: ArrowApply a => a (a b c, b) c
- arr :: Arrow a => (b -> c) -> a b c
- first :: Arrow a => a b c -> a (b, d) (c, d)
- loop :: ArrowLoop a => a (b, d) (c, d) -> a b c
- (>>>) :: forall {k} cat (a :: k) (b :: k) (c :: k). Category cat => cat a b -> cat b c -> cat a c
- (|||) :: ArrowChoice a => a b d -> a c d -> a (Either b c) d
- fromString :: IsString a => String -> a
- fromLabel :: IsLabel x a => a
- ifThenElse :: Bool -> a -> a -> a
- getField :: forall x r a. HasField x r a => r -> a
- setField :: forall x r a. HasField x r a => r -> a -> r
Documentation
module Prelude
app :: ArrowApply a => a (a b c, b) c #
first :: Arrow a => a b c -> a (b, d) (c, d) #
Send the first component of the input through the argument arrow, and copy the rest unchanged to the output.
(>>>) :: forall {k} cat (a :: k) (b :: k) (c :: k). Category cat => cat a b -> cat b c -> cat a c infixr 1 #
Left-to-right composition
(|||) :: ArrowChoice a => a b d -> a c d -> a (Either b c) d infixr 2 #
Fanin: Split the input between the two argument arrows and merge their outputs.
The default definition may be overridden with a more efficient version if desired.
fromString :: IsString a => String -> a #
New definitions
ifThenElse :: Bool -> a -> a -> a Source #
getField :: forall x r a. HasField x r a => r -> a Source #
Get record field
This is NOT the standard getField
from GHC.Records, but is instead
defined in terms of GHC.Records.Compat.HasField. As a consequence we do not
currently support OverloadedRecordDot
without RebindableSyntax
.
(For ghc 9.2 and 9.4 RebindableSyntax
is required anyway when using
OverloadedRecordUpdate
, so this is less of a limitation than it might
seem.)
Unfortunately, we cannot currently support HasField
; in the
remainder of this comment we explain why. Consider a record such as
{-# ANN type Person largeRecord #-} data Person = Person { name :: String }
The internal representation of this record generated by large-records
looks something like this:
data Person = forall a. a ~ String => Person { name :: a }
This representation prevents ghc from generating record accessors, whilst
at the same time still making it possible to define and pattern match on
records in the normal way. Unfortunately, although GHC does not generate
a HasField
instance for such a record, it also prevents us from
defining our own:
If a field has a higher-rank or existential type, the corresponding HasField constraint will not be solved automatically (as described above), but in the interests of simplicity we do not permit users to define their own instances either.
https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/hasfield.html#solving-hasfield-constraints
There is a proposal to change this
(https://github.com/ghc-proposals/ghc-proposals/pull/515),
but for now we instead rely on HasField
, for which no
such restrictions exist.