Skip to content

Commit

Permalink
Removes fromList
Browse files Browse the repository at this point in the history
  • Loading branch information
gampleman committed Mar 22, 2024
1 parent 9d052d8 commit 62eceeb
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 24 deletions.
2 changes: 1 addition & 1 deletion docs.json

Large diffs are not rendered by default.

23 changes: 2 additions & 21 deletions src/Triple/Extra.elm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module Triple.Extra exposing
, first, second, third
, apply, sortWith
, map, mapFirst, mapSecond, mapThird
, toList, fromList
, toList
)

{-| Convenience functions for 3-Tuples (also known as Triple).
Expand Down Expand Up @@ -40,7 +40,7 @@ This is good advice! However triples do have their usecases for anonymous groupi
# Lists
@docs toList, fromList
@docs toList
-}

Expand Down Expand Up @@ -235,22 +235,3 @@ map f ( a, b, c ) =
toList : ( a, a, a ) -> List a
toList ( a, b, c ) =
[ a, b, c ]


{-| Creates a triple from the first three elements of a list.
Triple.Extra.fromList [ 1, 2, 3, 4 ]
--> Just ( 1, 2, 3 )
Triple.Extra.fromList [ 1, 2 ]
--> Nothing
-}
fromList : List a -> Maybe ( a, a, a )
fromList lst =
case lst of
a :: b :: c :: _ ->
Just ( a, b, c )

_ ->
Nothing
3 changes: 1 addition & 2 deletions tests/TripleTests.elm
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,5 @@ suite =
triple
|> Triple.Extra.toList
|> List.sort
|> Triple.Extra.fromList
|> Expect.equal (Just (Triple.Extra.sortWith compare triple))
|> Expect.equal (Triple.Extra.sortWith compare triple |> Triple.Extra.toList)
]

0 comments on commit 62eceeb

Please sign in to comment.