This repository has been archived by the owner on Mar 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: A function to add a connection to a state
- Loading branch information
1 parent
f3f8fbf
commit 9e0a425
Showing
5 changed files
with
90 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,17 @@ | ||
module Lunarbox.Data.Lens where | ||
module Lunarbox.Data.Lens | ||
( listToArrayIso | ||
, newtypeIso | ||
) where | ||
|
||
import Data.Lens (Lens', iso) | ||
import Data.Array as Array | ||
import Data.Lens (Lens', Iso', iso) | ||
import Data.List as List | ||
import Data.Newtype (class Newtype, unwrap, wrap) | ||
|
||
-- Generic iso which can be used for any data type with a newtype instance | ||
newtypeIso :: forall a b. Newtype a b => Lens' a b | ||
newtypeIso = iso unwrap wrap | ||
|
||
-- I usually use this when I want to focus on a single element of a lsit | ||
listToArrayIso :: forall a. Iso' (List.List a) (Array a) | ||
listToArrayIso = iso List.toUnfoldable Array.toUnfoldable |